ON/Off Origin planes

ON/Off Origin planes

Anonymous
Not applicable
3,991 Views
13 Replies
Message 1 of 14

ON/Off Origin planes

Anonymous
Not applicable

For constraining parts in an assembly I use a lot the origin planes of the parts. When switching on/off the visibility of the origin planes in the assembly (object visibility).

 

Knipsel4.JPG

 

I only see the origin planes of the parts which have switch on  the visibility of the origin planes in the party itself. Unfortyunally, some are set to visilble other are not...

 

Knipsel.JPG

 

Is there a way to switch on/off all the origin planes of the parts themselves, so I can easely switch on/off their visibility on the assembly with ?

 

0 Likes
Accepted solutions (2)
3,992 Views
13 Replies
Replies (13)
Message 2 of 14

bradeneuropeArthur
Mentor
Mentor

Hi,

 

The only way to do that is to manually set the workplanes visible in the parts.

The method "object visibility" only works for the visible features in the models themselves. The visibility is handled in the assembly and not in the part. This means the "object visibility"  only works if you change the part.

If you need that you need to loop through the assembly occurences and set the workplanes visible or invisible.

 

Do you need that?

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 14

johan.degreef
Advisor
Advisor

yes

Inventor 2025, Vault Professional 2025, Autocad Plant 3D 2025
0 Likes
Message 4 of 14

bradeneuropeArthur
Mentor
Mentor

what features need to be set visible?

only origin workplanes?

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 5 of 14

Anonymous
Not applicable

Yes, switching on/off only the origin workplanes of all underlying parts and subassemblies by running the rule, if possible..

0 Likes
Message 6 of 14

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Public Sub main()
Dim a As Application
Set a = ThisApplication

Dim b As AssemblyDocument
Set b = a.ActiveDocument

Dim c As AssemblyComponentDefinition
Set c = b.ComponentDefinition

Dim occ As ComponentOccurrence

For Each occ In c.Occurrences
Dim d As Document
Set d = occ.Definition.Document

'MsgBox d.ComponentDefinition.WorkPlanes.Item("XY Plane").Name
d.ComponentDefinition.WorkPlanes.Item("YZ Plane").Visible = True
d.ComponentDefinition.WorkPlanes.Item("XZ Plane").Visible = True
d.ComponentDefinition.WorkPlanes.Item("XY Plane").Visible = True
'occ.Definition.Document
Next
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

Message 7 of 14

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

If it has a very large assembly and activates the visibility of all the main planes of origin, it can be complicated to work on the components because many planes will appear activated. With this external ilogic rule, you will select the components in which you need to activate / deactivate the planes, with the escape key you will exit the loop.

 

Dim comps As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection

While True
Dim comp As Object = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a component") 
If IsNothing(comp) Then Exit While
comps.Add(comp) 
End While

For Each comp In comps
	Dim WP As WorkPlane = comp.definition.document.ComponentDefinition.WorkPlanes.Item(1)
	Dim oValue As Boolean
	If WP.Visible = True Then oValue = False Else oValue = True
	
	For i As Integer = 1 To 3
		comp.definition.document.ComponentDefinition.WorkPlanes.Item(i).Visible = oValue
	Next
	iLogicVb.UpdateWhenDone = True
Next

 I hope it will be useful. regards


Please accept as solution and give likes if applicable.

I am attaching my Upwork profile for specific queries.

Sergio Daniel Suarez
Mechanical Designer

| Upwork Profile | LinkedIn

Message 8 of 14

Anonymous
Not applicable

It is a good idea, this is a great piece of code!

0 Likes
Message 9 of 14

j_weber
Mentor
Mentor

Great code.

 

Perheps you can put the ESC Command in the Kontextmenu when the code works




Jörg Weber
CAD Systemtechniker für AutoCAD, Inventor, Vault





0 Likes
Message 10 of 14

JBerns
Advisor
Advisor

@Sergio.D.Suárez,

 

Your code will be very helpful!

 

One question: instead of pressing ESC to exit the loop, could the code be changed to loop until ENTER is pressed?

 

Our designers come from an AutoCAD background, so ESC usually cancels a command without changing anything, while ENTER ends the command and accepts all input. I have searched the forums and other sites, but have only found code for using the ESC key.

 

Thanks for your time. I look forward to the replies.

 

 

Regards,

Jerry 

-----------------------------------------------------------------------------------------
CAD Administrator
Using AutoCAD & Inventor 2025
Autodesk Certified Instructor
Autodesk Inventor 2020 Certified Professional
Autodesk AutoCAD 2017 Certified Professional
0 Likes
Message 11 of 14

m_send
Community Visitor
Community Visitor

Dear Sergio.D.Suárez

 

Tanks for this nice Code. It's very helpful.

Unfortunately i get an error when i try using it on content center files/ custom content center files like elbow fitting.

Do you have maybe an idea whaht's the problem?

 

