I have a script, creating (depending on parameters) different Levels.
e.g.:
OK_A
OK_B1
OK_B2
OK_B3
OK_C1
OK_C2
now the Levels OK_B1-3 may vary if they are implemented or not. Leaving a possible minimum of:
OK_A
OK_B1
OK_C1
OK_C2
so far so good.
Now in my next step I want to create columns using these levels. This is where my question is located. Is there a way to creat a Code Block with e.g. “OK_B1” as a fixed term for the level OK_B1? Because if I run the script creating only one B the transition von B to C wont work without opening the script selecting the right level in the list…
I want to creat a list with levels (by using CodeBlocks with fiexed names), kicking null values out of the list and add the last valid value on top of OK_C1.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
#Preparing input from dynamo to revit
run = IN[0]
name = IN[1]
#Do some action in a Transaction
if run:
fec = FilteredElementCollector(doc).OfClass(Level).ToElements()
for l in fec:
if l.Name == name:
OUT = l
else:
OUT = "Set Run to True"
One Question, do I have to set it up like this if I want to collect all levels? Or can I get along with one Python script block somehow??
@solamour
this method looks interessting aswell. My problem here is, that I don’t get the Code Block bottom left [“LEvel 2”… ]; to work. It won’t turn active.
@solamour
this method looks interessting aswell. My problem here is, that I don’t get the Code Block bottom left [“LEvel 2”… ]; to work. It won’t turn active.
Simply replace the "Level 2" orange text with your Level names Such as "OK_FT4"!
In the code block I use a square brace [ to start a List, and on the next line I use a String (Text) of each Level name (In my file: it was “Level 2” etc.), followed by a comma to finish the line. You an have as many lines as you wish, with the final line not having a comma. To end the List I finish with a square brace ] and to end the code block’s… block of code (hah… weird to type this!), you use a semi-colon ;.
It would need to be modified a little to make it work on a List if you are wanting to give it multiple Level names.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
#Preparing input from dynamo to revit
run = IN[0]
names = IN[1]
#Do some action in a Transaction
levels = []
if run:
fec = FilteredElementCollector(doc).OfClass(Level).ToElements()
for l in fec:
for n in names:
if l.Name == n:
levels.Add(l)
OUT = levels
else:
OUT = "Set Run to True"
To use the least RAM you can take either ZeroTouch (C# Custom Nodes) or Python - In both cases you will want to not return intermediate objects to the graph
For example - if you are building an array of points, then offsetting those points upwards, creating a line and then creating a cone from that line this is a lot of Geometry being held in memory. If you use Nodes, each step will be present in their respective nodes. If you use either method above (ZT or Python) and Dispose() of the geometry inside - simply returning only the cone, then all the other geometrical elements will not be held in RAM.
This is most noticeable with either large data-sets, or Geometry. For your workflow above it’s pretty negligible.