Sketchsymbol to coordinate dimension

Sketchsymbol to coordinate dimension

Tom_BeyerFMVHA
Contributor Contributor
411 Views
17 Replies
Message 1 of 18

Sketchsymbol to coordinate dimension

Tom_BeyerFMVHA
Contributor
Contributor

Hello, I am trying to place a sketch symbol with a fixed area on the dimension text.

I am using the "jogpoint1" for this.

 

Does anyone have any ideas on how to call the text with ilogic or how best to ‘dock’ the sketch symbol to the dimensioning?

 

Sub Main()
    ' Anordnung der Symbole "Sketchsymbolname" und "Sketchsymbolname" basierend auf dem Maßzahlentext
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

    Dim oSymbol_Links As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("Höhenkoten-links")
    Dim oSymbol_Rechts As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("Höhenkote-rechts")
    
	  For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
        If oSymbol.Name = "Sketchsymbolname" Or oSymbol.Name = "Sketchsymbolname" Then
            oSymbol.Delete()
        End If
    Next
	
	
    ' Fester horizontaler Abstand von 10 mm vom Maßzahlentext
    Dim symbolAbstand As Double = 0.2

    ' Durchlaufe alle Dimensionen auf dem Blatt
    For Each dimension As DrawingDimension In oSheet.DrawingDimensions
        If dimension.DimensionType = kHorizontalDimensionType Then
            Dim measurePos As Point2d = Nothing
            ' Versuch, die Position des Maßzahlentexts zu ermitteln
            On Error Resume Next
            measurePos = dimension.Text.Position
            On Error GoTo 0

            ' Falls kein Text vorhanden ist, benutze JogPointOne (statt Mittelwert)
            If measurePos Is Nothing Then
                measurePos = dimension.JogPointtwo
            End If

            ' Bestimme den Insertionspunkt relativ zum Maßzahlentext
            Dim oInsertionPoint As Point2d = Nothing
            If dimension.JogPointOne.X > dimension.JogPointTwo.X Then
                ' Annahme: Maßzahl steht links – Kote soll rechts daneben erscheinen
                oInsertionPoint = oTG.CreatePoint2d(measurePos.X + symbolAbstand, measurePos.Y)
                oSheet.SketchedSymbols.Add(oSymbol_Rechts, oInsertionPoint, 0, 1)
            Else
                ' Annahme: Maßzahl steht rechts – Kote soll links daneben erscheinen
                oInsertionPoint = oTG.CreatePoint2d(measurePos.X - symbolAbstand, measurePos.Y)
                oSheet.SketchedSymbols.Add(oSymbol_Links, oInsertionPoint, 0, 1)
            End If
        End If
    Next
End Sub

 

0 Likes
Accepted solutions (2)
412 Views
17 Replies
Replies (17)
Message 2 of 18

WCrihfield
Mentor
Mentor

Hi @Tom_BeyerFMVHA.  Do you need the SketchedSymbol to be truly attached to the dimension, or is just placing it on the dimension in a static way OK?  If you need to be able to truly attach it to the dimension, then you will need to use the SketchedSymbols.AddWithLeader method, instead of using the SketchedSymbols.Add method.  Then, you will also need to use the Sheet.CreateGeometryIntent method, to create a GeometryIntent to put into the ObjectCollection that the AddWithLeader method is asking for, instead of just a transient Point2d object.  A Point2d object is just numerical data for a location, with no association to anything.  The GeometryIntent is what defines the 'connection or association' between a piece of pre-existing geometry and a dimension or annotation that you want to attach to it.  When that is in place, then whatever you are attaching to the pre-existing geometry will move with that pre-existing geometry, if it moves.  When using the CreateGeometryIntent method, try using the value of the DrawingDimension.DimensionLine property as the first 'input' it is asking for, then PointInferenceEnum.kPtAtMidPoint as the second input, even though the second input is optional, it helps specify that you want it associated with the mid-point of that line, not just that line in general.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 18

