In a PartDocument, ModelFeatureControlFrame is added through Inventor API by creating of definition of ModelFeatureControlFrameDefinition. Along with definition, at least one ModelFeatureControlFrameRow should be added to ModelFeatureControlFrameDefinition. Otherwise, ModelFeatureControlFrame.Add() method failed to generate ModelFeatureControlFrame.
Usually, ModelFeatureControlFrameDefinition are defined with geometry intent, Annotation Plane definition and Point to locate ModelFeatureControlFrameRow.
To demonstrate this, a sample part can be downloaded from this link
After downloading the part, open the same part in Inventor. Copy and paste below VBA code in VBA editor.
VBA code:
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
On successful running code, a prompt will pop up which is looking for face selection as shown below image.
Output:
Try below VBA code to add ModelGeneralNote into PartDocument.
Sub ModelGeneralNote()
Dim oDoc As PartDocument
Set oDoc = ThisApplication.ActiveDocument
Dim oDef As PartComponentDefinition
Set oDef = oDoc.ComponentDefinition
Dim oDescription As String
oDescription = "<StyleOverride><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>DESCRIPTION</Property></StyleOverride>"
Dim oTitle As String
oTitle = "<StyleOverride><Property Document='model' PropertySet='Inventor Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>TITLE</Property></StyleOverride>"
Dim oText As String
oText = oDescription & oTitle
Dim oModeldef As ModelGeneralNoteDefinition
Set oModeldef = oDef.ModelAnnotations.ModelGeneralNotes.CreateDefinition(oText, True)
Dim oNote As ModelGeneralNote
Set oNote = oDef.ModelAnnotations.ModelGeneralNotes.Add(oModeldef)
End Sub