System.Runtime.InteropServices.COMException (0x80004005): Unbekannter Fehler (Ausnahme von HRESULT: 0x80004005 (E_FAIL))
bei Microsoft.VisualBasic.CompilerServices.LateBinding.InternalLateSet(Object o, Type& objType, String name, Object[] args, String[] paramnames, Boolean OptimisticSet, CallType UseCallType)
bei Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase, CallType CallType)
bei Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateSetComplex(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean OptimisticSet, Boolean RValueBase)
bei ThisRule.Main() in Externe Regel: Ursprungsebenen anzeigen:Zeile 22.
bei Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)
bei iLogic.RuleEvalContainer.ExecRuleEval(String execRule)


Best Regards

 

Michael

 
 
 
0 Likes
Message 12 of 14

WCrihfield
Mentor
Mentor

Hi @m_send.  It is most likely encountering the errors because content center files are ReadOnly.  There are a few ways around this issue.  One way to avoid those potential errors is to enclose the lines of code that are trying to make changes to change the visibility of the WorkPlanes within the Try side of a Try...Catch statement.  When you do that, if it fails, it will not throw an error that will stop the rule.  Instead it will simply continue on to whatever is next in the code.  You can also place some code within the Catch side of that statement that will try to do something when the code in the Try side fails.  This is often used as a debug tool by including some feedback on the Catch side, like a message or an iLogic Log entry with the Logger.Error() snippet.  Another way to avoid those errors is to filter out any components that represent content center parts.  That way they do not get processed.  Checking if a component represents a content center part is not the simplest process, because the ComponentOccurrence object does not have a direct property for that.  Only the PartComponentDefinition has a property for that (PartComponentDefinition.IsContentMember).  The ComponentOccurrence.Definition property returns its ComponentDefinition, but you can only access that if the component is not currently suppressed.  If you try to access that while it is suppressed, it will throw an error.  Once you have the ComponentDefinition, you must first make sure it is specifically a PartComponentDefinition (as sub type), and not an AssemblyComponentDefinition (or one of the other sub types).  Then you can check that property's value.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 13 of 14

m_send
Community Visitor
Community Visitor

Thank you very much for your reply!

 

Unfortunately i am not good in programming and only use some iLogic rues i find to improve my work performance...

I would like to add this Try....Catch Statement but i dont know in which line and what it should include to solve this problem. I would be very happy if you could help me..

 

It find always a fault in rule line 15 and says for conent center files:

 

(Ausnahme von HRESULT: 0x80004005 (E_FAIL))

 

here Ausnahme = Exception

 

Thanks in advance

 

 

0 Likes
Message 14 of 14

WCrihfield
Mentor
Mentor

Hi @m_send.  Here is a very similar example you can try, in which it incorporates a couple of those Try...Catch statements to help avoid potential errors.  In this example, instead of using an ObjectCollection and a 'While' loop, it is using the old 'GoTo' keyword.  But in both examples, you can just use your 'Esc' keyboard key when it asks you to select a component, which will let the code resume without anything being selected, and when nothing has been selected, that will cause it to exit the loop.  It is using a Try...Catch statement where it attempts to access the WorkPlanes collection of the component, because accessing the 'Definition' property of a component that is currently suppressed will throw an error.  You may never select a suppressed component, but if you do, it will avoid that error, and just exit the routine.  Then this example, the line of code that attempts to change the visibility of a WorkPlane is enclosed within a Try...Catch statement, to avoid that potential error, because that will fail if the document the component references is ReadOnly, like content center files and such.  The 'GoTo' term just tells the rule to go to where the following term is found, which in this case is just before the line of code for picking another component.  You could also ask the user a simple question at that point, like "Go again?", and then only loop again if they answer Yes.  I have used that technique many times before to avoid endless loops in basic code routines.  It just involves an extra mouse click each time to continue.

Dim oOcc As ComponentOccurrence, oWPlanes As WorkPlanes, oWPlane As WorkPlane
Dim sPrompt As String = "Select a component." & vbCrLf & "Or tap ESC key to exit loop."
PickAgain :
oOcc = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, sPrompt)
If oOcc Is Nothing Then Return
Try 'this will fail if the component is suppressed, also maybe if it is a virtual component
	oWPlanes = oOcc.Definition.WorkPlanes
Catch
	Return 'exit this routine, because it could not access the WorkPlanes
End Try
For Each oWPlane In oWPlanes
	If oWPlane.IsCoordinateSystemElement Then
		If oWPlane.Visible = True Then
			Try 'this will fail if the referenced document is ReadOnly (content center, library, etc)
				oWPlane.Visible = False
			Catch
				'what to do if it fails here
			End Try
		End If
	End If
Next
'If MsgBox("Pick again?", vbYesNo+vbQuestion, "Again?") = vbNo Then Return
GoTo PickAgain 'go to where this term is found

Wesley Crihfield

EESignature

(Not an Autodesk Employee)