Tom_BeyerFMVHA
Contributor
Contributor

Hi Wesley, thanks for the quick reply. I tried to implement your guidance, but I keep encountering an unknown error. (Ausnahme von HRESULT: 0x80004005 (E_FAIL)) in this line 

 oSketchedSymbol = oSheet.SketchedSymbols.AddWithLeader(oSymbol_Rechts, objCollection, 0, 1)

 

0 Likes
Message 4 of 18

Ivan_Sinicyn
Advocate
Advocate

@Tom_BeyerFMVHA 
I experimented a bit with your code. Take a look

osymb.png

 

Sub Main()
    ' Set logging level to Trace for maximum detail
    iLogicVb.Automation.LogControl.Level = LogLevel.Trace
    logger.Trace("Script started.")

    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

    ' Retrieve sketched symbol definitions
    Dim oSymbol_Links As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("Höhenkoten-links")
    Dim oSymbol_Rechts As SketchedSymbolDefinition = oDoc.SketchedSymbolDefinitions.Item("Höhenkote-rechts")
    
    ' Remove all existing instances of specified symbols from the sheet
    logger.Trace("Removing existing instances of Höhenkoten-links and Höhenkote-rechts symbols.")
    For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
        If oSymbol.Name = "Höhenkoten-links" Or oSymbol.Name = "Höhenkote-rechts" Then
            On Error Resume Next
            oSymbol.Delete()
            If Err.Number = 0 Then
                logger.Info("Deleted symbol: " & oSymbol.Name)
            Else
                logger.Error("Failed to delete symbol " & oSymbol.Name & ": " & Err.Description)
                Err.Clear
            End If
            On Error GoTo 0
        End If
    Next
    
    Dim symbolAbstand As Double = 0.2
    logger.Trace("Starting dimension processing.")

    ' Process each drawing dimension to place new symbols
    For Each dimension As DrawingDimension In oSheet.DrawingDimensions
        logger.Info("Processing dimension. DimensionType: " & dimension.DimensionType & ", Type: " & dimension.Type)
        
        ' Check for ordinate dimension using Type
        If dimension.Type = 117484800 Then ' kOrdinateDimensionObject
            logger.Info("Found ordinate dimension (OrdinateDimension).")
            
            Dim measurePos As Point2d = Nothing
            ' Attempt to retrieve JogPointTwo as primary position
            On Error Resume Next
            measurePos = dimension.JogPointTwo
            If Err.Number <> 0 Then
                logger.Error("Error retrieving JogPointTwo: " & Err.Description)
                Err.Clear
            End If
            On Error GoTo 0
            logger.Trace("JogPointTwo position: " & IIf(measurePos Is Nothing, "Not defined", measurePos.X & ", " & measurePos.Y))

            ' Fallback to JogPointOne if JogPointTwo is unavailable
            If measurePos Is Nothing Then
                logger.Warn("JogPointTwo not defined. Attempting to use JogPointOne.")
                On Error Resume Next
                measurePos = dimension.JogPointOne
                If Err.Number <> 0 Then
                    logger.Error("Error retrieving JogPointOne: " & Err.Description)
                    Err.Clear
                End If
                On Error GoTo 0
                logger.Trace("JogPointOne position: " & IIf(measurePos Is Nothing, "Not defined", measurePos.X & ", " & measurePos.Y))
            End If

            ' Skip dimension if no position is defined
            If measurePos Is Nothing Then
                logger.Warn("Position not defined. Skipping dimension.")
                Continue For
            End If

            Dim oInsertionPoint As Point2d = Nothing
            Dim jog1X As Double
            Dim jog2X As Double
            On Error Resume Next
            jog1X = dimension.JogPointOne.X
            jog2X = dimension.JogPointTwo.X
            If Err.Number <> 0 Then
                logger.Error("Error retrieving JogPointOne or JogPointTwo X coordinates: " & Err.Description)
                Err.Clear
            End If
            On Error GoTo 0
            logger.Trace("JogPointOne.X: " & jog1X & ", JogPointTwo.X: " & jog2X)

            ' Determine symbol placement based on jog point X coordinates
            If jog1X > jog2X Then
                oInsertionPoint = oTG.CreatePoint2d(measurePos.X + symbolAbstand, measurePos.Y)
                logger.Trace("Adding symbol Höhenkote-rechts at point: " & oInsertionPoint.X & ", " & oInsertionPoint.Y)
                On Error Resume Next
                oSheet.SketchedSymbols.Add(oSymbol_Rechts, oInsertionPoint, 0, 1)
                If Err.Number <> 0 Then
                    logger.Error("Error adding Höhenkote-rechts: " & Err.Description)
                    Err.Clear
                Else
                    logger.Info("Successfully added Höhenkote-rechts.")
                End If
                On Error GoTo 0
            Else
                oInsertionPoint = oTG.CreatePoint2d(measurePos.X - symbolAbstand, measurePos.Y)
                logger.Trace("Adding symbol Höhenkoten-links at point: " & oInsertionPoint.X & ", " & oInsertionPoint.Y)
                On Error Resume Next
                oSheet.SketchedSymbols.Add(oSymbol_Links, oInsertionPoint, 0, 1)
                If Err.Number <> 0 Then
                    logger.Error("Error adding Höhenkoten-links: " & Err.Description)
                    Err.Clear
                Else
                    logger.Info("Successfully added Höhenkoten-links.")
                End If
                On Error GoTo 0
            End If
        Else
            logger.Trace("Dimension is not an ordinate dimension. Skipping.")
        End If
    Next
    
    logger.Trace("Script completed.")
