Inventor General Discussion

Inventor General Discussion

Reply
Active Member
rjones0215
Posts: 9
Registered: ‎10-01-2011
Message 1 of 28 (1,536 Views)
Accepted Solution

ilogic and work plane visibility

1536 Views, 27 Replies
03-23-2012 10:59 AM

Is there a way to turn off visibility on work planes using ilogic?   Also, is there a way to change an extrusion type from an assymetrical extrusion to a one direction extrusion using ilogic?

Inventor 2013 Certified Professional

This will turn the visibility of Work Plane1 off

 

Dim

oDoc As PartDocument

oDoc

= ThisDoc.Document

For Each

oWorkPlane In oDoc.ComponentDefinition.WorkPlanes

 

If oWorkPlane.Name = "Work Plane1" Then

'

oWorkPlane.Visible = False

'

End If

Next

 

 

 

Hi Diswill,

 

I think this will do it. I didn't have much time to review this, so you might find some un-needed lines, etc.

 

I'm probably missing something obvious, but as is this example only looks at sub assemblies one level deep. Meaning that if you have an assembly in your subassembly, it won't turn off the workplanes for the same reasons as before (view reps).

 

If I think of something different, I'll post back.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

sample #4

'get user input
oInput = InputRadioBox("Select workplane visibility:", _
"Turn ON workplanes for all components", "Turn OFF workplanes for all components", "False", "iLogic")
' set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Define the open document (top level assembly)
Dim openDoc As Document
openDoc = ThisDoc.Document
'define view rep
Dim oViewRep As DesignViewRepresentation
Dim sVRep as String
'change to something else if Default is used for something already
sVRep = "Default"
'create or activate view rep in the top level assembly
Try
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate
Catch
'create new View Rep
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
'create or activate view rep in subassemblies
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments
Dim subDoc As AssemblyComponentDefinition
If docFile.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
subDoc = docFile.ComponentDefinition
Try
subDoc.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate
Catch
'create new View Rep
subDoc.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
Else
End If
Next
'toggle work planes in the open document (top level assembly)
For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next
'look at only the subassemblies
Dim subDocFile As Document
For each oCompOcc in oAsmCompDef.Occurrences
If oCompOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oCompOcc.SetDesignViewRepresentation(sVRep,, True) 'True sets the view rep to be associative
Else
End If
Next
'Look at all of the files referenced in the open document
For Each docFile In openDoc.AllReferencedDocuments
'format file name
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)
Dim docFName As String
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos)
For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next
Next
iLogicVb.UpdateWhenDone = True

 

Hi  pistonrod8,

 

Here is a modified version that handles all work features.

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'get user input
oInput = InputRadioBox("Select work feature visibility:", _
 "Turn ON work features for all components", _
 "Turn OFF work features for all components", "False", "iLogic")

' set a reference to the assembly component definintion.
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

'Define the open document (top level assembly)
Dim openDoc As Document
openDoc = ThisDoc.Document
'define view rep
Dim oViewRep As DesignViewRepresentation
Dim sVRep as String
'change to something else if Default is used for something already
sVRep = "Default"

'create or activate view rep in the top level assembly
Try     
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate    
Catch
'create new View Rep
oAsmCompDef.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try

'create or activate view rep in subassemblies
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
Dim subDoc As AssemblyComponentDefinition
If docFile.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
subDoc = docFile.ComponentDefinition
Try     
subDoc.RepresentationsManager.DesignViewRepresentations.Item(sVRep).Activate    
Catch
'create new View Rep
subDoc.RepresentationsManager.DesignViewRepresentations.Add(sVRep)
End Try
Else
End If
Next

    'toggle work features in the open document (top level assembly)
    For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
    If oInput = True Then
    oWorkPlane.Visible = True
    ElseIf oInput = False Then
    oWorkPlane.Visible = False
    End If
    Next

    For Each oWorkAxis In openDoc.ComponentDefinition.WorkAxes
    If oInput = True Then
    oWorkAxis.Visible = True
    ElseIf oInput = False Then
    oWorkAxis.Visible = False
    End If
    Next

    For Each oWorkPoint In openDoc.ComponentDefinition.WorkPoints
    If oInput = True Then
    oWorkPoint.Visible = True
    ElseIf oInput = False Then
    oWorkPoint.Visible = False
    End If
    Next

