03-28-2018
03:01 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
03-28-2018
03:01 AM
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.
After selection of face, sample ModelSurfaceTextureSymbol and ModelLeaderNote are added at different location as shown below.
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
