Hello, I was wondering if someone has already run into this topic. I am currently trying to automate the process of changing Wall Compound Layer functions to be able to change them from Finish to Membrane. I am currently using the clockwork nodes FamilyType.SetCompoundLayerMaterial and FamilyType.SetCompoundLayerWidth, nevertheless there is no node to set the Function of the layer. I have tried to modify the FamilyType.SetCompoundLayerWidth node to change the Function of the layer instead of the width, with no success. Anyone?
Hi Daniel,
Youâre on the right path. All you need to do now is feed in correct layer function object. Youâll find a list of the available options here:
http://revitapisearch.com/html/1cbeb006-f7a2-f6d2-491f-faa0b9a006fc.htm
Youâll basically need to replace line 21 with:
cs.SetLayerFunction(indices[counter], MaterialFunctionAssignment.Membrane
)
Thank you @Dimitar_Venkov! I just managed to create a node to change the Finish Layer to Membrane (which exludes the core layer)⌠However, when trying to change back from membrane to Finish, the core layer also gets edited. I´m currently trying (Im new to python) to use an IF statment to exclude the core layer when switching back to Finish, however i can´t manage to make it work.
I still have no idea what your end goal is and why youâd need to do this complicated conversion in the first place.
Hereâs a script that might possibly do what you need. Use the toggle to convert between finishes to membranes and vice versa :
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
This script targets only the first and last layers of the wall because those are commonly the ones defined as finishes.
@Dimitar_Venkov If you remove the first and the last " in your code, the formatting gets much nicer on the forum. Iâm sorry if you already knew and it was intended.
Thanks, Einar.
I used âblockquoteâ instead of âpreformatted textâ. It does indeed look a lot nicer this way.
@Dimitar_Venkov, @Einar_Raknes Thank You! In our current workflow, we model the Structural elements in a separate RVT file from the architectural model. We currently use a material finish for concrete casts, to be able to get a material takeoff for concrete casts. The problem comes in the architectural model, when our team members want to setup the wall finishes, in many cases they end up aligning the wall finish to the finish (cast) of the structural model. To prevent this, we are now removing all (with your awesome help) cast layers and turning them to membrane (width = 0) so that our architectural team can work faster and with more accuracy. We then turn back the casts on for work On-Site. Hopes that clears the use for this!
Hope to see you at AU 2016 Las Vegas!
Best Regards from PerĂş.
Daniel A.
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
fablabolbia,
to create python codes inside a code block you have to start with âand end withâ; that is.
"
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 will need to determine yourself
cs.SetLayerWidth (i, 0.1)
t.SetCompoundStructure (cs)
TransactionManager.Instance.TransactionTaskDone ()
OUT = 0
";
thank you !