Change visibility of plane of part of assembly in a drawing view

Change visibility of plane of part of assembly in a drawing view

dev8FGGQ
Participant Participant
349 Views
1 Reply
Message 1 of 2

Change visibility of plane of part of assembly in a drawing view

dev8FGGQ
Participant
Participant

Hi,

pls, how can I change visibility of a plane of a part of an assembly in a drawing view in VBA? I select a part in a view and then I want set visibility of a plane of the choosed part.

 

dev8FGGQ_0-1653653264487.png

 

 

I can get the part like this :

 

Sub p()

Dim doc As DrawingDocument
Set doc = ThisApplication.ActiveDocument
Set selSet = doc.SelectSet(1)
Dim oView As DrawingView
Dim obj As Object

Call doc.ProcessViewSelection(selSet, oView, obj)

 

'Call oView.SetVisibility(planeYZ, True)

End Sub

 

But I dont know, how to get planeYZ for setting of the visibility. If it is deep in oView or from the obj?

 

Thanks

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

dev8FGGQ
Participant
Participant
Accepted solution

So I have found how to do it :

 

Sub p()


Dim doc As DrawingDocument
Set doc = ThisApplication.ActiveDocument
Set selSet = doc.SelectSet(1) 'a part has to be selected
Dim oView As DrawingView
Dim obj As Object

Call doc.ProcessViewSelection(selSet, oView, obj)

Dim selectedpartname As String
selectedpartname = obj.Name 'name of selected part

Dim asmCompDef As ComponentDefinition 'top assembly
Set asmCompDef = oView.ReferencedDocumentDescriptor.ReferencedDocument.ComponentDefinition

Dim occ As ComponentOccurrence 'part of the assembly
Dim occurencename As String
Dim count As Long
Dim Y As Long

count = asmCompDef.Occurrences.count 'Count of occurrences
For Y = 1 To count
Set occ = asmCompDef.Occurrences(Y)
occurencename = occ.Name

If selectedpartname = occurencename Then 'If the name of selected correspod to occurrence
Dim asmPlane As WorkPlane
Dim occPlane As WorkPlane
Dim X As Long

For X = 1 To 3 'all 3 planes
On Error Resume Next ' Defer error handling.
Set occPlane = occ.Definition.WorkPlanes.Item(X)
Call occ.CreateGeometryProxy(occPlane, asmPlane) 'work plane in the context of the assembly
Call oView.SetIncludeStatus(asmPlane, True) 'Include the plane
Call oView.SetVisibility(asmPlane, True) 'Make visible
Next X
On Error GoTo 0
End If
Next Y


End Sub

0 Likes