Set Wall Compound Layers Function

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?

Captura

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)

2 Likes

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.

1 Like

@Daniel_Aramburu

I still have no idea what your end goal is and why you’d need to do this complicated conversion in the first place. :confused: :slight_smile:

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.

3 Likes

@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.

2 Likes

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.

1 Like

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

EOF EXPECTEDOPEN PAR EXPECTED

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 !