Getting Model Feature from Selected Drawing Curve - side view

Getting Model Feature from Selected Drawing Curve - side view

GeorgK
Advisor Advisor
2,180 Views
5 Replies
Message 1 of 6

Getting Model Feature from Selected Drawing Curve - side view

GeorgK
Advisor
Advisor

Hello together,

 

there is a post to get the model feature.

 

https://forums.autodesk.com/t5/inventor-customization/getting-model-feature-from-selected-drawing-cu...

 

But how could I get the model feature from a side view?

 

Gewinde.png

 

Thank you Georg

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

JaneFan
Autodesk
Autodesk

Hello Gorge,

 

As long as the drawing curve segment can be selected, the relative Edge, Face and CreatedByFeature can be get with the same way as what was said in this topic:https://forums.autodesk.com/t5/inventor-customization/getting-model-feature-from-selected-drawing-cu...

 




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 6

GeorgK
Advisor
Advisor

Hello Jane,

 

I tried that. But it does not work at all. Is it possible that you try it?

 

Georg

0 Likes
Message 4 of 6

MechMachineMan
Advisor
Advisor

Hi Georg. So what you do here is convert your code to vba.

 

Use the watch window to capture objects. Explore the various sub-items in the watch window as you STEP through the code. Eventually, you can expand nodes of various items and work your way through trial and error of expanding nodes to find where the object is store and what path you can take to access it.

 

This is also useful because if the object that you are trying to access shows up as "kGenericObject", or something similar, there is almost no functionality in the API for it.

 

The easiest way to do this is to have the code just access a select set; select the object you want to gain information on, start stepping through the code, and browser the object tree in the watch window. 


--------------------------------------
Did you find this reply helpful ? If so please use the 'Accept as Solution' or 'Like' button below.

Justin K
Inventor 2018.2.3, Build 227 | Excel 2013+ VBA
ERP/CAD Communication | Custom Scripting
Machine Design | Process Optimization


iLogic/Inventor API: Autodesk Online Help | API Shortcut In Google Chrome | iLogic API Documentation
Vb.Net/VBA Programming: MSDN | Stackoverflow | Excel Object Model
Inventor API/VBA/Vb.Net Learning Resources: Forum Thread

Sample Solutions:Debugging in iLogic ( and Batch PDF Export Sample ) | API HasSaveCopyAs Issues |
BOM Export & Column Reorder | Reorient Skewed Part | Add Internal Profile Dogbones |
Run iLogic From VBA | Batch File Renaming| Continuous Pick/Rename Objects

Local Help: %PUBLIC%\Documents\Autodesk\Inventor 2018\Local Help

Ideas: Dockable/Customizable Property Browser | Section Line API/Thread Feature in Assembly/PartsList API Static Cells | Fourth BOM Type
0 Likes
Message 5 of 6

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

Hi @GeorgK,

 

Sometimes, ModelGeometry of DrawingCurve could be kFaceObject. So, try the following modified VBA code.

 

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 oFace As Face
  Dim oHoleFeature As HoleFeature
  
  If oDrawingCurve.ModelGeometry.Type = kFaceObject Then
    
    Set oFace = oDrawingCurve.ModelGeometry
  
    If oFace.CreatedByFeature.Type = ObjectTypeEnum.kHoleFeatureObject Then
          
      Set oHoleFeature = oFace.CreatedByFeature
      Debug.Print "Name = " & oHoleFeature.Name
      Debug.Print "ExtendedName = " & oHoleFeature.ExtendedName
      Debug.Print "ExtentType = " & oHoleFeature.ExtentType

    End If
    
  ElseIf oDrawingCurve.ModelGeometry.Type = kEdgeObject Then
      
      Dim oEdge As Edge
      Set oEdge = oDrawingCurve.ModelGeometry
      
      For Each oFace In oEdge.Faces
        If oFace.CreatedByFeature.Type = ObjectTypeEnum.kHoleFeatureObject Then
        
          Set oHoleFeature = oFace.CreatedByFeature
          Debug.Print "Name = " & oHoleFeature.Name
          Debug.Print "ExtendedName = " & oHoleFeature.ExtendedName
          Debug.Print "ExtentType = " & oHoleFeature.ExtentType
    
        End If
      Next
    
  End If
  
End Sub

Please feel free to contact if there is any doubt.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



Message 6 of 6

GeorgK
Advisor
Advisor

Hello @chandra.shekar.g,

 

thank you very much for your help. I added some code to get the RectangularPatternFeature and CircularPatternFeature.

 

Georg

0 Likes