[iLogic / VBA ] Toggle on/off features in Assembly context

[iLogic / VBA ] Toggle on/off features in Assembly context

Luisfmts
Enthusiast Enthusiast
600 Views
1 Reply
Message 1 of 2

[iLogic / VBA ] Toggle on/off features in Assembly context

Luisfmts
Enthusiast
Enthusiast

Hi guys,

There are a lot of codes for toggling on/off work features around. Particulary i like the second one from this page:

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

 

Althouth it doesn't do the job for workfeatures on assembly context. (image attached)

 

 

Does anybody knows how to include a loop for this kind of feature?

 

 

0 Likes
Accepted solutions (1)
601 Views
1 Reply
Reply (1)
Message 2 of 2

Sergio.D.Suárez
Mentor
Mentor
Accepted solution

Hi, What happens is that the workplane you have created is not within the reference files, that is to say of its components, the workplane is within your active assembly. That's why I added the same lines in the code and changed the access to the document (in red)
Try the following ilogic code

 

On Error Resume Next
'define the active assembly
Dim oAssyDoc As AssemblyDocument
oAssyDoc = ThisApplication.ActiveDocument

'get user input as True or False
wfBoolean = InputRadioBox("Turn all Work Features On/Off", "On", "Off", False, "iLogic")


'Check all referenced docs 
Dim oDoc As Inventor.Document
For Each oDoc In oAssyDoc.AllReferencedDocuments
    'set work plane visibility
    For Each oWorkPlane In oDoc.ComponentDefinition.WorkPlanes
    oWorkPlane.Visible = wfBoolean
    Next
    'set work axis visibility
    For Each oWorkAxis In oDoc.ComponentDefinition.WorkAxes
    oWorkAxis.Visible = wfBoolean
    Next
    'set work point visibility
    For Each oWorkPoint In oDoc.ComponentDefinition.WorkPoints
    oWorkPoint.Visible = wfBoolean
    Next    
    'set sketch visibility
    For Each oSketch In oDoc.ComponentDefinition.Sketches
    oSketch.Visible = wfBoolean
    Next
Next


For Each oWorkPlane In  oAssyDoc.ComponentDefinition.WorkPlanes
oWorkPlane.Visible = wfBoolean
Next
'set work axis visibility
For Each oWorkAxis In  oAssyDoc.ComponentDefinition.WorkAxes
oWorkAxis.Visible = wfBoolean
Next
'set work point visibility
For Each oWorkPoint In  oAssyDoc.ComponentDefinition.WorkPoints
oWorkPoint.Visible = wfBoolean
Next    
'set sketch visibility
For Each oSketch In  oAssyDoc.ComponentDefinition.Sketches
oSketch.Visible = wfBoolean
Next

'update the files
InventorVb.DocumentUpdate()

 I hope it is useful for you. 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

0 Likes