'look at only the subassemblies
Dim subDocFile As Document
For each oCompOcc in oAsmCompDef.Occurrences
If oCompOcc.DefinitionDocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then
oCompOcc.SetDesignViewRepresentation(sVRep,, True) 'True sets the view rep to be associative
Else
End If
Next


'Look at all of the files referenced in the open document
For Each docFile In openDoc.AllReferencedDocuments                

    'toggle work features in the components
    For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
    If oInput = True Then
    oWorkPlane.Visible = True
    ElseIf oInput = False Then
    oWorkPlane.Visible = False
    End If
    Next

    For Each oWorkAxis In docFile.ComponentDefinition.WorkAxes
    If oInput = True Then
    oWorkAxis.Visible = True
    ElseIf oInput = False Then
    oWorkAxis.Visible = False
    End If
    Next

    For Each oWorkPoint In docFile.ComponentDefinition.WorkPoints
    If oInput = True Then
    oWorkPoint.Visible = True
    ElseIf oInput = False Then
    oWorkPoint.Visible = False
    End If
    Next
Next
iLogicVb.UpdateWhenDone = True


 

Distinguished Mentor
swordmaster
Posts: 540
Registered: ‎12-15-2008
Message 2 of 28 (1,531 Views)

Re: ilogic and work plane visibility

03-23-2012 11:44 AM in reply to: rjones0215

This will turn the visibility of Work Plane1 off

 

Dim

oDoc As PartDocument

oDoc

= ThisDoc.Document

 

For Each

oWorkPlane In oDoc.ComponentDefinition.WorkPlanes

 

If oWorkPlane.Name = "Work Plane1" Then

'

oWorkPlane.Visible = False

'

End If

Next

 

 

 

Inventor 2010 Certified Professional
*Expert Elite*
Curtis_Waguespack
Posts: 2,955
Registered: ‎03-08-2006
Message 3 of 28 (1,516 Views)

Re: ilogic and work plane visibility

03-23-2012 01:23 PM in reply to: rjones0215

Hi rjones0215, 

 

Here's another rule that toggles all of the workplanes on/off.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

'define document
Dim oDoc As PartDocument
oDoc = ThisDoc.Document
'look at the workplane collection
For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
'toggle all work planes
If oWorkPlane.Visible = True Then
oWorkPlane.Visible = False
ElseIf oWorkPlane.Visible = False Then
oWorkPlane.Visible = True
End If
Next

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Distinguished Mentor
swordmaster
Posts: 540
Registered: ‎12-15-2008
Message 4 of 28 (1,511 Views)

Re: ilogic and work plane visibility

03-23-2012 01:51 PM in reply to: Curtis_Waguespack

Nice rule Curtis

Inventor 2010 Certified Professional
Active Member
rjones0215
Posts: 9
Registered: ‎10-01-2011
Message 5 of 28 (1,492 Views)

Re: ilogic and work plane visibility

03-26-2012 05:17 AM in reply to: rjones0215

thank you.  These definitely help.

Inventor 2013 Certified Professional
Active Member
david.campbell
Posts: 10
Registered: ‎08-22-2012
Message 6 of 28 (1,385 Views)

Re: ilogic and work plane visibility

09-24-2012 09:43 AM in reply to: Curtis_Waguespack

How can I make this work so that from an assembly plane visibility is changed to false in all sub assemblies and and parts.

 

Thanks

Inventor 2013
*Expert Elite*
Curtis_Waguespack
Posts: 2,955
Registered: ‎03-08-2006
Message 7 of 28 (1,373 Views)

Re: ilogic and work plane visibility

09-24-2012 10:35 AM in reply to: david.campbell

Hi Diswill,

 

Here are 2 quick rules that should give you an idea of how to do this. I didn't take a lot of time to test this, so be warned that you might bump into issues with locked design view reps, etc. But this should get you pointed in the right direction I think.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

sample rule #1

'get user input
oInput = InputRadioBox("Select workplane visibility:", _
 "Turn ON workplanes for all components", "Turn OFF workplanes for all components", "True", "iLogic")

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
'format  file name                   
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
Dim docFName As String 
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next
Next

iLogicVb.UpdateWhenDone = True

 

 

 

sample rule #2

'toggle work planes on, if off & off if on
'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
'format  file name                   
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
Dim docFName As String 
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
'toggle all work planes
If oWorkPlane.Visible = True Then
oWorkPlane.Visible = False
ElseIf oWorkPlane.Visible = False Then
oWorkPlane.Visible = True
End If
Next
Next

