layer control with ilogic form

layer control with ilogic form

Anonymous
Not applicable
1,694 Views
6 Replies
Message 1 of 7

layer control with ilogic form

Anonymous
Not applicable

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!

0 Likes
Accepted solutions (1)
1,695 Views
6 Replies
Replies (6)
Message 2 of 7

bretrick30
Advocate
Advocate

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.

Message 3 of 7

Anonymous
Not applicable

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!

0 Likes
Message 4 of 7

bretrick30
Advocate
Advocate
Accepted solution

 

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

 

0 Likes
Message 5 of 7

Anonymous
Not applicable

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

 

0 Likes
Message 6 of 7

Anonymous
Not applicable

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!

0 Likes
Message 7 of 7

rhasell
Advisor
Advisor

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
2026.1