End Sub

 

 

INV 2025.3
0 Likes
Message 5 of 18

Stakin
Collaborator
Collaborator
Accepted solution

The symbol must without prompt

 

 

Sub Main()
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry	
    Dim oSymbol_Links As String = "Höhenkoten-links"
	Dim oSymbol_Rechts As String= "Höhenkote-rechts"	
    For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
        If oSymbol.Definition.Name=oSymbol_Links Or oSymbol.Definition.Name= oSymbol_Rechts Then
            oSymbol.Delete()
         End If
    Next    
    Dim symbolAbstand As Double =3 'mm,Must >=3mm,i guess it may limitied by the leader size
    For Each dimension As OrdinateDimension In oSheet.DrawingDimensions.cast(Of DrawingDimension).Where(Function(x) x.Type = 117484800)
     	Dim oLeaderPoints As ObjectCollection
			oLeaderPoints = oGetCol(dimension,symbolAbstand) 
		Dim oSymbol As SketchedSymbol
		Dim oSymbolDef As SketchedSymbolDefinition
		Dim oSymbolDefName As String		
		If dimension.DimensionType = Inventor.DimensionTypeEnum.kHorizontalDimensionType Then
			oSymbolDefName=oSymbol_Rechts
		Else
			oSymbolDefName=oSymbol_Links
		End If
		oSymbolDef= oDoc.SketchedSymbolDefinitions.Item(oSymbolDefName )
		oSymbol = oSheet.SketchedSymbols.AddWithLeader(oSymbolDef, oLeaderPoints)
		oSymbol.LeaderVisible = False
		oSymbol.SymbolClipping = False
    Next
End Sub
Function oGetCol(dimension As DrawingDimension,symbolAbstand As Double) As ObjectCollection	
    Dim oLeaderPoints As ObjectCollection
    oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
	Dim oPoint As Point2d
    	oPoint = dimension.JogPointTwo	
	Dim oPoint1 As Point2d
	oPoint1=oPoint.Copy
	If dimension.DimensionType = Inventor.DimensionTypeEnum.kHorizontalDimensionType Then
		oPoint1.Y+=symbolAbstand/10
	Else
		oPoint1.X+=symbolAbstand/10
	End If
	oLeaderPoints.Add(oPoint1)
    Dim oGeometryIntent As GeometryIntent
    oGeometryIntent = dimension.Parent.CreateGeometryIntent(dimension,oPoint)
    Call oLeaderPoints.Add(oGeometryIntent)
	Return oLeaderPoints
