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?
Solved! Go to Solution.
Solved by caroline_ccc. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
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 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
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
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
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.
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
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
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
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
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
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.
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
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
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
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.
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!
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
Can't find what you're looking for? Ask the community or share your knowledge.