Using Inventor API 's Model Annotation to object to add Dimension in 3D Model

Using Inventor API 's Model Annotation to object to add Dimension in 3D Model

adrian_liao
Explorer Explorer
180 Views
2 Replies
Message 1 of 3

Using Inventor API 's Model Annotation to object to add Dimension in 3D Model

adrian_liao
Explorer
Explorer

I want to use Inventor 2025's API to handle 3D dimensions(to add Dimension in 3D Model), but I saw the API documentation, which shows that "LinearModelDimension" under the "Model Annotation" category only has "Get" but no "Set". Does this mean that Inventor 2025's API  does not support to create 3D annotations?

adrian_liao_2-1750474916006.png

adrian_liao_3-1750475061713.png

 

Thank for your replay

Regards

Adrian

0 Likes
Accepted solutions (1)
181 Views
2 Replies
Replies (2)
Message 2 of 3

JelteDeJong
Mentor
Mentor
Accepted solution

You can create them. Have a look at this example code:

' Get the current part document and its component definition
Dim doc As PartDocument = ThisDoc.Document
Dim def As PartComponentDefinition = doc.ComponentDefinition

' Prompt the user to select the first face for the dimension
Dim face1 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter,
    "Select the first face for the linear dimension.")

' Prompt the user to select the second face for the dimension
Dim face2 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter,
    "Select the second face for the linear dimension.")

' Prompt the user to select a face to serve as the annotation plane
Dim face3 = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter,
    "Select the annotation plane.")

' Create a point to place the dimension text (placeholder at origin)
Dim textPoint = ThisApplication.TransientGeometry.CreatePoint(0, 0, 0)

' Create geometry intents for the two selected faces (used by the dimension)
Dim intent1 = def.CreateGeometryIntent(face1)
Dim intent2 = def.CreateGeometryIntent(face2)

' Define the annotation plane using the third selected face
Dim annotationPlane = def.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(face3)

' Get the collection of existing linear model dimensions
Dim linearDimensions = def.ModelAnnotations.ModelDimensions.LinearModelDimensions

' Create a new linear dimension definition between the two faces
Dim linDef = linearDimensions.CreateDefinition(
    intent1, intent2, annotationPlane, textPoint, DimensionTypeEnum.kAlignedDimensionType)

' Add the defined dimension to the model
linearDimensions.Add(linDef)

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 3

adrian_liao
Explorer
Explorer

Hello  Jelte de Jong
Thank you very much !

This sample code was very helpful to me, It solved my biggest problem !

 

Best regards

Adrian.Liao

0 Likes