Add linear dimension by 2 point 2D inventor vba

Add linear dimension by 2 point 2D inventor vba

Anonymous
Not applicable
876 Views
2 Replies
Message 1 of 3

Add linear dimension by 2 point 2D inventor vba

Anonymous
Not applicable

Hello Everyone,

 

in the drawing, I would like to create a linear dimension by 2 2d points, how can I archive it? Please help me with this case.

 

Thanks.NS95_2021-03-14_No01.png

0 Likes
877 Views
2 Replies
Replies (2)
Message 2 of 3

bradeneuropeArthur
Mentor
Mentor
Sub main()
    ' Open a drawing document and select two parallel linear curves in same drawing view first.
    Dim oApp As Inventor.Application
    set oApp = ThisApplication
    
    Dim oDoc As Document
    set oDoc = oApp.ActiveDocument
    If Not (oDoc Is Nothing) Then
        If Not (oDoc.DocumentType = kDrawingDocumentObject) Then
            MsgBox "Please activate a drawing document for this sample.", vbCritical, "Inventor"
            Exit Sub
        End If
    Else
        MsgBox "Please open a drawing document for this sample.", vbCritical, "Inventor"
        Exit Sub
    End If
    
    If Not (oDoc.SelectSet.Count = 2) Then
        MsgBox "Please select two parallel linear drawing curves from same drawing view for this sample.", vbCritical, "Inventor"
        Exit Sub
    ElseIf (oDoc.SelectSet(1).Type <> kDrawingCurveSegmentObject Or oDoc.SelectSet(1).Type <> kDrawingCurveSegmentObject) Then
        MsgBox "Please select two parallel linear drawing curves from same drawing view for this sample.", vbCritical, "Inventor"
        Exit Sub
    End If
   
    Dim oCurve1 As DrawingCurve, oCurve2 As DrawingCurve
    set oCurve1 = oDoc.SelectSet(1).Parent
    set oCurve2 = oDoc.SelectSet(2).Parent
    
    Dim oSheet As Sheet
    set oSheet = oCurve1.Parent.Parent
    
    ' Create two GeometryIntent based on the selected drawing curve segments.
    Dim oIntent1 As GeometryIntent, oIntent2 As GeometryIntent
    set oIntent1 = oSheet.CreateGeometryIntent(oCurve1)
    set oIntent2 = oSheet.CreateGeometryIntent(oCurve2)
    
    Dim oTextPos As Point2d
    set oTextPos = oApp.TransientGeometry.CreatePoint2d(12, 12)
    
    ' Create the linear foreshortened dimension
    Dim oLinearForeshortenedDim As LinearGeneralDimension
    'oLinearForeshortenedDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinearForeshortened(oTextPos, oIntent1, oIntent2, True)
    oLinearForeshortenedDim = oSheet.DrawingDimensions.GeneralDimensions.AddLinear(oTextPos, oIntent1, oIntent2)
End Sub







Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 3 of 3

agrove72Y9W
Participant
Participant

You can create a geometry intent at the intersection between two drawing curves

 

Dim oSheet As Sheet = ThisDoc.Document.Sheets.Item(1)
Dim oCurve1, oCurve2 As DrawingCurve

[insert code for specifying oCurve1 and oCurve2]

Dim oIntent As GeometryIntent = oSheet
.CreateGeometryIntent(oCurve1, oCurve2)

 

0 Likes