841x
004326
2020-01-31

Pregunta

¿Cómo puedo crear un comentario a través de la interfaz COM?


Respuesta:
Al utilizar la interfaz COM (RF-COM o RS-COM), puede crear un comentario utilizando la interfaz de objetos auxiliares "IGuideObjects". El siguiente es un programa de ejemplo que crea un comentario:

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
iModel.GetApplication.UnlockLicense

End Sub

La selección de la referencia o el elemento al que se refiere el comentario se define primero por el tipo (ObjectType). Aquí, es posible seleccionar, por ejemplo, una barra, un nudo o cualquier punto en el espacio. A continuación, el número del objeto de referencia se especifica mediante ObjectNo (por ejemplo, Barra 1). Si ha seleccionado un punto libre, se establece por Punto.
Finalmente, puede especificar un desplazamiento que resulta del objeto de referencia.