Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Hello @SachinRane,

 

Try the below VBA code to add ModelSurfaceTextureSymbols and ModelLeaderNote.

 

Sub Main()

    Dim doc As PartDocument
    Set doc = ThisApplication.ActiveDocument
    
    Dim oDef As PartComponentDefinition
    Set oDef = doc.ComponentDefinition
    
    Dim oFace As Face
    Set oFace = ThisApplication.CommandManager.Pick(kPartFaceFilter, "Select a face to add leader point")
    
    Dim oAnnotationPlaneDef As AnnotationPlaneDefinition
    Set oAnnotationPlaneDef = oDef.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(oFace)
    
    ' Set a reference to the TransientGeometry object.
    Dim oTG As TransientGeometry
    Set oTG = ThisApplication.TransientGeometry

    Dim oSurfacePoints As ObjectCollection
    Set oSurfacePoints = ThisApplication.TransientObjects.CreateObjectCollection

    ' Create a few leader points.
    Call oSurfacePoints.Add(oTG.CreatePoint(10, 15, 0))
    
    Dim oIntent As GeometryIntent
    Set oIntent = oDef.CreateGeometryIntent(oFace)
    
    Call oSurfacePoints.Add(oIntent)
    
    Dim oSurfaceTexDef As ModelSurfaceTextureSymbolDefinition
    Set oSurfaceTexDef = oDef.ModelAnnotations.ModelSurfaceTextureSymbols.CreateDefinition(oSurfacePoints, oAnnotationPlaneDef)
    
    Dim oSurfaceTexture As ModelSurfaceTextureSymbol
    Set oSurfaceTexture = oDef.ModelAnnotations.ModelSurfaceTextureSymbols.Add(oSurfaceTexDef)
    
    Dim oLeaderPoints As ObjectCollection
    Set oLeaderPoints = ThisApplication.TransientObjects.CreateObjectCollection

    ' Create a few leader points.
    Call oLeaderPoints.Add(oTG.CreatePoint(5, 10, 0))
    
    Dim oLeaderIntent As GeometryIntent
    Set oLeaderIntent = oDef.CreateGeometryIntent(oFace)
    
    Call oLeaderPoints.Add(oLeaderIntent)
    
    Dim oLeaderDef As ModelLeaderNoteDefinition
    Set oLeaderDef = oDef.ModelAnnotations.ModelLeaderNotes.CreateDefinition(oLeaderPoints, "Sample", oAnnotationPlaneDef)
    
    Dim oLeader As ModelLeaderNote
    Set oLeader = oDef.ModelAnnotations.ModelLeaderNotes.Add(oLeaderDef)
    
End Sub

On running above code, it prompts for selection of face as shown below.

 

Face_Selection.png

 

After selection of face, sample ModelSurfaceTextureSymbol and ModelLeaderNote are added at different location as shown below.

 

Result.png

 

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Kudo".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network