My requirement : Use the Inventor API to obtain a specific edge within a model feature and add dimension annotations to this edge in the engineering drawing.

My requirement : Use the Inventor API to obtain a specific edge within a model feature and add dimension annotations to this edge in the engineering drawing.

1210550275
Contributor Contributor
659 Views
7 Replies
Message 1 of 8

My requirement : Use the Inventor API to obtain a specific edge within a model feature and add dimension annotations to this edge in the engineering drawing.

1210550275
Contributor
Contributor

The AddLinear method requires a GeometryIntent object created from the Sheet class, and Sheet.CreateGeometryIntent() can only accept edges within the view. How can I convert an edge in the model into an edge within the view?

Or, my approach might be incorrect. What are the correct steps to achieve my requirement?

0 Likes
Accepted solutions (1)
660 Views
7 Replies
Replies (7)
Message 2 of 8

Michael.Navara
Advisor
Advisor
Accepted solution

This is a sample, how to create drawing dimension to the specified edge in model. It requires update, because it doesn't contain your logic for edge selection, text positioning, works only for part, etc. But it can be used as starting point.

 

Expected dataset:

  • Drawing with single drawing view on active sheet
  • Drawing view references simple part with one extrusion of box

 

'Get relevant documents
dim drw as DrawingDocument = ThisDoc.Document
dim part As PartDocument = drw.ReferencedDocuments(1)

'Get edge in model
' !! This is just a sample. Modify it for your needs. !!
Dim partEdge = part.ComponentDefinition.Features.ExtrudeFeatures(1).EndFaces(1).Edges(1)

'Get drawing sheet and view
Dim drwSheet as Sheet = drw.ActiveSheet
Dim drwView as DrawingView = drwSheet.DrawingViews(1)

'Get drawing curve which corresponds with model edge
Dim edgeCurves As DrawingCurvesEnumerator = drwView.DrawingCurves(partEdge)
If edgeCurves.Count = 0 Then
    Logger.Error("There is no drawing curve for specified edge.")
    return
End If

'Create geometry intent for edge
Dim partEdgeIntent As GeometryIntent = drwSheet.CreateGeometryIntent(edgeCurves(1))

'Crete dimension
Dim textOrigin As Point2d = drwView.Position
drwSheet.DrawingDimensions.GeneralDimensions.AddLinear(textOrigin, partEdgeIntent, DimensionType := DimensionTypeEnum.kAlignedDimensionType)

 

 

Dataset preview

 

2024-11-13_10-19-14.jpg

Message 3 of 8

1210550275
Contributor
Contributor

I really appreciate your help, it was a huge relief. I sincerely hope to have the opportunity to seek your advice again in the future.

0 Likes
Message 4 of 8

1210550275
Contributor
Contributor
Hello,I have a question regarding the acquisition of a "side" as follows.
In the parts, you can manually assign a name to a certain face or edge, which will be displayed in "Named Geometric Elements". Suppose I name a face "Face 1" and name an edge within "Face 1" as "Edge 1".
Is there a method in the API that allows direct access to "Edge 1"?
0 Likes
Message 5 of 8

Michael.Navara
Advisor
Advisor

You can use Attributes API, or iLogic.

If you want to use iLogic, you need to convert variable part to ICadDocument. Below is the sample how to do it.

This code can replace line 3 and 7 in above sample.

...
Dim part As PartDocument = drw.ReferencedDocuments(1)
Dim partCadDoc = New CadDoc(part)
Dim partEdge = partCadDoc.NamedEntities.TryGetEntity("Edge1")
...

 

0 Likes
Message 6 of 8

1210550275
Contributor
Contributor
Thank you for your response.
Are there alternatives to these methods in the Inventor API?
I noticed that there is no NamedEntities object in the Inventor API. How can I achieve the same effect using the Inventor API?
0 Likes
Message 7 of 8

Michael.Navara
Advisor
Advisor

This information is stored in Attributes. Try to look at this part of the API. You need to know how it works.

For better understanding and testing you can use NiftyAttributes by Brian Ekkins. 

0 Likes
Message 8 of 8

1210550275
Contributor
Contributor
Thanks~
0 Likes