Inventor General Discussion

Inventor General Discussion

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

Re: ilogic and work plane visibility

09-24-2012 12:18 PM in reply to: david.campbell

Your sample #3 seams to produce the same results I am having with the code I am currently using.

I am going to use your sample #3 for further discussions so that we are on the same page.

 

Thanks again

 

Inventor 2013
*Expert Elite*
Curtis_Waguespack
Posts: 3,000
Registered: ‎03-08-2006
Message 12 of 28 (1,075 Views)

Re: ilogic and work plane visibility

09-24-2012 12:49 PM in reply to: david.campbell

Hi Diswill,

 

I think what you're seeing is an issue with view reps in the sub assembly.  Basically, we'll need to have a few lines of code check the component to see if it's an assembly file, and then use or create a view rep in the sub assembly.

 

To test this theory you can create a view rep in your sub assembly and ensure that your sub assembly is placed using that view rep, and then I think you'll see that the rule works as expected.

 

I'll post back if I have time to look into the needed code update later.

 

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

 



  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 13 of 28 (1,069 Views)

Re: ilogic and work plane visibility

09-24-2012 01:17 PM in reply to: Curtis_Waguespack

your assumption about the view representation appears to be correct.

for us assemblies are normally places with the master view representation.

 

Your assistance is greatly appreciated.

 

 

Inventor 2013
*Expert Elite*
Curtis_Waguespack
Posts: 3,000
Registered: ‎03-08-2006
Message 14 of 28 (1,062 Views)

Re: ilogic and work plane visibility

09-24-2012 01:46 PM in reply to: david.campbell

Hi Diswill,

 

Let's back up a step or two.

 

Are you wanting to use iLogic to :

A) turn off the visibility of work planes at the top level assembly?

B) reach down into each component and turn off the visibility of the work planes

 

If A, then I think this one line will do the trick:

 

ThisApplication.CommandManager.ControlDefinitions.Item("AppAllWorkfeaturesCmd").Execute

 This is the same as going to the VIew tab > Object Visibility button > All Work Features check box.

 

 

But if you're needing B, then we were on the right track earlier, and we'll need to add some lines to look at the sub assembly view reps.

 

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



  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 15 of 28 (1,059 Views)

Re: ilogic and work plane visibility

09-24-2012 02:09 PM in reply to: Curtis_Waguespack

We are looking at option B

 

Using the Object Visibility under the view tab is not what we want.

 

We want clean assemblies with no plane visibility being active on any part or assembly / subassembly at any level as a starting point for the next group to start working with.

 

The group work in works mainly with planes and it becomes a pain to go to each part and turn off each plane then move to each subassembly and turn off each plane. Then so on up to the main assembly.

 

When the next group grabs our main assemblies in uses them in the larger project a few planes being left on by accident becomes a problem.

 

Thanks

 

 

Inventor 2013
*Expert Elite*
Curtis_Waguespack
Posts: 3,000
Registered: ‎03-08-2006
Message 16 of 28 (1,049 Views)

Re: ilogic and work plane visibility

09-24-2012 03:30 PM in reply to: david.campbell

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

 



  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 17 of 28 (1,030 Views)

Re: ilogic and work plane visibility

09-25-2012 05:47 AM in reply to: Curtis_Waguespack

This sample seams to catch most of our problems.

Yes we can bury assemblies several layers deep but not so deep that it will require to add to this code.

I really appreciate you and your help.

 

Thanks again.

 

 

Inventor 2013
Contributor
pistonrod8
Posts: 15
Registered: ‎11-09-2004
Message 18 of 28 (944 Views)

Re: ilogic and work plane visibility

01-15-2013 08:36 AM in reply to: Curtis_Waguespack

This is exactly what I was looking for.

 

Would it be too much to ask to supplement the code to also turn off the work axes and work points? Basically I want all the work features to turn off.

 

Thank you!

*Expert Elite*
Curtis_Waguespack
Posts: 3,000
Registered: ‎03-08-2006
Message 19 of 28 (933 Views)

Re: ilogic and work plane visibility

01-15-2013 11:11 AM in reply to: pistonrod8

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


 



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





Contributor
pistonrod8
Posts: 15
Registered: ‎11-09-2004
Message 20 of 28 (922 Views)

Re: ilogic and work plane visibility

01-15-2013 11:23 AM in reply to: Curtis_Waguespack

That works great. Thank you!

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.