List Structure problem with Python

Hi there,
I just want to take all the Project Points informations for some links.
I’m adapting one code in this forum.
Right know i get all the project base point in one list and all the project survey point in other list.

My goal is to get all the information for one doc in one list and so on.

Could you help me? Thanks in advance.

image

import clr
import math
# import Document Manager
clr.AddReference("RevitServices")
import RevitServices 
from RevitServices.Persistence import DocumentManager
#doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

dataEnteringNode = IN
docs = IN[0]
outData = []
ft2m = 0.3048
outProjBasePt = []
outProjSurvPt = []
outProjLoc = []
for n in docs:
	coll = FilteredElementCollector(n)
	basePt = coll.OfClass(BasePoint).ToElements()

	projBasePt = None

	for e in basePt:
		a = e.Category.Name
		if a == "Project Base Point":		
			pbpEW = e.LookupParameter("E/W")
			pbpNS = e.LookupParameter("N/S")
			pbpElev = e.LookupParameter("Elev")
			pbpAngle = e.LookupParameter("Angle to True North")
			
		elif a == "Survey Point":
			pspEW = e.LookupParameter("E/W")
			pspNS = e.LookupParameter("N/S")
			pspElev = e.LookupParameter("Elev")
	
	outProjBasePt.append(round(pbpNS.AsDouble()*ft2m,6))
	outProjBasePt.append(round(pbpEW.AsDouble()*ft2m,6))
	outProjBasePt.append(round(pbpElev.AsDouble()*ft2m,6))
	outProjBasePt.append(round(pbpAngle.AsDouble()*180/math.pi,6))

	outProjSurvPt.append(round(pspNS.AsDouble()*ft2m,6))
	outProjSurvPt.append(round(pspEW.AsDouble()*ft2m,6))
	outProjSurvPt.append(round(pspElev.AsDouble()*ft2m,6))		
	

	projLoc = n.ActiveProjectLocation
	origin = XYZ(0.0,0.0,0.0)

	projPos = projLoc.get_ProjectPosition(origin)
	if projPos == None:
		outProjLoc.append("No Project Position at origin point")
	else:
		outProjLoc.append(round(projPos.EastWest * ft2m,6))
		outProjLoc.append(round(projPos.NorthSouth * ft2m,6))
	    	
OUT = [outProjLoc, outProjBasePt, outProjSurvPt]

Right now, you are appending everything to the same list. Your current structure is like this:

docs = [a, b, c]
out_list = []
for doc in docs:
    out_list.append(1)
    out_list.append(2)

You can change the structure to this:

docs = [a, b, c]
out_list = []
for doc in docs:
    out_sublist = []
    out_sublist.append(1)
    out_sublist.append(2)
    out_list.append(out_sublist)

This way i’ll get the same item for the 2 elements in one list right?
I want to get the 2 parameters for one element in one list.

a,b = docs , x and y PBP, PSP. then a sublists with the parameters.

My goal is to get one list with PBP1,PSP1 and other one with PBP2,PSP2

Maybe the solution is really simple but i can’t get it.

Thanks for your attention.

image

You can try this:

import clr
import math
# import Document Manager
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

docs = IN[0]
outData = []
ft2mm = 304.8

for doc in docs:
	if doc == None:
		continue
	name = doc.Title
	coll = FilteredElementCollector(doc)
	basePts = coll.OfClass(BasePoint).ToElements()
	projBasePt = None
	basePt = []
	survPt = []
	loc = []
	for e in basePts:
		a = e.Category.Name
		if a == "Project Base Point":		
			pbpEW = e.LookupParameter("E/W")
			pbpNS = e.LookupParameter("N/S")
			pbpElev = e.LookupParameter("Elev")
			pbpAngle = e.LookupParameter("Angle to True North")
			basePt.append(round(pbpEW.AsDouble()*ft2mm,6))
			basePt.append(round(pbpNS.AsDouble()*ft2mm,6))
			basePt.append(round(pbpElev.AsDouble()*ft2mm,6))
			basePt.append(round(pbpAngle.AsDouble()*180/math.pi,6))
		elif a == "Survey Point":
			pspEW = e.LookupParameter("E/W")
			pspNS = e.LookupParameter("N/S")
			pspElev = e.LookupParameter("Elev")
			survPt.append(round(pspEW.AsDouble()*ft2mm,6))
			survPt.append(round(pspNS.AsDouble()*ft2mm,6))
			survPt.append(round(pspElev.AsDouble()*ft2mm,6))
	
	projLoc = doc.ActiveProjectLocation
	origin = XYZ(0.0,0.0,0.0)
	
	projPos = projLoc.get_ProjectPosition(origin)
	if projPos == None:
		loc.append("No Project Position at origin point")
	else:
		loc.append(round(projPos.EastWest * ft2mm,6))
		loc.append(round(projPos.NorthSouth * ft2mm,6))
	projData = [name] + [basePt] + [survPt]# + [loc] #for Active Location
	outData.append(projData)
	    	
OUT = outData

This will include the linked doc’s file name as well, but you can remove it by deleting [name] + on line 56. You can also add in the active project location by deleting # infront of + [loc] on the same line.

list%20structure%20active%20proj

The Linked Project titled node is just a python script node.

3 Likes

That’s it! Thanks kenny!