End Function

 

 

0 Likes
Message 6 of 18

Tom_BeyerFMVHA
Contributor
Contributor

Hi Stakin and Ivan,  it works good. 

 

Thanks for your effort.

0 Likes
Message 7 of 18

Tom_BeyerFMVHA
Contributor
Contributor

Hi Stakin, I have another question: Do you know the name of the point????? I'm trying to dock the symbol at the end of the dimension line. Thanks in effort.Screenshot 2025-03-12 144709.png

0 Likes
Message 8 of 18

Ivan_Sinicyn
Advocate
Advocate

@Tom_BeyerFMVHA 

DimensionText.Origin Property
Parent Object: DimensionText

Description

Gets and sets the origin position of the text.

Syntax
DimensionText.Origin() As Point2d
Property Value
This is a read/write property whose value is a Point2d.

INV 2025.3
0 Likes
Message 9 of 18

Stakin
Collaborator
Collaborator

 

Rem The end point(join the text):
dimension.DimensionLine.PointAtIndex(dimension.DimensionLine.PointCount)
Rem The Start point(join the object):
dimension.DimensionLine.PointAtIndex(1)

 

0 Likes
Message 10 of 18

WCrihfield
Mentor
Mentor

Been too busy at work to reply much lately, and still pretty busy.  But one little detail that I keep seeing here is the terms 'JogPointone' & 'JogPointTwo'.  Those are not properties of the generic DrawingDimension object type.  They are only available when working with the OrdinateDimension object type (OrdinateDimension.JogPointOne & OrdinateDimension.JogPointTwo), and will not exist for any other drawing dimension sub type.  The GeneralDimension object type is the other main sub type (with several sub-types of its own) of the generic DrawingDimension type, and it does not have those properties, so if iterating every dimension on a sheet, and not checking what type of dimension each one you encounter is, then it will likely throw an error when trying to access that property of a dimension that is not that type.  And if checking one of those two properties on both sides of a Try...Catch...End Try statement, then it will still throw an error, because both property access attempts would fail.  Besides that, the value of those properties is just a transient Point2d object, which is not stable geometry to 'attach' an annotation to with a GeometryIntent, but can be used to help specify a a more specific location along the base geometry object that you input as the first input argument.  So, if you have any other types of dimensions on your sheet, then you may have to check which type each one is before proceeding, then handle the different sub types a little differently.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 11 of 18

Stakin
Collaborator
Collaborator

@WCrihfield @Ivan_Sinicyn 

in oGetCol Function if set the

 

 

oPoint = dimension.JogPointTwo

 

 

, it runs ok;

but if set 

 

 

oPoint = dimension.DimensionLine.PointAtIndex(dimension.DimensionLine.PointCount)

 

 

it breaked at but it when add for verticaltype symbol 

Are you known the reason?

 

 

