Greetings,
It is possible to get Layers from an external document with OOTB (built in) Civil 3D Dynamo Nodes? If not does anyone have a coded node they would share?
The Why?
I have:
A dwg that represents all of my standard layers that should be frozen for the current document.
I want:
To read from the external dwg all of it’s layers.
(Future: Separate lists for Frozen and Thawed Layers)
(Future: I would also like to add in a list of layers with wild cards to freeze, ie pipe network layers created by Civil 3D. ==> P-Storm-* with * being the wild card.)
I have not tried to figure out the wild card layers yet. But attached is my attempt at getting the standard layers to freeze. It is easy to find nodes to get/create a current document layers list, but when I try to pick an external document it does not like the input?
(Future: Ideally, the source dwg should have the thawed layers as well, and the dyn should be able to use the thawed layers list to apply attributes (color, linetype, and plotsyle) to any matching layers in the current dwg… but that is probably a lot of Python, which I am just starting to look at.)
StandardLayersToFreeze.dyn (27.5 KB)
Any guidance would be much appreciated.
Not a solution for an external document, but maybe process that document once into an external format which can be more readily read (i.e. CSV, JSON) and leverage that instead? Will read faster too.
Can you recommend an OOTB node(s) I would use if I had a CSV file with Layer Names I wanted to freeze?
Yes - the ones which show up in the library when you search CSV. 
Seriously though this will get the data into the graph, then you just have to work at freezing / thawing / updating the layer settings in your active file.
Good answer, I should have looked before replying…
if I cannot find it I may be back… Thank you for your suggestion.
1 Like
That worked great. I had to find a way to remove layers that did not exist in the current dwg so it would not error out and stop. But there is an OOTB node (List.SetDifference) to create a list by removing items that do not exist in one list from the other and creating a new List… and that did the trick.
StandardLayersToFreezeFromCSV.dyn (31.2 KB)
Thank you again for you suggestion.
1 Like
Thanks but I realized it is doing the reverse of what I want… I will need to have the layers I want to remain thawed in the CSV, instead of the ones I want frozen.
There must be a way to have it do two Layer commands in a specific order… If I freeze all in Current Document, and then run dyn with boolean set to false it thaws all layers not in list… ie… keeps frozen what is in CSV file.
But I do not see a way of telling it to run this set of nodes first, and then this other set of nodes next? Is this something easy I am just missing?
You’re describing a ‘WaitFor’ method. A node won’t execute until the node which it has an an input executes first. Say you want to add two numbers after you multiple two other numbers together. If you build a list from the result of the addition node and one of the numbers to multiply, and the. Take the number to multiply out of the list and pass that into the multiplication node. Now the addition node has to complete before the multiplication node can.
This can also be done with a custom node (the clockwork package has such a node, as do a few other packages), or with a single line of design script [waitfor, passthrough][1];
and wire the result of the thing you want to complete into the ‘waitfor’ input and the thing you want to pass into the second action into the ‘passthrough’ input.
1 Like
Awesome! it worked and now I have created my first code block.
Thank you!
2 Likes
StandardLayersToFreeze.dyn (33.0 KB)
Hi, I updated this .dyn with some “external document layer” nodes from the camber package. You need to download CAMBER and use that.
There are standard nodes that do exactly what you are asking.
CSV and OOTB nodes seem to work great if you use exact layer names. Finished dyn below for when we have all layer names to freeze.
Layers_VIZ_from_CSVs.dyn (37.7 KB)
Problem is that some of the layers I want to freeze may be in XREFs and the name of the XREFs are not always the same.
I cannot get wildcards to work with the “LayerExtensions.SetIsFrozen” node?
LayerExtensions.SetIsFrozen_Not Working with wild Cards.dyn (9.4 KB)
Is there a node for freezing layers that works with wild cards? I would like to be able to freeze all -DEMO layers in a dwg. A wildcard in front of the -DEMO should be able to pick up the XREF Layers ie… BaseXREF2|E-BOC-DEMO.
I don’t think it is doable by default, but perhaps @zachri.jensen has thoughts?
Likely you would want to pull all layers, then get the later names, then use a String.Contains node to get names which contain the desired strings to freeze (excluding the asterisk symbol) and then use a List.AnyTrue followed by a List.FilterByBoolMask where the layers (nkt their names) are the list and the boolean list from AnyTrue is the mask. Anything in the ‘out’ would want to be not frozen (Unfrozen? Thawed? Defrosted? No idea what the CAD term is here) and anything in the ‘in’ list would be frozen.
No, wildcards are not supported. Like Jacob outlined, I would use string operations to filter the list of layers down to what you need. Using your specific example, a wildcard of *-DEMO
is equivalent to a String.EndsWith
node with an input of -DEMO.
Kind of stupid Idea that I haven’t tested but would it be possible to search for layername (as string) that contains ”|” and then use List.FilterbyBoolmask on them. I think that the Xref layer name use to named like that.
String.Contains might be better than ‘ends with’ kf you want to catch -DEMO-Wall
and -DEMO-Plmb
in the same query. 
1 Like
”Great minds think alike”
1 Like
That should work, but it would just catch the xrefs rather than the xref layers containing -DEMO
as outlined above. 
Yes, true… then some extra coding should fix it.
1 Like
@btillett give the string filter method a shot and if you get stuck post back here. 2 Dynamo for Civil 3D super stars and myself are clearly interested in the topic, so you’ve got some good help if you get stuck.
Be sure to watch the list lacing and levels as you go - you should only have one String.Contains node even with many values from the CSV. 
2 Likes