ilogic and work plane visibility toggle conditional

ilogic and work plane visibility toggle conditional

sam
Advocate Advocate
1,781 Views
7 Replies
Message 1 of 8

ilogic and work plane visibility toggle conditional

sam
Advocate
Advocate

Hi All,

I am looking for a way to link visibility (on/off) of work plane with associated feature being active (True/False).

Any help/ideas appreciated. 

 

regards,

Sajid Mahmood

 

 

0 Likes
Accepted solutions (4)
1,782 Views
7 Replies
Replies (7)
Message 2 of 8

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@sam,

 

Try below iLogic code to toggle visibility of work plane in part document.

 

Dim oDoc As PartDocument 
oDoc = ThisApplication.ActiveDocument 

Dim oDef As PartComponentDefinition 
oDef = oDoc.ComponentDefinition 

Dim oPlane As WorkPlane 
oPlane = oDef.WorkPlanes.Item("Work Plane") 'Need to specify name of work plane

oPlane.Visible = False ' True for visiblity

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 3 of 8

sam
Advocate
Advocate
Accepted solution

Hi Chander Sheker G, 

 

Thanks for the reply. Sorry for not being very clear with the message in my intial post. I was trying to write an iLogic code to link with a form where I would be turning off those features. Problem I am facing is that I can't seem to find where to do same with planes. 

Below is sample code:

 

SyntaxEditor Code Snippet

If Spacers = "2" Then Feature.IsActive("SpacerHoles01") = True
If Spacers = "2" Then Feature.IsActive("SpacerHoles02") = True

If Spacers = "1" Then Feature.IsActive("SpacerHoles01") = True If Spacers = "1" Then Feature.IsActive("SpacerHoles02") = False

If Spacers = "0" Then Feature.IsActive("SpacerHoles01") = False
If Spacers = "0" Then Feature.IsActive("SpacerHoles02") = False

Now these features SpacerHoles01 and SpacerHoles02 should turn on/off with their respective work planes names as Spacer1 and Spacer2. 
I hope I made myself clear this time. 
best regards, 
Sajid Mahmood

0 Likes
Message 4 of 8

clutsa
Collaborator
Collaborator
Accepted solution

i think @chandra.shekar.g had it right. Here's his code in your context.

Dim oDoc As PartDocument 
oDoc = ThisApplication.ActiveDocument 

Dim oDef As PartComponentDefinition 
oDef = oDoc.ComponentDefinition 

Dim oPlane1 As WorkPlane 
oPlane1 = oDef.WorkPlanes.Item("Spacer1") 'Need to specify name of work plane
Dim oPlane2 As WorkPlane 
oPlane2 = oDef.WorkPlanes.Item("Spacer2") 'Need to specify name of work plane

If Spacers = "2" Then 
	Feature.IsActive("SpacerHoles01") = True
	oPlane1.Visible = True
	Feature.IsActive("SpacerHoles02") = True
	oPlane2.Visible = True
Else If Spacers = "1" Then 
	Feature.IsActive("SpacerHoles01") = True
	oPlane1.Visible = True
	Feature.IsActive("SpacerHoles02") = False
	oPlane2.Visible = False
Else 'assume 0
	Feature.IsActive("SpacerHoles01") = False
	oPlane1.Visible = False 
	Feature.IsActive("SpacerHoles02") = False
	oPlane2.Visible = False
End If

or...

Dim oDoc As PartDocument 
oDoc = ThisApplication.ActiveDocument 

Dim oDef As PartComponentDefinition 
oDef = oDoc.ComponentDefinition 

Dim oPlane1 As WorkPlane 
oPlane1 = oDef.WorkPlanes.Item("Spacer1") 'Need to specify name of work plane
Dim oPlane2 As WorkPlane 
oPlane2 = oDef.WorkPlanes.Item("Spacer2") 'Need to specify name of work plane

Select Case Spacers
Case = "2"
	Feature.IsActive("SpacerHoles01") = True
	oPlane1.Visible = True
	Feature.IsActive("SpacerHoles02") = True
	oPlane2.Visible = True
Case = "1"
	Feature.IsActive("SpacerHoles01") = True
	oPlane1.Visible = True
	Feature.IsActive("SpacerHoles02") = False
	oPlane2.Visible = False
Case = "0"
	Feature.IsActive("SpacerHoles01") = False
	oPlane1.Visible = False 
	Feature.IsActive("SpacerHoles02") = False
	oPlane2.Visible = False
End Select
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 5 of 8

sam
Advocate
Advocate

@chandra.shekar.g thank you. 

@clutsa Thank you. 

0 Likes
Message 6 of 8

sam
Advocate
Advocate

@clutsa I have used first rule in on of my part. Some of that part parameters are being controlled in an Assembly. After incorporating This rule in the part it gives following error in the assembly. 

Error.JPG

 

Any insight what does this mean?

0 Likes
Message 7 of 8

clutsa
Collaborator
Collaborator
Accepted solution

The rule is running from a part document but the "active document" isn't that part anymore... try this so the rule stays focused on the document that called it 

Dim oDoc As PartDocument 
oDoc = ThisDoc.Document 'updated here

Dim oDef As PartComponentDefinition 
oDef = oDoc.ComponentDefinition 

Dim oPlane1 As WorkPlane 
oPlane1 = oDef.WorkPlanes.Item("Spacer1") 'Need to specify name of work plane
Dim oPlane2 As WorkPlane 
oPlane2 = oDef.WorkPlanes.Item("Spacer2") 'Need to specify name of work plane

If Spacers = "2" Then 
	Feature.IsActive("SpacerHoles01") = True
	oPlane1.Visible = True
	Feature.IsActive("SpacerHoles02") = True
	oPlane2.Visible = True
Else If Spacers = "1" Then 
	Feature.IsActive("SpacerHoles01") = True
	oPlane1.Visible = True
	Feature.IsActive("SpacerHoles02") = False
	oPlane2.Visible = False
Else 'assume 0
	Feature.IsActive("SpacerHoles01") = False
	oPlane1.Visible = False 
	Feature.IsActive("SpacerHoles02") = False
	oPlane2.Visible = False
End If
If I've helped you, please help me by supporting this idea.
Mass Override for Each Model State

Custom Glyph Icon for iMates

Message 8 of 8

sam
Advocate
Advocate

@clutsa Worked like a charm. 

Thank you so much for the help. have a good day sir. 

0 Likes