LISP to change attribute text from backwards to normal

aridzv
edited December 2021 in LISP
EDIT: I've found my error,correction in the code below.
Hi.
I have a LSP that change some attribute properties (Height & rotation).
I'm trying to write a pice of code inside that lsp to make sure that the tag text is not set to backwards,but the code is wrong...
I need help with making it work...
here is the LSP,the line that I've added are bolded, and I also added a screenshot to show the backwards option that I want to change:


(defun c:chatht180 ( / ta an bent bent2 pt lay tagname ss bname x att temp)

(setq tagname "ORDER")

(setq ss (ssget (list (cons 0 "INSERT"))))

(setq ht (getreal "\nEnter text height<24>: "))

(if
(= ht nil)
(setq ht 24)
)

(setq an (getreal "\nEnter Rotation<0>: "))

(if
(= an nil)
(setq an 0)
)

(setq tagname (strcase (getstring "\nAttribute tag specification: ")))

(if
(= tagname "")
(setq tagname "ORDER")
)

(setq an (/ (* an pi) 180))

(repeat (setq x (sslength ss))
(setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) ))))
(if (= (vla-get-hasattributes obj) :vlax-true)
(foreach att (vlax-invoke obj 'getattributes)
(if (= tagname (strcase (vla-get-tagstring att)))
(PROGN
(vla-put-Rotation att an)
(vla-put-height att ht)
if (= (vlax-get-property att 'Backward) :vlax-true)
(vlax-put-property att 'Backward :vlax-false)

)
)
)
)
)

(princ)
)

Comments

  • Parenthesis are missing around the highlighted if expression.
  • aridzv
    edited December 2021

    Parenthesis are missing around the highlighted if expression.

    (defun c:chatht15 ( / ta an bent bent2 pt lay tagname ss bname x att temp)

    (setq tagname "ORDER")

    (setq ss (ssget (list (cons 0 "INSERT"))))

    (setq ht (getreal "\nEnter text height<24>: "))

    (if
    (= ht nil)
    (setq ht 24)
    )

    (setq an (getreal "\nEnter Rotation<0>: "))

    (if
    (= an nil)
    (setq an 0)
    )

    (setq tagname (strcase (getstring "\nAttribute tag specification: ")))

    (if
    (= tagname "")
    (setq tagname "ORDER")
    )

    (setq an (/ (* an pi) 180))

    (repeat (setq x (sslength ss))
    (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) ))))
    (if (= (vla-get-hasattributes obj) :vlax-true)
    (foreach att (vlax-invoke obj 'getattributes)
    (if (= tagname (strcase (vla-get-tagstring att)))
    (PROGN
    (vla-put-Rotation att an)
    (vla-put-height att ht)
    if (= (vlax-get-property att 'Backward) :vlax-true)
    (vlax-put-property att 'Backward :vlax-false)

    if (= (vlax-get-property att 'UpsideDown) :vlax-true)
    (vlax-put-property att 'UpsideDown :vlax-false)
    )
    )
    )
    )
    )

    (princ)
    )

    that's the code that runs..
  • Dear Arid,
    as Roy mentioned : you forgot the opening parenthesis in
    "if ....

    I attached the fixed code here (did nto try yet), but looks it should work now :-)
    many greetings !
  • aridzv
    edited December 2021

    Dear Arid,
    as Roy mentioned : you forgot the opening parenthesis in
    "if ....

    I attached the fixed code here (did nto try yet), but looks it should work now :-)
    many greetings !

    first - Thanks, and happy new year!
    strange,but the original code dose work on my machine... :)
    EDIT:
    O.K.
    I see What causes the confusion....
    Original Code:

    if (= (vlax-get-property att 'Backward) :vlax-true)
    (vlax-put-property att 'Backward :vlax-false)

    Torsten Code:

    (if (= (vlax-get-property att 'Backward) :vlax-true)
    (vlax-put-property att 'Backward :vlax-false)
    )
    maybe the "If" statment opening and closing parenthesis are redundant?...
    because the code runs well with out them...
  • aridzv
    edited December 2021
    And if we're already here ...
    Here is another variation on the same LSP that does automatic numbering of the selected attributes.
    I would love any correction or ideas for improvement.
    Thanks...
  • > maybe the "If" statment opening and closing parenthesis are redundant?...
    because the code runs well with out them...

    because of missing ( and ) for the "if" statement, the 2 next statements were both processed unconditionally :-)
    but *any* statement in Lisp starts with a ( bracket ... and therefore also ends with a ) bracket, that is the definition :-)

    Will have a look at your "Num_Order.lsp" next ...
    many greetings !
  • > maybe the "If" statment opening and closing parenthesis are redundant?...
    because the code runs well with out them...

    because of missing ( and ) for the "if" statement, the 2 next statements were both processed unconditionally :-)
    but *any* statement in Lisp starts with a ( bracket ... and therefore also ends with a ) bracket, that is the definition :-)

    Understood,Changed - THANKS!! B)

    >Will have a look at your "Num_Order.lsp" next ...
    many greetings !

    Thanks!!
    Ari.