Getting Model Feature from Selected Drawing Curve

Getting Model Feature from Selected Drawing Curve

Anonymous
Not applicable
1,425 Views
4 Replies
Message 1 of 5

Getting Model Feature from Selected Drawing Curve

Anonymous
Not applicable

Hello All,

 

I've been doing some research these past few days but cannot seem to find what I'm looking for. 

 

Im trying to create some code for another user which takes the pre-selected drawing curve and retrieves the feature information from the model. More specifically, I want to pre-select the drawing curve of a hole, and then run the rule. The rule will take this selected drawing curve and get its model. Then from here I'm expecting I'll be able to use the Hole Feature classes in the API to retrieve the wanted information. 

 

I've tried using SelectSet.Item(1by tut cannot seem to be able to set it as a drawing curve (or anything for that matter). 

 

Any help is appreciated. 

 

Thanks

Mitch

0 Likes
1,426 Views
4 Replies
Replies (4)
Message 2 of 5

Vladimir.Ananyev
Alumni
Alumni

If you select a hole in a drawing view then drawing document SelectSet object contains DrawingCurveSegment object (not DrawingCurve object).

DrawingCurve is a parent for DrawingCurveSegment.

DrawingCurve object allows you to get the reference to the circle edge in the model. 

Then you may use Edge.Faces collection to find the face that was created by Hole feature.

I've tested this approach with the following VBA sample.  Hope it can clarify the idea.

 

Sub Holes_Test()

  'open drawing document and
  'select one hole. Then run this sample.
  
  Dim oDrawDoc As DrawingDocument
  Set oDrawDoc = ThisApplication.ActiveDocument
  
  Dim oSSet As SelectSet
  Set oSSet = oDrawDoc.SelectSet
  If oSSet.Count <> 1 Then
    MsgBox "Select one hole in a drawing"
    Exit Sub
  End If

  Dim oDrawingCurveSegment As DrawingCurveSegment
  Set oDrawingCurveSegment = oSSet.Item(1)
  
  Dim oDrawingCurve As DrawingCurve
  Set oDrawingCurve = oDrawingCurveSegment.Parent
  
  Dim oEdge As Edge
  Set oEdge = oDrawingCurve.ModelGeometry
  
  Dim oFace As Face
  For Each oFace In oEdge.Faces
    If oFace.CreatedByFeature.Type = ObjectTypeEnum.kHoleFeatureObject Then
    
      Dim oHoleFeature As HoleFeature
      Set oHoleFeature = oFace.CreatedByFeature
      Debug.Print "Name = " & oHoleFeature.Name
      Debug.Print "ExtendedName = " & oHoleFeature.ExtendedName
      Debug.Print "ExtentType = " & oHoleFeature.ExtentType

    End If
  Next
  
End Sub

 

 


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

Message 3 of 5

linjone09
Participant
Participant

It is work. Thank you.

0 Likes
Message 4 of 5

GeorgK
Advisor
Advisor

Hello @Vladimir.Ananyev,

 

is it possible to get the hole from the sideview?

 

Gewinde.png

 

Georg

0 Likes
Message 5 of 5

GeorgK
Advisor
Advisor

Is there a solution to get the hole?

0 Likes