Changing text alignment.

Discussion in 'AutoCAD' started by Bob, Jan 6, 2005.

  1. Bob

    Bob Guest

    Hey group, here's one for ya.

    Using VLISP and ActiveX I have opened a second acad dwg document and created
    some a text object. I am able to change this object's properties (layer,
    color, text height, and alignment), but not able to see the results of
    changing the object's alignment. (layer, color and height update)

    So, how can I get my text alignment to update?

    Here is my code:


    (setq ACADObject (vlax-get-acad-object)
    ACADCollection (vlax-get-property ACADObject 'Documents)
    NewDoc (vlax-invoke-method ACADCollection 'Add)
    CModelSpace (vlax-get-property NewDoc 'ModelSpace)
    LayerCollection (vlax-get-property NewDoc 'Layers)
    testLayer (vla-add LayerCollection "testing")
    );setq


    (setq InPt (list 50 50 0)
    TxtHt 20
    TxtStr "Hello World!"
    TxtObj (vla-addtext CModelSpace TxtStr (vlax-3D-point InPt) TxtHt)
    );setq


    (vla-put-layer TxtObj "testing")
    (vla-put-color TxtObj acred)
    (vla-put-height TxtObj 1)
    (vla-put-alignment TxtObj acAlignmentCenter)
     
    Bob, Jan 6, 2005
    #1
  2. Bob

    T.Willey Guest

    When text has an alignment of left then it is place by the InsertionPoint properity, but if it is anything else, then it is placed by the TextAlignmentPoint.

    So try changing the TextAlignmentPoint the the InsertionPoint value when going from left aligned to anything else, and vice versa for going from any alignment other then left to left.

    Hope that helped.
    Tim
     
    T.Willey, Jan 6, 2005
    #2
  3. Bob

    Bob Guest

    Tim,

    Thanks for the response. Still not working. Possibly I'm doing something
    wrong. Here's my code.

    When I check the properties of the text object it shows the alignment as
    Center. But it isn't aligned center. If I change it using normal ACAD
    commands to say Right, then it changes the way I would expect it to. If I
    then change the alignment using normal ACAD commands back to Center the text
    updates as it should. How can I force it to update?

    (setq ACADObject (vlax-get-acad-object)
    ACADCollection (vlax-get-property ACADObject 'Documents)
    NewDoc (vlax-invoke-method ACADCollection 'Add)
    CModelSpace (vlax-get-property NewDoc 'ModelSpace)
    LayerCollection (vlax-get-property NewDoc 'Layers)
    testLayer (vla-add LayerCollection "testing")
    );setq


    (setq InPt (list 50 50 0)
    TxtHt 20
    TxtStr "Hello World!"
    TxtObj (vla-addtext CModelSpace TxtStr (vlax-3D-point InPt) TxtHt)
    );setq

    (vla-put-alignment TxtObj acAlignmentCenter)
    (vla-put-textalignmentpoint TxtObj (vlax-3D-point InPt))
    (vla-put-alignment TxtObj acAlignmentCenter)
    (vla-update TxtObj)
     
    Bob, Jan 6, 2005
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.