LISP to change attribute text from backwards to normal
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)
)
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)
)
0
Comments
-
Parenthesis are missing around the highlighted
if
expression.0 -
(defun c:chatht15 ( / ta an bent bent2 pt lay tagname ss bname x att temp)Roy Klein Gebbinck said:Parenthesis are missing around the highlighted
if
expression.
(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..0 -
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 !0 -
first - Thanks, and happy new year!Torsten Moses said: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 !
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...0 -
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...
0 -
> 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 !0 -
Understood,Changed - THANKS!!Torsten Moses said:> 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 :-)
Thanks!!Torsten Moses said:>Will have a look at your "Num_Order.lsp" next ...
many greetings !
Ari.
0