ClientGraphics problem

ClientGraphics problem

GeorgK
Advisor Advisor
483 Views
3 Replies
Message 1 of 4

ClientGraphics problem

GeorgK
Advisor
Advisor

Hello together,

 

there is a question in the German forum to show the distance between a face and the CenterOfMass.

https://forums.autodesk.com/t5/inventor-deutsch/inventor-2019-schwerpunkt-im-modell-bemassen/m-p/836...

 

How could I do  this with ClientGraphics (show the dimensions)?

 

Thank you

 

Georg

0 Likes
484 Views
3 Replies
Replies (3)
Message 2 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@GeorgK,

 

Dimensions also can be created using 3D model annotations. Hoping that below VBA code may be helpful instead of client graphics.

 

Sub 3DLinearDimensions()

    Dim doc As PartDocument
    Set doc = ThisApplication.ActiveDocument

    Dim oDef As PartComponentDefinition
    Set oDef = doc.ComponentDefinition

    Dim oAnnotationFace As Face
    Set oAnnotationFace = ThisApplication.CommandManager.Pick(kPartFaceFilter, "Select a face to add Model linear dimension")
    
    Dim oAnnotationPlaneDef As AnnotationPlaneDefinition
    Set oAnnotationPlaneDef = oDef.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(oAnnotationFace)
    ' Set a reference to the TransientGeometry object.

    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry
    
    Dim oPt As Point
    Set oPt = oTG.CreatePoint(3, 3, 3)
    
    Dim oCenterOfMass As Point
    Set oCenterOfMass = oDef.MassProperties.CenterOfMass
    
    Dim oWpt As WorkPoint
    Set oWpt = oDef.WorkPoints.AddFixed(oCenterOfMass)
    
    Dim oFace As Face
    Set oFace = ThisApplication.CommandManager.Pick(kPartFaceFilter, "Select a face")
    
    Dim oIntent1 As GeometryIntent
    Set oIntent1 = oDef.CreateGeometryIntent(oFace)
    
    Dim oIntent2 As GeometryIntent
    Set oIntent2 = oDef.CreateGeometryIntent(oWpt)

    Dim oLinearDimDef As LinearModelDimensionDefinition
    Set oLinearDimDef = oDef.ModelAnnotations.ModelDimensions.LinearModelDimensions.CreateDefinition(oIntent1, oIntent2, oAnnotationPlaneDef, oPt, kVerticalDimensionType)
 
    Dim oLinearDim As LinearModelDimension
    Set oLinearDim = oDef.ModelAnnotations.ModelDimensions.LinearModelDimensions.Add(oLinearDimDef)
End Sub

To demonstrate, a screencast is prepared and uploaded to below link.

 

https://autode.sk/2Jz7lmD

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 4

GeorgK
Advisor
Advisor

Hello @chandra.shekar.g,

 

Thank you very much. That solves the problem for Inventor 2019 but not for older versions.

0 Likes
Message 4 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support

@GeorgK,

 

LinearModelDimensions.Add (ModelAnnotations) method is introduced in Inventor 2018 and later versions. For more details, refer Inventor 2018 API help documentation link.

 

http://help.autodesk.com/view/INVNTOR/2018/ENU/?guid=GUID-656FEC41-1A6E-4E11-9DA4-B08F254F85A2

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes