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

how to Add ModelSurfaceTextureSymbols

SachinRane
Explorer

how to Add ModelSurfaceTextureSymbols

SachinRane
Explorer
Explorer

Hi

 

I am Trying to add the Model Annotation.

 

In Model annotation I am trying to Add the ModelSurfaceTextureSymbols and LeaderNoteText How to do Create the Defination for the same.

0 Likes
Reply
Accepted solutions (4)
859 Views
7 Replies
Replies (7)

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

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



SachinRane
Explorer
Explorer

Thanks for your help in Adding ModelSurfaceTextureSymbols, I am trying to add the tolerence Feature using the ModelCompositeAnnotation or the trying to add the ModelFeatureFrame but its giving the Error. Can you Help me out

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@SachinRane,

 

Try below VBA code to add ModelFeatureControlFrame. There must be at least one row in ModelFeatureControlFrame while adding.

 

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 Model feature control frame")
    
    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 oIntent As GeometryIntent
    Set oIntent = oDef.CreateGeometryIntent(oFace)
        
    Dim oPt As Point
    Set oPt = oTG.CreatePoint(12, 15, 0)
    
    Dim oMFCFDef As ModelFeatureControlFrameDefinition
    Set oMFCFDef = oDef.ModelAnnotations.ModelFeatureControlFrames.CreateDefinition(oIntent, oAnnotationPlaneDef, oPt)

    Dim oMFCFRow As ModelFeatureControlFrameRow
    Set oMFCFRow = oMFCFDef.FeatureControlFrameRows.Add(kFlatness, 0.02)
    
    Dim oMFCF As ModelFeatureControlFrame
    Set oMFCF = oDef.ModelAnnotations.ModelFeatureControlFrames.Add(oMFCFDef)
    
    
End Sub

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



SachinRane
Explorer
Explorer
Accepted solution

Thanks For your support

 

but i am trying to add the ModelCompositeAnnotation, I Can do that

0 Likes

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@SachinRane,

 

Yes, You can use same ModelFeatureControlFrame to add a ModelCompositeAnnotation.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



SachinRane
Explorer
Explorer

I am Trying to Set the Standerd for the ModelSurfaceTexture via API, it is possible in Drafting but how to do the Same for the ModelSurfaceTextureSymbols. Figure 2 is the Required result and Figure 3 is API Result. How I can achive the Same.

 

Figure 1 is need to Set the STD. I want to set the ANSI Std for ModelSurfaceTextureSymbols

 

0 Likes

josh.nieman
Advocate
Advocate

This has been a very good teaching tool for me.  I'm having a particular issue where Inventor will crash when running this method, if a non-planar face is selected.  If, say, a cylindrical face is selected


oAnnoPlaneDef = oDoc.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(oFace)

 

Fails

and Inventor crashes.

I have tried instead using kAllPlanarEntities instead, but that similarly failed.

What would be the best route to constrain the user to selecting only valid planar faces, or being able to handle a nonplanar face selection?

Thanks in advance.

IMPORTANT EDIT
I'm working in an assembly environment, rather than part.  Trying to add ModelLeaderNotes

0 Likes