ComponentOccurrence the DrawingCurveSegment belongs to

<?xml encoding=”UTF-8″>By Adam Nagy

If you want to find out which ComponentOccurrence of the assembly a given DrawingCurve/DrawingCurveSegment belongs to then you can find it like so:

Sub GetOccurrenceFromDrawingCurveSegment()
' First select a drawing curve segment in
' one of the views that is showing an assembly
' If the curve is related to geometry
' inside a subcomponent then that suboccurrence
' in the assembly will be retrieved
Dim dcs As DrawingCurveSegment
Set dcs = ThisApplication.ActiveDocument.SelectSet(1)
Dim ep As EdgeProxy
Set ep = dcs.Parent.ModelGeometry
Dim co As ComponentOccurrence
Set co = ep.ContainingOccurrence
MsgBox (co.Name)
End Sub

Comments

2 responses to “ComponentOccurrence the DrawingCurveSegment belongs to”

  1. Colbjørn Johnsen Øyen Avatar
    Colbjørn Johnsen Øyen

    I can’t get this code to work.
    Is it outdated?
    The problem is this line:
    ep = dcs.Parent.ModelGeometry

  2. Hi,
    It should still work.
    Did you check it in a drawing view of an assembly as mentioned in the comments of the code?
    What error are you getting?
    Cheers,
    Adam

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading