Set Analytical Floor Alignment

#1

Hi

Anyone knows how I can set the Analytical floor Alignment “z Projection” to “Top of Element” or “Bottom of Element” through Dynamo? I get an error when typing a string.

0 Likes

#2

If it is a dropdown option you have to use a number. most likely a pattern like this

Option 1 - 0
Option 2 - 1
Option 3 - 2
Option 4 - 4
Option 5 - 8

You can figure it out by using Element.getParameterValueByName

0 Likes

#3

@Ahejnfelt You might find this useful…

0 Likes

#4

I have tried using numbers instead, but when I use “Element.GetParameterValueByName” it returns a string:

0 Likes

#5

Yes that is strange, it looks like it’s expectiing a ElementId as input, here is a screenshot from Revit Lookup:

I’m not sure how to get the ElementId of the top surface of your floor, but if you feed it a level it will work:

0 Likes

#6

I took another look at this, but had to turn to python to make it work:


(Edit: Python is updated, center and bottom had swapped places)

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

#Functions for list handling
def ProcessList(_func, _list):
    return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )

#Preparing input from dynamo to revit
if isinstance(IN[0], list):
	analyticalFloor = ProcessList(UnwrapElement, IN[0])
else:
	analyticalFloor = []
	analyticalFloor.append(UnwrapElement(IN[0]))

#Create a dictionary for getting the correct enum
prjOptEnum = { 
"Top of Element" : SurfaceElementProjectionZ.TopOrInterior, 
"Bottom of Element" : SurfaceElementProjectionZ.BottomOrExterior,
"Center of Element" : SurfaceElementProjectionZ.CenterOfElement,
}
#Look uo the the enum
projOption = prjOptEnum[IN[1]]

#Define function for API method:
def setProjection(aFloor,pOption = projOption):
		aFloor.ProjectionZ=pOption

#Change projection method in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

ProcessList(setProjection,analyticalFloor)

TransactionManager.Instance.TransactionTaskDone()

OUT = analyticalFloor
1 Like

Python Nodes Basics
#7

Hi Einar

Thanks a lot for the help!!

0 Likes