Hi everybody,
sorry for my terrible programming skills…I try to write the Code Block node but I have the following two problems…
Thank you in advance for the help !
Antonio
Hi @fablabolbia
Your missing double quotes ("") at the beginning and end of the code block.
Hi @Kulkul … still missing something.
Drop the code here.
import clr
clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
memb = MaterialFunctionAssignment.Membrane
fin1 = MaterialFunctionAssignment.Finish1
fin2 = MaterialFunctionAssignment.Finish2
types = UnwrapElement(IN[0])
f2m = IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
for t in types:
cs = t.GetCompoundStructure()
last_layer = cs.LayerCount - 1
for i in (0 , last_layer):
cur_fn = cs.GetLayerFunction(i)
if f2m and (cur_fn == fin1 or cur_fn == fin2):
cs.SetLayerFunction(i, memb)
# membranes require a thickness of 0
cs.SetLayerWidth(i, 0.0)
elif not f2m and cur_fn == memb:
cs.SetLayerFunction(i, fin1)
# finish layers need some width
# you’ll need to determine those yourself
cs.SetLayerWidth(i, 0.1)
t.SetCompoundStructure(cs)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0
@fablabolbia Like this.
You can copy paste this code.
"
import clr
clr.AddReference(‘RevitServices’)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference(‘RevitNodes’)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
memb = MaterialFunctionAssignment.Membrane
fin1 = MaterialFunctionAssignment.Finish1
fin2 = MaterialFunctionAssignment.Finish2
types = UnwrapElement(IN[0])
f2m = IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
for t in types:
cs = t.GetCompoundStructure()
last_layer = cs.LayerCount - 1
for i in (0 , last_layer):
cur_fn = cs.GetLayerFunction(i)
if f2m and (cur_fn == fin1 or cur_fn == fin2):
cs.SetLayerFunction(i, memb)
# membranes require a thickness of 0
cs.SetLayerWidth(i, 0.0)
elif not f2m and cur_fn == memb:
cs.SetLayerFunction(i, fin1)
# finish layers need some width
# you’ll need to determine those yourself
cs.SetLayerWidth(i, 0.1)
t.SetCompoundStructure(cs)
TransactionManager.Instance.TransactionTaskDone()
OUT = 0
";
Thank you very much @Kulkul
Antonio
No problem Mark the post as solved.
Done !
Thank you again
good afternoon!
I have a similar problem. Could suggest …
"
import clr, System
clr.AddReference(“RevitNodes”)
import Revit
clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *
clr.AddReference(“RevitServices”)
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocumentnameOfCategory = “Space”
bui = System.Enum.GetValues(BuiltInCategory) # Все BuiltInCategory
cats, buis = ,
for i in bui:
try:
cat = Revit.Elements.Category.ById(ElementId(i).IntegerValue) # Имена всех категорий
cats.append(cat)
buis.append(i)
except:
passfor i, b in zip(cats, buis):
if nameOfCategory == str(i): # Если имена категорий совпадают
ost = b # то получаем его BuiltInOUT = FilteredElementCollector(doc).OfCategory(ost).WhereElementIsNotElementType().ToElements()
";