Sub Main()
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry	
    Dim oSymbol_Links As String = "Höhenkoten-links"
	Dim oSymbol_Rechts As String= "Höhenkote-rechts"	
    For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
        If oSymbol.Definition.Name=oSymbol_Links Or oSymbol.Definition.Name= oSymbol_Rechts Then
            oSymbol.Delete()
         End If
    Next    
    Dim symbolAbstand As Double =20'mm,Must >=3mm,i guess it may limitied by the leader size
    For Each dimension As OrdinateDimension In oSheet.DrawingDimensions.cast(Of DrawingDimension).Where(Function(x) x.Type = 117484800)
     	Dim oLeaderPoints As ObjectCollection
			oLeaderPoints = oGetCol(dimension,symbolAbstand) 
	
		Dim oSymbol As SketchedSymbol
		Dim oSymbolDef As SketchedSymbolDefinition
		Dim oSymbolDefName As String		
		If dimension.DimensionType = Inventor.DimensionTypeEnum.kHorizontalDimensionType Then
			oSymbolDefName=oSymbol_Rechts
		Else
			oSymbolDefName=oSymbol_Links
		End If
		oSymbolDef = oDoc.SketchedSymbolDefinitions.Item(oSymbolDefName)
		MessageBox.Show(oLeaderPoints.Count, "oLeaderPoints,Title")

		oSymbol = oSheet.SketchedSymbols.AddWithLeader(oSymbolDef, oLeaderPoints, , , ,False,True)
		oSymbol.LeaderVisible = False
		oSymbol.LeaderClipping = False
    Next
End Sub
Function oGetCol(dimension As OrdinateDimension,symbolAbstand As Double) As ObjectCollection	
    Dim oLeaderPoints As ObjectCollection
    oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
	Dim oPoint As Point2d
	oPoint = dimension.DimensionLine.PointAtIndex(dimension.DimensionLine.PointCount)
	Dim oPoint1 As Point2d
'	oPoint1 = dimension.DimensionLine.PointAtIndex(1)
	
'	MessageBox.Show("x1=" & oPoint.X & vbLf & "y1=" & oPoint.Y & vbLf & "x2=" & oPoint1.X & vbLf & "y2=" & oPoint1.Y, "Title")



'		oPoint = dimension.JogPointTwo

	

	
	oPoint1=oPoint.Copy

	If dimension.DimensionType = Inventor.DimensionTypeEnum.kHorizontalDimensionType Then
		oPoint1.Y += symbolAbstand / 10

		oPoint1.X += 1

	Else
		oPoint1.X += symbolAbstand / 10

		oPoint1.Y-= 1
	End If
	oLeaderPoints.Add(oPoint1)
	oLeaderPoints.Add(oPoint)
    Dim oGeometryIntent As GeometryIntent
    oGeometryIntent = dimension.Parent.CreateGeometryIntent(dimension,oPoint)
    Call oLeaderPoints.Add(oGeometryIntent)
	Return oLeaderPoints
End Function

 

 

 

0 Likes
Message 12 of 18

Ivan_Sinicyn
Advocate
Advocate

I hope this comes in handy for someone in the future.

Analyzing and displaying kOrdinateDimension line points:

 

