Unable to Change Visibility of Workplane Proxies in 2018

Unable to Change Visibility of Workplane Proxies in 2018

MechMachineMan
Advisor Advisor
762 Views
7 Replies
Message 1 of 8

Unable to Change Visibility of Workplane Proxies in 2018

MechMachineMan
Advisor
Advisor

In order to make constraining easier, I have a macro which turns the visibility of work planes of components in an assembly on. With the 2018 modification to removing the ability to change library parts through API, it broke this functionality. 

 

I've discovered I can do the same thing for the parts in the assembly by simply right clicking the workplanes in the browser and changing that items visibility. My research has pointed me to these being WorkPlane Proxies, and these workplane proxies are accessible through the API.

 

HOWEVER, I THINK the 2018 change may have inadvertently locked up these WorkPlane Proxies although they are still modifiable through the UI.

 

The code I am currently using is as below:

 

If someone can confirm this issue, I would be grateful. Thanks!

 

Sub ToggleOccWP(oDoc As Document, oObj As Variant)
    
    Dim oAssyCompDef As AssemblyComponentDefinition
    Set oAssyCompDef = oDoc.ComponentDefinition
    
    Set oOccurrences = oAssyCompDef.Occurrences.AllReferencedOccurrences(oObj)
    
    Dim oOccurrence As ComponentOccurrence
    Dim oSubAssyCompDef As ComponentDefinition
    
    For Each oOccurrence In oOccurrences
        Set oSubAssyCompDef = oOccurrence.Definition
    
        Dim oPlaneProxy As WorkPlaneProxy
        For Each oPlane In oSubAssyCompDef.WorkPlanes
            Call oOccurrence.CreateGeometryProxy(oPlane, oPlaneProxy)
            oPlaneProxy.Visible = True
        Next
        
        Dim oAxisProxy As WorkAxisProxy
        For Each oAxis In oSubAssyCompDef.WorkAxes
            Call oOccurrence.CreateGeometryProxy(oAxis, oAxisProxy)
            oAxisProxy.Visible = True
        Next
        
        Dim oWPoProxy As WorkPointProxy
        Call oOccurrence.CreateGeometryProxy(oSubAssyCompDef.WorkPoints(1), oWPoProxy)
        oWPoProxy.Visible = True
    Next
End Sub

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
763 Views
7 Replies
Replies (7)
Message 2 of 8

MechMachineMan
Advisor
Advisor

@chandra.shekar.g could you please take a look at this and confirm this as an issue to be logged?

 

Implementation code for testing it is attached.

 

Make sure to try it out in a file that has both a library part and a non-library part, and watch how it works on the one, but not the other.

 

Sub ToggleWorkPlanes()

    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    
    If oDoc Is Nothing Then
        Exit Sub
    End If
     
    Select Case True
        Case Not oDoc.ActivatedObject Is Nothing
            If oDoc.ActivatedObject.Type = ObjectTypeEnum.kDocumentObject Then
                Set oDoc = oDoc.ActivatedObject
            Else
                MsgBox ("Invalid active object")
                Exit Sub
            End If
        Case oDoc.ActivatedObject Is Nothing
            'Continue without revising anything
        Case Else
            MsgBox ("Invalid Activated Object!")
    End Select
    
    Dim oSS As SelectSet
    Set oSS = oDoc.SelectSet
    
    Dim oItems As ObjectsEnumerator
    Set oItems = ThisApplication.TransientObjects.CreateObjectCollection
    For Each oObj In oSS
        oItems.Add oObj
    Next
    
'On Error Resume Next

    Select Case True
        Case oSS.Count = 0
        Case oSS.Count = 1
            If oSS.Item(1).Type = ObjectTypeEnum.kDocumentObject Then
            ElseIf oSS.Item(1).Type = ObjectTypeEnum.kComponentOccurrenceObject Or oSS.Item(1).Type = ObjectTypeEnum.kComponentOccurrenceProxyObject Then
                    Call ToggleOccWP(oDoc, oSS.Item(1).Definition.Document)
            Else
                MsgBox ("Invalid selected object!")
            End If
        Case Else
            MsgBox ("Invalid Select Set!")
    End Select
    
    Exit Sub
    
End Sub

 

Thanks!


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 3 of 8

JaneFan
Autodesk
Autodesk

Hi Justin,

 

Thank you for the report. I can reproduce and confirm the issue that it will be tracked in our internal system.




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 4 of 8

MjDeck
Autodesk
Autodesk

