Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Struggling to understand iLogic

2 REPLIES 2
Reply
Message 1 of 3
CJ.10E-10mm
385 Views, 2 Replies

Struggling to understand iLogic

This is part of a Rule provided by another user to switch the Visibilty of Workplanes:

'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


How should I address other Workfeatures in a similar vein including Axis, Points and Surfaces and not just WorkPlanes?

 

For under Work Features in System Snippets only two simple options are provided which do not satisfy my requirements.



Applying 'simple logic' I attempted to use the following to address Work Axis to no avail:


For Each oWorkAxis In openDoc.ComponentDefinition.WorkAxis

And received this error:

Public member 'WorkAxis' on type 'AssemblyComponentDefinition' not found.

Thanks.

CJ

2 REPLIES 2
Message 2 of 3
MegaJerk
in reply to: CJ.10E-10mm

It would seem to me that I am unable to turn the workplane visibility (on the assembly level) on or off by setting a work plane’s property of Visible to False. Instead I had to use the Object Visibility (Found commonly on the View tab of Inventor) to change the setting for User Work Plane visibility from there. 

Here is my code.

If ThisApplication.ActiveDocument.DocumentType <> Inventor.DocumentTypeEnum.kAssemblyDocumentObject Then
    MessageBox.Show("Please run this from an Assembly!", "Bad Level Error")
    Return
End If

'Assuming that you have a TRUE / FALSE parameter
'(Named - myTrueFalseParameter) 
'that is inside of your assembly, you will be
'able to use that as the 'switch' that determines
'the visibility state (ON / OFF) of the workplanes
'on the Assembly level using the below line of code.

ThisApplication.ActiveDocument.ObjectVisibility.UserWorkPlanes = myTrueFalseParameter
ThisApplication.ActiveDocument.ObjectVisibility.UserWorkAxes = myTrueFalseParameter
ThisApplication.ActiveDocument.ObjectVisibility.UserWorkPoints = myTrueFalseParameter

 

 

Remember to set up your true / false parameter inside of your assembly document if you want this to work.

You should probably also read the following post over on Inventor Trenches (wonderful blog)

http://inventortrenches.blogspot.com/2013/03/turn-onoff-all-workfeatures-with-ilogic.html



If my solution worked or helped you out, please don't forget to hit the kudos button 🙂
iLogicCode Injector: goo.gl/uTT1IB

GitHub
Message 3 of 3
CJ.10E-10mm
in reply to: MegaJerk

Hi MegaJerk,

 

Thank you so much, I will check your solution and suggested link out tonight and get back to you.

 

In the meantime thank you for your kind assistance.

 

CJ

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report