Change visibility of origin work plane at occurrence level

Change visibility of origin work plane at occurrence level

MatthiasMinich
Participant Participant
463 Views
6 Replies
Message 1 of 7

Change visibility of origin work plane at occurrence level

MatthiasMinich
Participant
Participant

 

there is a difference when handling "user defined workplanes" and "origin work planes". It is not possible to change the visibility of a origin work plane only in the occurrence level. Modifying the "origin work plane proxie" always changes the parent document. whereas a "user defined work plane" can be shown only in a occurrence level. 

 

Please check the sample code below. Select a component (with a user defined work plane) in a assembly document. When the code is executed work planes (1-3) are shown in all occurrences, but the following work planes (4-...) are visible only in the selected occurrence, as desired.

 

Is there a work around to change the visibility of a origin work plane only at an occurrence?

 

I'm using Autodesk Inventor 2019

 

Best,

Matthias

 

Public Sub Test_WorkPlane_Visible()

    Dim oApp As Inventor.Application
    Set oApp = ThisApplication
    
    If oApp.ActiveDocumentType <> kAssemblyDocumentObject Then Exit Sub
    
    Dim oDoc As Inventor.AssemblyDocument
    Set oDoc = oApp.ActiveDocument
    
    
    Dim oOcc As Inventor.ComponentOccurrence
    Dim Item As Object
        
    For Each Item In oDoc.SelectSet
        If Item.Type = Inventor.kComponentOccurrenceObject Then
            Set oOcc = Item
            
            Dim i As Long
            For i = 1 To oOcc.Definition.WorkPlanes.Count
                
                Dim oWorkPlane As Inventor.WorkPlane
                Set oWorkPlane = oOcc.Definition.WorkPlanes.Item(i)
                
                Dim oWorkPlaneProxie As Inventor.WorkPlaneProxy
                Call oOcc.CreateGeometryProxy(oWorkPlane, oWorkPlaneProxie)
                        
                oWorkPlaneProxie.Visible = Not (oWorkPlaneProxie.Visible)
            Next i
        
        End If
    Next
    
End Sub

 

 

m_matthias_0-1678262156494.png

0 Likes
464 Views
6 Replies
Replies (6)
Message 2 of 7

WCrihfield
Mentor
Mentor

Hi @MatthiasMinich.  Your code is 'toggling' the visibility of every WorkPlane of every pre-selected component in the context of that component's parent assembly.  If you want to change the visibility of the WorkPlanes within the context of the component's referenced model file, then you should skip the 'proxy' steps.  And if the component is not a top level component, you would need to step the proxy reference up however many levels it takes to get to the top level assembly's context.  Creating a proxy of a 4th level component WorkPlane gets you a reference to its virtual copy within the context of its parent assembly, which is at 3rd level, not top level.  Since it is 'toggling' them, then if the component currently has all of its origin WorkPlanes turned off, and one custom WorkPlane visible, then running the rule will, by design, leave the origin WorkPlanes on, and the custom one off.  That is the definition of toggling.  To change it from toggling, change that line of code for setting Visible property to using a normal True or False value.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 7

MatthiasMinich
Participant
Participant

Hi @WCrihfield

thanks for your reply. Actually I noticed that my problem is not API related but more a general topic. I only want to "toggle" the visibility in the context of a components parent assembly. Unfortunately this is not possible for "Origin"-Objects such as: Origin-Point, Origin-Axes(X Axis/Y Axis/Z Axis) and Origin-Plane (YZ-Plane/XZ-Plane/XY-Plane). They are always "toggled" in the Document level and never in the context of a components parent assembly. 

For all other user defined objects Points/Axes&Planes this works fine. 

Just check it yourself. If you have a component which is used multiple times in your assembly, changing the visibility of one origin object will affect all others.

 

m_matthias_0-1678288461099.png

 

0 Likes
Message 4 of 7

WCrihfield
Mentor
Mentor

Interesting find.  I am able to reproduce that same behavior, both manually, and by code.  Seems like a bug, because it should not be linked that way.  It doesn't even seem to care how you have the DVR's (DesignViewRepresentations) set-up, either on the parent assembly side, or on the source component assembly side.  What version of Inventor are you using?  I'm currently using 2022.4.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 7

MatthiasMinich
Participant
Participant

I am still using a older version of inventor:

Autodesk Inventor Professional 2019

64-Bit-Edition

Build 330, Release: 2019.4.3

 

is there a special way to report a bug, or is this post already seen as bug report?

0 Likes
Message 6 of 7

A.Acheson
Mentor
Mentor

Hi @MatthiasMinich you can post this on the inventor forum to get an official answer. I have noticed that content center parts will not allow origin planes to be visible because of their read only status. However you can set user defined work features as visible. This to me would suggest that user defined work features can be converted to a proxy object and origin work features cannot.  Origin work features can only be changed in the part/assembly definition themselves. 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 7 of 7

c_hoppen
Advocate
Advocate

I just ran into the same issue (2024.2 / 2025.2) and found this thread here. CreateGeometryObject still returns the NATIVE workplane instead of the proxy.

It seems like Autodesk has no interest in fixing this annoying bug...?

0 Likes