How to get an info on selected part in drawing view using VBA?

How to get an info on selected part in drawing view using VBA?

Anonymous
Not applicable
2,218 Views
5 Replies
Message 1 of 6

How to get an info on selected part in drawing view using VBA?

Anonymous
Not applicable

Hi all. Hope you guys have nothing on your hands to do, so I can get help pretty soon ... Man Happy

 

I am trying to make a VBA macro that will, after component is selected (filter for part priority is picked), set component as "transparent" and set line type to "Dash Double Dot". The problem I have is that under SelectionSet.Item(1).ObjectType it says kUnknownObject when component is selected. I was expecting to get info on selected component. Please, see picture below:

SelectedPartInDrawing.png

I also tried RMB and "Select As Edges", which gives me all selected edges under SeletionSet but I still cannot get info for the component which is the parent for these selected edges. Also, I think, that if I go with "Select As Edges" I will not be able to make component transparent.

 

What I am missing here? Is it even possible to do this through VBA?

0 Likes
Accepted solutions (1)
2,219 Views
5 Replies
Replies (5)
Message 2 of 6

omartin
Advocate
Advocate

You can get the occurrence from the edge selection:

Dim dcc As DrawingCurveSegment
Set dcc = ss(1)
Dim dc As DrawingCurve
Set dc = dcc.Parent

Dim face As FaceProxy
Dim edge As EdgeProxy

If dc.ModelGeometry.Type = 67120288 Then
Set edge = dc.ModelGeometry
Set occ = edge.ContainingOccurrence
ElseIf dc.ModelGeometry = 67119520 Then
Set face = dc.ModelGeometry
Set occ = face.ContainingOccurrence
End If

occ.Transparent = True


Was my reply Helpful ? send a Kudos or accept as solution
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hi omartin. Thank you for reply.

This is how I used your code, but it does not work. I am able to change "Transparent" value to true, but on drawing nothing changes.

Public Sub TempSub()

Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument

Dim oObject As Object
Set oObject = oDrawDoc.SelectSet.Item(1)

Dim dcc As DrawingCurveSegment
Set dcc = oObject

Dim dc As DrawingCurve
Set dc = dcc.Parent

Dim face As FaceProxy
Dim edge As EdgeProxy

Dim occ As Variant

If dc.ModelGeometry.Type = 67120288 Then
    Set edge = dc.ModelGeometry
    Set occ = edge.ContainingOccurrence
ElseIf dc.ModelGeometry = 67119520 Then
    Set face = dc.ModelGeometry
    Set occ = face.ContainingOccurrence
End If

occ.Transparent = False

End Sub
0 Likes
Message 4 of 6

Anonymous
Not applicable

omartin,

I just found out that this "Transparent" vlaue is related to model view and not to the drawing view. It changes transparency for the part in model not in the drawing.

0 Likes
Message 5 of 6

omartin
Advocate
Advocate
Accepted solution

Hmm. I c, (obviously I didn't test my code).... I think it has to do with drawing views or some where to refresh the view (If I re add the view the transparent will take effect).....

 

Well You can simply exute the transparent command using this line after the whole part is selected.

 

ThisApplication.CommandManager.ControlDefinitions("DrawingBodyTransparentCtxCmd").Execute2 (True)

Was my reply Helpful ? send a Kudos or accept as solution
0 Likes
Message 6 of 6

Anonymous
Not applicable

omartin,

Thank you! This will suffice. I totally forgot that I can call commands.

0 Likes