Sub Main()
    Dim drawingDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim activeSheet As Sheet = drawingDoc.ActiveSheet
    Dim transientGeom As TransientGeometry = ThisApplication.TransientGeometry

    ' Locate the first ordinate dimension on the active sheet
    Dim dimension As DrawingDimension = Nothing
    For Each dimen As DrawingDimension In activeSheet.DrawingDimensions
        If dimen.Type = 117484800 Then ' kOrdinateDimensionObject
            dimension = dimen
            Exit For
        End If
    Next

    If dimension Is Nothing Then
        MsgBox("No ordinate dimension found on the active sheet.", vbExclamation, "Error")
        Exit Sub
    End If

    ' Create a temporary sketch to display markers and bounding box
    Dim sketch As DrawingSketch = activeSheet.Sketches.Add()
    sketch.Edit()

    Dim markerRadius As Double = 0.1
    Dim dimLine As Object = dimension.DimensionLine
    Dim pointCount As Integer = dimLine.PointCount
    Dim textRange As Box2d = dimension.Text.RangeBox

    ' Declare points once at the top
    Dim startPoint As Point2d = dimLine.PointAtIndex(1)
    Dim endPoint As Point2d = dimLine.PointAtIndex(pointCount)
    Dim jogPointOne As Point2d = dimension.JogPointOne
    Dim jogPointTwo As Point2d = dimension.JogPointTwo
    Dim textOrigin As Point2d = dimension.Text.Origin

    ' Calculate and draw the bounding box encompassing the entire dimension line and text at the start
    If Not textRange Is Nothing Then
        ' Initialize min and max coordinates with start point
        Dim minX As Double = startPoint.X
        Dim minY As Double = startPoint.Y
        Dim maxX As Double = startPoint.X
        Dim maxY As Double = startPoint.Y

        ' Update bounds with end point
        If endPoint.X < minX Then minX = endPoint.X
        If endPoint.Y < minY Then minY = endPoint.Y
        If endPoint.X > maxX Then maxX = endPoint.X
        If endPoint.Y > maxY Then maxY = endPoint.Y

        ' Include JogPointOne if available
        If Not jogPointOne Is Nothing Then
            If jogPointOne.X < minX Then minX = jogPointOne.X
            If jogPointOne.Y < minY Then minY = jogPointOne.Y
            If jogPointOne.X > maxX Then maxX = jogPointOne.X
            If jogPointOne.Y > maxY Then maxY = jogPointOne.Y
        End If

        ' Include JogPointTwo if available
        If Not jogPointTwo Is Nothing Then
            If jogPointTwo.X < minX Then minX = jogPointTwo.X
            If jogPointTwo.Y < minY Then minY = jogPointTwo.Y
            If jogPointTwo.X > maxX Then maxX = jogPointTwo.X
            If jogPointTwo.Y > maxY Then maxY = jogPointTwo.Y
        End If

        ' Include text bounding box (Text.Origin is within RangeBox)
        If textRange.MinPoint.X < minX Then minX = textRange.MinPoint.X
        If textRange.MinPoint.Y < minY Then minY = textRange.MinPoint.Y
        If textRange.MaxPoint.X > maxX Then maxX = textRange.MaxPoint.X
        If textRange.MaxPoint.Y > maxY Then maxY = textRange.MaxPoint.Y

        ' Add padding to the bounding box
        Dim padding As Double = 0.2 ' Padding in centimeters
        minX = minX - padding
        minY = minY - padding
        maxX = maxX + padding
        maxY = maxY + padding

        ' Define the corners of the padded bounding box
        Dim bottomLeft As Point2d = transientGeom.CreatePoint2d(minX, minY)
        Dim topRight As Point2d = transientGeom.CreatePoint2d(maxX, maxY)

        ' Draw the dashed rectangle representing the bounding box
        Dim boundingBoxEntities As SketchEntitiesEnumerator = sketch.SketchLines.AddAsTwoPointRectangle(bottomLeft, topRight)
        For Each line As SketchLine In boundingBoxEntities
            Line.LineType = kDashedLineType ' Set to dashed line (65793)
        Next
    Else
        MsgBox("Text.RangeBox is unavailable; bounding box cannot be drawn.", vbExclamation, "Error")
    End If

    ' Mark all points using the helper subroutine
    MarkPoint(sketch, startPoint, "Start point of the dimension line marked (DimensionLine.PointAtIndex(1)).")
    If Not jogPointOne Is Nothing Then MarkPoint(sketch, jogPointOne, "JogPointOne of the ordinate dimension marked.")
    If Not jogPointTwo Is Nothing Then MarkPoint(sketch, jogPointTwo, "JogPointTwo of the ordinate dimension marked.")
    MarkPoint(sketch, endPoint, "End point of the dimension line marked (DimensionLine.PointAtIndex(PointCount)).")
    If Not textOrigin Is Nothing Then MarkPoint(sketch, textOrigin, "Text.Origin of the ordinate dimension marked.")

    ' Finalize the sketch (bounding box and markers are deleted with the sketch)
    sketch.ExitEdit()
    sketch.Delete()

    MsgBox("Analysis of available objects completed.", vbInformation, "Done")
End Sub

