Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Anonymous
1486 Views, 6 Replies

layer control with ilogic form

Can someone direct me to some ilogic code that will allow me to turn layers on/off? Or simply turn on/off sets of text? I would like to be able to control this in the same form I've created to input iproperty values.

 

Thanks in advance!

bretrick30
in reply to: Anonymous

SyntaxEditor Code Snippet

ThisDrawing.Document.StylesManager.Layers("Layer Name").Visible = False 'or True


I have notes on my drawings that certain text is turned on and off depending on a parameter.  You can assign a text box to a certain layer.

Anonymous
in reply to: bretrick30

This seems like it should help me, but given my lack of experience, I'm afraid I can't do much with this. My company is only beginning to use Inventor efficiently so I will have to take baby steps. I know exactly how to create parameters and write basic rules that allow my team to enter custom iproperty information through an ilogic form. And this is where my ilogic knowledge stops.

 

As of now, our material specs are separated by layers that we turn on/off each for drawing. I was hoping to find a way to turn these layers on and off through the form I've already created for other information.

 

I can't expect for everything to be handed to me.

 

Thanks for your help!

bretrick30
in reply to: Anonymous

 

You can use an If statement to control the layer.  

 

For example, if you have a parameter in your drawing called "Material", the code will look like this.

 

SyntaxEditor Code Snippet

If Material = "Stainless Steel" Then
    ThisDrawing.Document.StylesManager.Layers("Layer Name").Visible = True
Else
    ThisDrawing.Document.StylesManager.Layers("Layer Name").Visible = False
End If

 

Anonymous
in reply to: bretrick30

This makes perfect sense. However, I keep running into this error message:

 

Error in rule: Rule6, in document: Drawing7.idw

The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))

 

I used the parameter I created called "MATL" and inserted a parameter value in quotation marks. I'm not sure what's going on, but what you are supplying seems to be right way to go about it.

 

Thank you

 

Anonymous
in reply to: bretrick30

I've created a multivalue parameter with each value being in a different layer. I need the "default" layer, which is designated for custom values, to turn on only when the other parameter values are not used.

 

Can you help with a code that will allow this? I'm not sure how to deal with "all values except these" type of code.

 

Thank you!

rhasell
in reply to: bretrick30

Hi

Just in case I confused you with a like, three years later.

I needed to toggle a "Plot"  setting on a specific layer.

Your snippet saved me a lot of R&D

Thanks.

Reg
2025.2