Even in the UI, you can't change the visibility of the predefined work features in the Origin folder (XY plane etc.) in a library part. Do you need to do that, or would it be sufficient to affect only the added work features? If that's good enough, you can use code like the following to skip over the Origin features:

	Dim oPlane As WorkPlane
        Dim oPlaneProxy As WorkPlaneProxy
        For i = 4 To oSubAssyCompDef.WorkPlanes.Count
            Set oPlane = oSubAssyCompDef.WorkPlanes(i)
            Call oOccurrence.CreateGeometryProxy(oPlane, oPlaneProxy)
            oPlaneProxy.Visible = True
        Next
        
        Dim oAxis As WorkAxis
        Dim oAxisProxy As WorkAxisProxy
        For i = 4 To oSubAssyCompDef.WorkAxes.Count
            Set oAxis = oSubAssyCompDef.WorkAxes(i)
            Call oOccurrence.CreateGeometryProxy(oAxis, oAxisProxy)
            oAxisProxy.Visible = True
        Next
        
        Dim oWPo As WorkPoint
        Dim oWPoProxy As WorkPointProxy
        For i = 2 To oSubAssyCompDef.WorkPoints.Count
            Set oWPo = oSubAssyCompDef.WorkPoints(i)
            Call oOccurrence.CreateGeometryProxy(oWPo, oWPoProxy)
            oWPoProxy.Visible = True
        Next

Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 5 of 8

MechMachineMan
Advisor
Advisor

Hmm weird. It is definitely does expose Workplanes through the UI for library parts in my assemblies, and in the feedback report I sent in, they said they are seeing the same results.

 

As per the BORN modelling technique that I have found advocated by Autodesk, it makes the most sense to have this functionality work on all workplanes, or any workplane that was used for the born technique of modelling for use in assemblies. Makes sense too, in order to capture design intent. What good is using the BORN technique in parts if you neglect to use the same ideology in assembly modelling?


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 6 of 8

MjDeck
Autodesk
Autodesk

Ok, now I have a better picture. You specifically want to show the origin work features. Are you sure you can do that through the UI for a library part in 2018?


Mike Deck
Software Developer
Autodesk, Inc.

0 Likes
Message 7 of 8

MechMachineMan
Advisor
Advisor

Certain. I have done it multiple times, and it's my current method of doing such. I'm currently trying to code/test a workaround that will grab the browser node and use the control definition to change the visibility of the node to see if this can feasibly simulate the results I'm looking for. Still no proper access to the object through the API though!


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 8 of 8

MechMachineMan
Advisor
Advisor

As suspected, I can replicate the UI functionality by using the commands. See this code:

 

Sub ToggleOccWP(odoc As Document, oObj As Variant)
    
    Dim oAssyCompDef As AssemblyComponentDefinition
    Set oAssyCompDef = odoc.ComponentDefinition
    
    Set oOccurrences = oAssyCompDef.Occurrences.AllReferencedOccurrences(oObj)
    
    Dim oOccurrence As ComponentOccurrence
    Dim oSubAssyCompDef As ComponentDefinition
    
    Dim oVisibleBool As Boolean
    
    Dim oCommandMgr As CommandManager
    Set oCommandMgr = ThisApplication.CommandManager
    Dim oControlDef1 As ControlDefinition
    
    
    Set oOccurrence = oOccurrences.Item(1)
    'For Each oOccurrence In oOccurrences
        Set oSubAssyCompDef = oOccurrence.Definition
        
        Dim oWPoProxy As WorkPointProxy
        Call oOccurrence.CreateGeometryProxy(oSubAssyCompDef.WorkPoints(1), oWPoProxy)
        If oWPoProxy.Visible Then
            oVisibleBool = False
        Else
            oVisibleBool = True
        End If
            
        Set oBN = odoc.BrowserPanes("Model").GetBrowserNodeFromObject(oSubAssyCompDef.WorkPoints(1))
        
        oBN.EnsureVisible
        oBN.DoSelect
        
        Set oControlDef1 = oCommandMgr.ControlDefinitions.Item("AssemblyVisibilityCtxCmd")
        oControlDef1.Execute
    
        'oWPoProxy.Visible = oVisibleBool
        
        Dim oPlaneProxy As WorkPlaneProxy
        For Each oPlane In oSubAssyCompDef.WorkPlanes
            Set oBN = odoc.BrowserPanes("Model").GetBrowserNodeFromObject(oPlane)
            
            oBN.EnsureVisible
            oBN.DoSelect
        
            Set oControlDef1 = oCommandMgr.ControlDefinitions.Item("AssemblyVisibilityCtxCmd")
            oControlDef1.Execute
            'Call oOccurrence.CreateGeometryProxy(oPlane, oPlaneProxy)
            'oPlaneProxy.Visible = oVisibleBool
        Next
        
        Dim oAxisProxy As WorkAxisProxy
        For Each oAxis In oSubAssyCompDef.WorkAxes
            Set oBN = odoc.BrowserPanes("Model").GetBrowserNodeFromObject(oAxis)
            
            oBN.EnsureVisible
            oBN.DoSelect
        
            Set oControlDef1 = oCommandMgr.ControlDefinitions.Item("AssemblyVisibilityCtxCmd")
            oControlDef1.Execute
            'Call oOccurrence.CreateGeometryProxy(oAxis, oAxisProxy)
            'oAxisProxy.Visible = oVisibleBool
        Next
    'Next
    
    oOccurrence.Visible = True
    
End Sub

'WorkFeatureVisibilityWrapperCmd
'AssemblyVisibilityCtxCmd

--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes