TheSwamp
CAD Forums => CAD General => Topic started by: hudster on January 19, 2004, 10:28:18 AM
-
I use scripts a lot, i don't know how to write lisp programs, and i always get stuck when it comes to user inputs.
i.e. i wish to rotate an attribute value in a rotated block so that the text is rotated to zero, everything in the script goes well until it comes to the select block part, then it pauses, i click on the block and have to type 'resume to get the script going again.
is there an easier way to do this?
Oh while I'm here, can anyone recommend a good book or website which will show me how to write lisp routines as it's getting to the point where it's becoming necessary that i learn how to do it.
cheers :twisted:
-
Oh while I'm here, can anyone recommend a good book or website which will show me how to write lisp routines as it's getting to the point where it's becoming necessary that i learn how to do it.
Website www.smadsen.com
book: Start at the library.
-
i.e. i wish to rotate an attribute value in a rotated block so that the text is rotated to zero, everything in the script goes well until it comes to the select block part, then it pauses, i click on the block and have to type 'resume to get the script going again.
Here ya go Hudster, this should do what your trying to accomplish:
(defun c:rot_attr (/ cmd txt index a1 a2 a2a a3 check_att att_name1);;Rotate all selected blocks attributes to zero
(setq cmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(prompt "\nSelect blocks to rotate attributes: ")
(setq a1 (ssget '((0 . "INSERT"))))
(setq index 0)
(repeat (sslength a1);;Counts how many blocks were selected and repeats that many times
(setq a2 (entget (ssname a1 index)));;gets first list from block
(setq a3 (entget(entnext(cdr(assoc -1 a2)))));;gets sub-list from same block
(setq check_att (cdr(assoc 0 a3)));;checks to make sure this block has attributes
(if (= check_att "ATTRIB");;if the block does have attributes
(progn;;then
(while (/= check_att "SEQEND");;this makes sure the block hasn't reached the sequence end
(setq att_name1 (cdr(assoc -1 a3)));;gets the name of the block/attribute
(command "attedit" "" "" "" "" att_name1 "a" "0" "");;rotates attribute to zero
(setq a3 (entget(entnext(cdr(assoc -1 a3)))));;goes to the next attribute in the block
(setq check_att (cdr(assoc 0 a3)));;extracts out whether its "ATTRIB" or "SEQEND"
;; It keeps looping until all attributes have been extracted and rotated then goes to the
;; next selected block and repeats the entire process
);;end while
);;end progn
);;end if
(setq index (+ index 1))
);;end repeat
(setvar "CMDECHO" cmd)
(princ);;clear the command line
);;end defun rot_attr
-
Website www.smadesen.com
book: Start at the library.
That's www.smadsen.com. Thanks for the recommendation, Daron. I'd recommend AfraLisp (http://www.afralisp.com/) any time, though! :)
-
Cheers
www.smadesen.com
All I get on this site is a "Page cannot be displayed" message.
-
Typo in URL - look in above post
-
Sorry Stig. I should check my spelling.
-
I've done a bit of checking and user input is possible using a macro function.
If you type \ the macro pauses to allow you to select an item.
So my original query about rotating attributes to zero can be solved by using this macro command
^C^C-attedit;Y;;;;\;a;0;;