iLogicVb.UpdateWhenDone = True

 

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
david.campbell
Posts: 10
Registered: ‎08-22-2012
Message 8 of 28 (1,359 Views)

Re: ilogic and work plane visibility

09-24-2012 11:01 AM in reply to: Curtis_Waguespack

working with your sample 1

 

user defined planes are not switching.

 

if I make a offset plane from orgin plane xy when I run sample 1 the plane I created is unaffected by this rule.

 

 

 

Inventor 2013
*Expert Elite*
Curtis_Waguespack
Posts: 2,955
Registered: ‎03-08-2006
Message 9 of 28 (1,352 Views)

Re: ilogic and work plane visibility

09-24-2012 11:25 AM in reply to: david.campbell

Hi Diswill,

Sample#1 should have worked for your original request  "plane visibility is changed to false in all sub assemblies and and parts.", but if you have user workplanes at the top level assembly as well, then you might need to add a few lines to look at the workplane collection in the top level assembly,  as in example #3 below.

 

Again the issue could be with locked design view representations as well. It's difficult to guess without more details, but hopefully this example will help you work it out.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 sample rule #3

'get user input
oInput = InputRadioBox("Select workplane visibility:", _
 "Turn ON workplanes for all components", "Turn OFF workplanes for all components", "True", "iLogic")

'Define the open document
Dim openDoc As Document
openDoc = ThisDoc.Document

'toggle work planes in the open document (top level assembly)
For Each oWorkPlane In openDoc.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next

'Look at all of the files referenced in the open document
Dim docFile As Document
For Each docFile In openDoc.AllReferencedDocuments                
'format  file name                   
Dim FNamePos As Long
FNamePos = InStrRev(docFile.FullFileName, "\", -1)                        
Dim docFName As String 
docFName = Right(docFile.FullFileName, Len(docFile.FullFileName) - FNamePos) 
For Each oWorkPlane In docFile.ComponentDefinition.WorkPlanes
'toggle all work planes
If oInput = True Then
oWorkPlane.Visible = True
ElseIf oInput = False Then
oWorkPlane.Visible = False
End If
Next
Next

iLogicVb.UpdateWhenDone = True

 



  solution.png  Did you find this reply helpful ? If so please use the Accept as Solution or  Kudos button below.





Active Member
david.campbell
Posts: 10
Registered: ‎08-22-2012
Message 10 of 28 (1,343 Views)

Re: ilogic and work plane visibility

09-24-2012 12:04 PM in reply to: Curtis_Waguespack

Please let me claifiry

 the current code I have is

 

 

'get user input
oInput=InputRadioBox("Select workplane visibility:", _
"Turn ON workplanes for all components", "Turn OFF workplanes for all components", "True", "iLogic")
'catches planes in current assembly
IfoInput=FalseThen
'define document
DimoDocAsAssemblyDocumentoDoc=ThisDoc.Document
'look at the workplane collection
For EachoWorkPlaneInoDoc.ComponentDefinition.WorkPlanes
'toggle all work planes off
IfoWorkPlane.Visible=TrueThenoWorkPlane.Visible=False
End If
Next
ElseIfoinput=TrueThen
'define document
DimoDocAsAssemblyDocumentoDoc=ThisDoc.Document
'look at the workplane collection
For EachoWorkPlaneInoDoc.ComponentDefinition.WorkPlanes
'toggle all work planes on
IfoWorkPlane.Visible=FalseThenoWorkPlane.Visible=True
End If
Next
End If
'catches some planes in subassemblies
'Define the open document
DimopenDocAsAssemblyDocumentopenDoc=ThisDoc.Document
'Look at all of the files referenced in the open document
DimdocFileAsDocumentForEachdocFileInopenDoc.AllReferencedDocuments
'format file name
DimFNamePosAsLong
FNamePos=InStrRev(docFile.FullFileName, "\", -1)
DimdocFNameAsString
docFName=Right(docFile.FullFileName, Len(docFile.FullFileName)-FNamePos)For EachoWorkPlaneIndocFile.ComponentDefinition.WorkPlanes
'toggle all work planes
IfoInput=TrueThenoWorkPlane.Visible=True
ElseIfoInput=FalseThen
oWorkPlane.Visible=False
End If
Next
Next
iLogicVb.UpdateWhenDone=True

browser.png

 

However when I open Assembly 2 the plane appears to be toggling correctly. It just appears not to reflect correctly up to assembly1.

 

How do I fix?

 

Thanks in Advance

Inventor 2013
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.