865x
004326
2020-01-31

Creating Comment via COM Interface

How can I create a comment via the COM interface?


Answer:

When using the COM interface (RF‑COM or RS‑COM), you can create a comment using the guide object interface IGuideObjects. The following is an example program that creates a comment:

Sub test_comment()

'   get interface from the opened model and lock the licence/program
    Dim iModel As RFEM5.IModel3
    Set iModel = GetObject(, "RFEM5.Model")
    iModel.GetApplication.LockLicense

On Error GoTo e
    
    Dim iModelData As RFEM5.IModelData2
    Set iModelData = iModel.GetModelData
    
    Dim iGuiObj As RFEM5.IGuideObjects
    Set iGuiObj = iModel.GetGuideObjects
    
    Dim comm As RFEM5.Comment
    
    '   set frame type
    comm.Frame = CircularFrameType
    
    '   set reference object type
    comm.ObjectType = GeneralObjectType
    comm.ObjectNo = 1
    
    '   set point if GeneralObjectType is choosen
    comm.Point.X = 2
    comm.Point.Y = 4
    comm.Point.Z = 6
    
    '   set offset from reference object
    comm.Offset.X = 0.5
    comm.Offset.Y = 1
    comm.Offset.Z = 1.5
    comm.Rotation = 1
    
    '   set text of comment
    comm.Text = "testcomment"
    
    '   transfer object to program
    iGuiObj.PrepareModification
    iGuiObj.SetComment comm
    iGuiObj.FinishModification
    
e:  If Err.Number <> 0 Then MsgBox Err.Description, , Err.Source
    
    Set iModelData = Nothing
    iModel.GetApplication.UnlockLicense
    Set iModel = Nothing

End Sub

The selection of the reference or the element to which the comment is referred is defined by the type (ObjectType) first. Here it is possible to select, for example, a member, a node, or any point in space. Next, the number of the reference object is specified via ObjectNo (for example, Member 1). If you have selected a free point, it is set by Point.

Finally, you can specify an offset that results from the reference object.


Author

Mr. Günthel provides technical support for our customers.

Links
Downloads


;