Vla-put-Justify

Discussion in 'AutoCAD' started by Adesu, Sep 15, 2004.

  1. Adesu

    Adesu Guest

    ; at is stand for align text
    ; Design by Ade Suharna
    ; 15 September 2004
    ; idea from BillZ <>9/10/2004
    ; edit by

    (defun c:at (/ ent opt)
    (vl-load-com)
    (setq ent1 (vlax-ename->vla-object (car (entsel "\nSELECT TEXT: "))))
    (prompt "LEFT=0 CENTER=1 RIGHT=2 ALIGN=3 MIDDLE=4 FIT=5")
    (setq opt (fix (getreal "\nENTER NUMBER FOR TEXT ALIGN: ")))
    (vla-put-Justify ent1 opt)
    (princ)
    )

    I've got idea from BillZ,to change align text by use vla function,my code
    not yet work,I don't know what wrong this program,can you help me to correct
    it,thanks.
     
    Adesu, Sep 15, 2004
    #1
  2. Adesu

    Adesu Guest

    (vla-put-linetypescale ent1 opt) >>>>vla-put-linetypescale displayed
    bluecolor
    (vla-put-Justify ent1 opt) >>>>vla-put-Justify displayed
    blackcolor

    Is it not match if text ( vla-put-Justify displayed blackcolor) ??
     
    Adesu, Sep 15, 2004
    #2
  3. Adesu

    Jeff Mishler Guest

    Ade,
    Try this....

    Code:
    ; at is stand for align text
    ;       Design by Ade Suharna
    ;       15 September 2004
    ;       idea from BillZ <>9/10/2004
    ;       edit by
    
    (defun c:at (/ ent opt)
    (vl-load-com)
    ;(setq ent1 (vlax-ename->vla-object (car (entsel "\nSELECT TEXT: "))))
    ;use SelectionSet to ensure ONLY text is selected
    (prompt "\nSELECT TEXT: ")
    (if (setq ss (ssget '((0 . "TEXT"))))
    (progn
    (prompt "LEFT=0 CENTER=1 RIGHT=2 ALIGN=3 MIDDLE=4 FIT=5")
    (setq opt (getint "\nENTER NUMBER FOR TEXT ALIGN: "))
    (setq index -1)
    (while (< (setq index (1+ index)) (sslength ss))
    (setq ent1 (vlax-ename->vla-object (ssname ss index)))
    (if (not (= (vla-get-alignment ent1) 0))
    (setq alPnt (vla-get-textalignmentpoint ent1))
    (setq alPnt nil)
    )
    (setq insPnt (vla-get-insertionpoint ent1))
    (vla-put-alignment ent1 opt)
    (if (not alPnt)
    (vla-put-textalignmentpoint ent1 insPnt)
    )
    );while
    );progn
    );if
    ;(vla-put-Justify ent1 opt)-there is no "Justify, use "Alignment"
    (princ)
    )
    
     
    Jeff Mishler, Sep 15, 2004
    #3
  4. Adesu

    Adesu Guest

    Hi Jeff,your code it work,thanks a lot,and how /where you find
    "textalignmentpoint",is it in properties or others ??

     
    Adesu, Sep 15, 2004
    #4
  5. Adesu

    Adesu Guest

    Hi Jeff,now it work,we change (vla-put-Justify ent1 opt) to
    (vla-put-alignment ent1 opt)


    ; at is stand for align text
    ; Design by Ade Suharna
    ; 15 September 2004
    ; idea from BillZ
    ; edit by

    (defun c:at (/ ent opt)
    (vl-load-com)
    (setq ent1 (vlax-ename->vla-object (car (entsel "\nSELECT TEXT: "))))
    (prompt "LEFT=0 CENTER=1 RIGHT=2 ALIGN=3 MIDLE=4 FIT=5")
    (setq opt (fix (getreal "\nENTER NUMBER FOR TEXT ALIGN: ")))
    (vla-put-alignment ent1 opt)
    (princ)
    )
     
    Adesu, Sep 15, 2004
    #5
  6. Adesu

    Jeff Mishler Guest

    You want to be careful of how you do this though. I see a few things that
    will crash the routine.
    1. (setq ent1 (vlax-ename->vla-object (car (entsel "\nSELECT TEXT: "))))
    This will crash if nothing is selected
    2. (vla-put-alignment ent1 opt) this will crash if ent1 is not a text,
    attribute, or attribute reference
    These 2 reasons are why I showed using a selection set in an if statement
    3. Although it won't cause a crash: Why ask for a real (getreal) when you
    want an integer? (getint) would work better for this.....

    To answer your question from the other post, check out the properties for
    the Text object as listed by (vlax-dump-object):
    Those with a (RO) are read-only....
    Command: DUMP

    Select entity to get object data: ; IAcadText: AutoCAD Text Interface
    ; Property values:
    ; Alignment = 1
    ; Application (RO) = #<VLA-OBJECT IAcadApplication 00a8a730>
    ; Backward = 0
    ; Color = 256
    ; Document (RO) = #<VLA-OBJECT IAcadDocument 0107559c>
    ; Handle (RO) = "C03B"
    ; HasExtensionDictionary (RO) = 0
    ; Height = 2.4
    ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 0a513804>
    ; InsertionPoint = (5237.01 4412.89 0.0)
    ; Layer = "SUR-TEXT"
    ; Linetype = "BYLAYER"
    ; LinetypeScale = 1.0
    ; Lineweight = -1
    ; Normal = (0.0 0.0 1.0)
    ; ObjectID (RO) = 1074763480
    ; ObjectName (RO) = "AcDbText"
    ; ObliqueAngle = 0.0
    ; OwnerID (RO) = 1074531512
    ; PlotStyleName = "ByLayer"
    ; Rotation = 0.0
    ; ScaleFactor = 1.0
    ; StyleName = "SHADOW-SM"
    ; TextAlignmentPoint = (5244.35 4412.89 0.0)
    ; TextGenerationFlag = 0
    ; TextString = "HUNTER"
    ; Thickness = 0.0
    ; UpsideDown = 0
    ; Visible = -1
     
    Jeff Mishler, Sep 15, 2004
    #6
  7. Adesu

    Adesu Guest

    _$ (setq aa (vlax-get-acad-object))
    #<VLA-OBJECT IAcadApplication 00ac8928>
    _$ (vlax-dump-object aa)
    ; IAcadApplication: An instance of the AutoCAD application
    ; Property values:
    ; ActiveDocument = #<VLA-OBJECT IAcadDocument 00eb0f84>
    ; Application (RO) = #<VLA-OBJECT IAcadApplication 00ac8928>
    ; Caption (RO) = "AutoCAD 2000 - [Drawing1.dwg]"
    ; Documents (RO) = #<VLA-OBJECT IAcadDocuments 01ab4390>
    ; FullName (RO) = "C:\\AUTO CAD 2000\\ACAD.EXE"
    ; Height = 570
    ; LocaleId (RO) = 1033
    ; MenuBar (RO) = #<VLA-OBJECT IAcadMenuBar 01ab4374>
    ; MenuGroups (RO) = #<VLA-OBJECT IAcadMenuGroups 00d789c4>
    ; Name (RO) = "AutoCAD"
    ; Path (RO) = "C:\\AUTO CAD 2000"
    ; Preferences (RO) = #<VLA-OBJECT IAcadPreferences 01ab0c2c>
    ; StatusId (RO) = ...Indexed contents not shown...
    ; VBE (RO) = #<VLA-OBJECT VBE 02a3163c>
    ; Version (RO) = "15.0"
    ; Visible = -1
    ; Width = 796
    ; WindowLeft = 2
    ; WindowState = 1
    ; WindowTop = 2
    T
    _$

    Huh.....I'm not yet going to there
     
    Adesu, Sep 15, 2004
    #7
  8. Adesu

    Jeff Mishler Guest

    Ade,
    Here's a little code that I use to dump the properties and methods of any
    graphical entity. It may help you, I know it did/does help me.

    Code:
    ;for listing an objects properties
    (defun C:DUMP ( / ent obj)
    (while (setq ent (entsel "\nSelect entity to get object data: "))
    (setq obj (vlax-ename->vla-object (car ent)))
    (vlax-dump-object obj)
    (vlax-release-object obj)
    (princ)
    )
    (princ)
    )
    
    ;for listing an objects properties and methods
    (defun C:DUMPT ( / ent obj)
    (while (setq ent (entsel "\nSelect entity to get object data: "))
    (setq obj (vlax-ename->vla-object (car ent)))
    (vlax-dump-object obj T);added T to return methods available
    (vlax-release-object obj)
    (princ)
    )
    (princ)
    )
    
    --
    Jeff
    check out www.cadvault.com
     
    Jeff Mishler, Sep 15, 2004
    #8
  9. Adesu

    Adesu Guest

    Hi Jeff,thanks a lot for your help,now I rather understand .
     
    Adesu, Sep 15, 2004
    #9
  10. Adesu

    zeha Guest

    Adesu,

    Just curious,

    Why not the standard autocad justifytext
    This also works for attributes and Mtext

    Cheers

    Harrie
     
    zeha, Sep 15, 2004
    #10
  11. Adesu

    Tom Smith Guest

    I wondered the same thing. This seems like a duplication of a built-in
    command, except that it offers fewer choices and has a less friendly
    interface.
     
    Tom Smith, Sep 15, 2004
    #11
  12. Adesu

    John Uhden Guest

    You guys might find the attached fun.




     
    John Uhden, Sep 16, 2004
    #12
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.