Code:
Function AddSurfaceTextureSymbol(sRa As String) As Boolean
AddSurfaceTextureSymbol = False
' Set a reference to the drawing document.
' This assumes a drawing document is active.
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument ' Set a reference to the active sheet.
Dim oActiveSheet As Sheet
Set oActiveSheet = oDrawDoc.ActiveSheet
Dim obj As Object
For Each obj In oDrawDoc.SelectSet
If Not TypeOf obj Is DrawingCurveSegment Then
MsgBox "Es dürfen nur Kanten ausgewählt werden!"
Exit Function
End If
' Get the mid point of the first extension line of the dimension
Dim oMidPoint As Point2d
If obj.Parent.CurveType = kLineCurve Then
Set oMidPoint = obj.Parent.MidPoint
ElseIf obj.Parent.CurveType = kCircleCurve Then
Set oMidPoint = obj.Parent.CenterPoint
Else
Set oMidPoint = obj.Parent.StartPoint
End If
' Set a reference to the TransientGeometry object.
Dim oTG As TransientGeometry
Set oTG = ThisApplication.TransientGeometry
Dim oLeaderPoints As ObjectCollection
Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection
' Create a few leader points.
'Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 10))
'Call oLeaderPoints.Add(oTG.CreatePoint2d(oMidPoint.X + 10, oMidPoint.Y + 5))
' Create an intent and add to the leader points collection.
' This is the geometry that the symbol will attach to.
Dim oGeometryIntent As GeometryIntent
Set oGeometryIntent = oActiveSheet.CreateGeometryIntent(obj.Parent, kMidPointIntent)
Call oLeaderPoints.Add(oGeometryIntent)
' Create the symbol with a leader
Dim oSymbol As SurfaceTextureSymbol
If sRa = "Ra6,4" Then
Set oSymbol = oActiveSheet.SurfaceTextureSymbols.Add(oLeaderPoints, kBasicSurfaceType, False, False, , (sRa), , , , , , False)
ElseIf sRa = "Ra25" Then
Set oSymbol = oActiveSheet.SurfaceTextureSymbols.Add(oLeaderPoints, kBasicSurfaceType, False, False, , (sRa), , , , , , False)
Else
Set oSymbol = oActiveSheet.SurfaceTextureSymbols.Add(oLeaderPoints, kMaterialRemovalProhibitedSurfaceType, False, False, , , , , , , , False)
End If
AddSurfaceTextureSymbol = True
Next
Debug.Print "ErrNr.:" & Err.Number & " - Desc.: " & Err.Description
End Function