View Full Version : Mirror a Block
mtubbs
2008-02-28, 04:06 PM
I am trying to create a lisp to insert a block "cont-tag2" at the current drawing scale on layer "g-symbol". I also want to prompt the user to mirror the block. I'm hitting some kind of snag. Help!
(setq scafac (getvar "dimscale"))
(setq pnt (getpoint "\nPick Insertion Point: "))
(command "-layer" "m" "g-symbol" "c" "6" "" "")
(command "-insert" "R:/standard/symbols/general/cont-tag2" pnt scafac "" "")(mirror_block)
;;mirror block
(defun mirror_block ()
(initget "Y N"
(setq mirrblk (getreal
"\nMirror the block Y or <N>: "
)
)
(if (eq mirrblk "Y")
(command "mirror" (entlast) "" "@" "@1<90" "yes")
)
(if (eq mirrblk "y")
(command "mirror" (entlast) "" "@" "@1<90" "Yes")
)
)
Moderator Note:
How to use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)
Change getreal to getstring for your mirrblk variable. Also, you can make a check one time after you get the string if you convert the string to the desired case prior to evaluating it.
mtubbs
2008-02-28, 04:58 PM
Change getreal to getstring for your mirrblk variable. Also, you can make a check one time after you get the string if you convert the string to the desired case prior to evaluating it.
I changed it to getstring, but had no success, I am getting this error:
; error: no function definition: MIRROR_BLOCK
Move the MIRROR_BLOCK definition to above the other code. It must be defined before you can call it.
mtubbs
2008-02-28, 07:27 PM
Move the MIRROR_BLOCK definition to above the other code. It must be defined before you can call it.
Now I get this error:
Mirror the block Y or <N>: Y
; error: bad argument type: fixnump: "Y"
FRAMEDNLV
2008-02-29, 01:47 AM
(initget 1 "Yes No")
(setq xxxxx (getkword "Do you want yes or no? (<Yes> or No) "))
(if (eq xxxxx"Yes")
(progn
(print xxxxx );<your command here
);end of progn
);end of "Y"
I found some information in the help section.
Chris
azarko
2008-02-29, 10:06 AM
Try it
(defun C:TEST ( / att attr *error* oldEcho mirrblk scafac)
(defun *error* (msg)(princ msg)(setvar "CMDECHO" oldEcho)(setvar "ATTDIA" att)(setvar "ATTREQ" attr)(princ))
(setq att (getvar "ATTDIA")
attr (getvar "ATTREQ")
oldEcho (getvar "CMDECHO")
); end setq
(setvar "ATTDIA" 0)(setvar "ATTREQ" 0)(setvar "CMDECHO" 0)
(initget "Yes No")
(setq mirrblk (getkword "\nMirror the block [Yes/No] <No>: "))
(setq scafac (getvar "dimscale"))
(setvar "CMDECHO" 0)
(princ "\nPick Insertion Point: ")
(command "_-insert"
"R:/standard/symbols/general/cont-tag2"
"_X"
(if (= mirrblk "Yes")(- 0 scafac) scafac) ;_Negative scale mirror from the Y axis
"_Y"
scafac
"_Z"
scafac
pause ;_whait insertion point
)
(princ "\nAngle of rotation: ")
(command pause) ;_whait angle of rotation
(setvar "CMDECHO" oldEcho)
(setvar "ATTDIA" att)
(setvar "ATTREQ" attr)
(princ)
)
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.