' Helper subroutine to mark a point with a red circle
Sub MarkPoint(sketch As DrawingSketch, point As Point2d, message As String)
    Dim markerRadius As Double = 0.1
    Dim circle As SketchCircle = sketch.SketchCircles.AddByCenterRadius(point, markerRadius)
    circle.OverrideColor = ThisApplication.TransientObjects.CreateColor(255, 0, 0) ' Red color
    MsgBox(message, vbInformation, "Object Type")
    sketch.SketchEntities.Item(sketch.SketchEntities.Count).Delete()
End Sub

 

 

INV 2025.3
Message 13 of 18

Stakin
Collaborator
Collaborator
Accepted solution

Try it,if works,let me known .

 

Rem It can be like this.
Sub Main()
    Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
    Dim oSheet As Sheet = oDoc.ActiveSheet
    Dim oTG As TransientGeometry = ThisApplication.TransientGeometry	
    Dim oSymbol_Links As String = "Höhenkoten-links"
	Dim oSymbol_Rechts As String= "Höhenkote-rechts"	
    For Each oSymbol As SketchedSymbol In oSheet.SketchedSymbols
        If oSymbol.Definition.Name=oSymbol_Links Or oSymbol.Definition.Name= oSymbol_Rechts Then
            oSymbol.Delete()
         End If
    Next    
    Dim symbolAbstand As Double =20'mm,Must >=3mm,i guess it may limitied by the leader size
    For Each dimension As OrdinateDimension In oSheet.DrawingDimensions.cast(Of DrawingDimension).Where(Function(x) x.Type = 117484800)
     	Dim oLeaderPoints As ObjectCollection
			oLeaderPoints = oGetCol(dimension,symbolAbstand) 
	
		Dim oSymbol As SketchedSymbol
		Dim oSymbolDef As SketchedSymbolDefinition
		Dim oSymbolDefName As String		
		If dimension.DimensionType = Inventor.DimensionTypeEnum.kHorizontalDimensionType Then
			oSymbolDefName=oSymbol_Rechts
		Else
			oSymbolDefName=oSymbol_Links
		End If
		oSymbolDef = oDoc.SketchedSymbolDefinitions.Item(oSymbolDefName)


		oSymbol = oSheet.SketchedSymbols.AddWithLeader(oSymbolDef, oLeaderPoints, , , ,False,True)
		oSymbol.LeaderVisible = False
		oSymbol.LeaderClipping = False
    Next
End Sub
Function oGetCol(dimension As OrdinateDimension,symbolAbstand As Double) As ObjectCollection	
    Dim oLeaderPoints As ObjectCollection
    oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
	Dim oPoint As Point2d
	oPoint = dimension.JogPointTwo	
	Dim oPoint1 As Point2d
	oPoint1 = dimension.DimensionLine.PointAtIndex(dimension.DimensionLine.PointCount)
	oLeaderPoints.Add(oPoint1)
    Dim oGeometryIntent As GeometryIntent
    oGeometryIntent = dimension.Parent.CreateGeometryIntent(dimension,oPoint)
    Call oLeaderPoints.Add(oGeometryIntent)
	Return oLeaderPoints
End Function

 

 

Message 14 of 18

Ivan_Sinicyn
Advocate
Advocate

@Stakin 
All symbols are strictly centered on the endpoint

points.png

points2.png

INV 2025.3
Message 15 of 18

Stakin
Collaborator
Collaborator

i think that's the point @Tom_BeyerFMVHA  wanted.

Is it correct?

0 Likes
Message 16 of 18

Tom_BeyerFMVHA
Contributor
Contributor

Hi Ivan, thanks for this amazing tool!

0 Likes
Message 17 of 18

Tom_BeyerFMVHA
Contributor
Contributor

Hi Stakin, yes thats it. Thank you

0 Likes
Message 18 of 18

Stakin
Collaborator
Collaborator

Nice tool,Maybe use Box2d.Extend can simply the code,try it

 

0 Likes