Hide layer by name

Hi,
i’m moving first steps with Dynamo, i’m trying to hide a singular layer with same name that is linked in a lot of dwg file, i’m in this situation…(image)…can someone help me?
Thanks

1 Like

Hi,

Welcome :slight_smile:

It’s always the way that the first simple thing you want to do… it turns out to be a pain…!

Here is a link to some custom code that was written to hide a Layer in a linked dwg…

This shows what you need to plug into it…

I obviously don’t know what your abilities are in Python, but if you have a lot of DWGs you’ll want to edit the code to iterate through them.

Hope that helps,

Mark

1 Like

TBH it was easy, so perhaps this saves some pain :slight_smile:

HideDwgLayersLst.dyn (7.1 KB)

Thanks Mark for the speedy response,
have you got any idea why i can’t see CAD.setlayervisibility function in my Bimorph nodes?

Because you’re at the cutting edge… :smiley: It’s going to be included in the next release of Thomas’ package I believe…

It occurs to me that you’ll likely need to iterate through a list of views and a list of layer names? So the code needs more work…

Just as an FYI… There are a few issues with your initial attempt…

E.G. you have extracted the Names… Then you’ve Sorted Them… That would mean they were nolonger ordered the same as the Layer Elements in your List… So you’d likely end up turning off the wrong one?

I would recommend going through the primer before going to much further :slight_smile:

https://primer.dynamobim.org/

Hope that’s of interest,

Mark

Edit:

This should work for single or lists now, it also does some filtering… you’ve got to be careful that only views which can see the dwg are run through it otherwise you get an error…
HideDwgLayersLstS.dyn (10.4 KB)
Capture

3 Likes

Thank you Mark, i have to work a lot on dynamo and python but your script work well, i tried with a simple file to understand the logic…the procedure is becoming clear.
Thanks again

1 Like

I’m trying something similar, but trying to do so via nodes so I can stay out of Python for the time being… It appears that it’s working, but in reality it only turns off the associated layers in one of the two link instances. Any ideas as to why it won’t pick up both, even though the script definitely SEEMS to be affecting both of them?

Hey,

I used it on one view, made that into a view template and applied that to lots of views… So for me, it worked with setting the layer visibility node ‘instance’ input to L1 and the names input to L2 with a single view input… Maybe try that and see if it works?

Cheers,

Mark

Thanks Mark! I think the view template thing will actually be a great stop-gap.

I’m using Dynamo 1.3 and cannot open the file…
can you share the phyton script please?