Place Text through VBA

Hi all,

Trying to work out how to place a predefined text string onto the drawing, without bring up any menus or options.

Have tried

    CadInputQueue.SendKeyin "place text"
CadInputQueue.SendKeyin sText

But the keyin window appears and i cant work out how to close it.

Also have tried
    CadInputQueue.SendKeyin "place dialogtext icon"
CadInputQueue.SendMessageToApplication "WORDPROC", sText

Which brings up the word processor but doesn't input the text.

Ideally i'd like to simple click a button on a form and the text appears on the drawing at the cursor ready for the user to select the location.

Cheers,

Rob

Parents Reply Children
  • dim text as string                  ' text string

    dim rotmatrix as matrix3d     ' text rotation

    dim p1 as point3d                  ' textt origin

    RotMatrix = Matrix3dFromAxisAndRotationAngle(2, 0)

    Set Text = CreateTextElement1(Nothing, "text to be written, P1, RotMatrix)

    ActiveModelReference.AddElement Testo

    Thanks, blumax, this helped me out a lot, but I'd like to submit a correction and expansion to this like so:

    dim text as TextElement
    dim RotMatrix as Matrix3d
    dim p1 as Point3d
    
    ' insert your own code to specify location of p1 based on your needs
    RotMatrix = Matrix3dFromAxisAndRotationAngle(2, 0)
    
    Set text = CreateTextElement1(Nothing, "your text, or a variable string", p1, RotMatrix)
    ' now you can set graphic group or any other properties you like, for example:
    text.graphicGroup = 15
    
    ActiveModelReference.AddElement text