Wesley_Amsterda 发表于 2022-7-5 23:25:22

LISP-routine does weird things

Hi all,
 
I have a weird problem with a LISP i wrote.
 
Please see attached files.
 
I want to draw shadowlines on a round column using the .lsp file.
Attached pdf file shows what I want.
 
If I run the routine it mixes up the lines.
 
But if I paste the commands (command "LINE" k1a k4a "") to draw the lines in autocad it works fine.
 
This was just a quick program because I was in a hurry.

(DEFUN C:colmunshadow () (setq scmde (getvar "CMDECHO")) (setq sblip (getvar "BLIPMODE")) (setvar "CMDECHO" 0) (setq magneet (getvar "osmode")) (setq fout *error*) (setq *error* fout2) ;(command "undo" "m")(DEFUN DTR(A)(* PI(/ A 180.0)))(COMMAND "-layer" "t" "x-layer" "")(command "-layer" "m" "x-layer" "c" "1" "" "") (command "-osnap" "end") (setq p1 (getpoint "\nSelect bottomleft corner....")) (setq p2 (getpoint "\nselect bottomright corner....")) (setq p3 (getpoint "\nSelect topright corner....")) (setq p4 (getpoint "\nselect topleft corner...."))(setq k1aa (polar p1 0 50)   k1a (polar k1aa (dtr 90) 50)   k1bb (polar k1a 0 50)   k1b (polar k1bb (dtr 90) 50)   k1cc (polar k1b 0 50)   k1c (polar k1cc (dtr 90) 50));(setq k2aa (polar p2 PI 50)   k2a (polar k2aa (dtr 90) 50)   k2bb (polar k2a PI 50)   k2b (polar k2bb (dtr 90) 50)   k2cc (polar k2b PI 50)   k2c (polar k2cc (dtr 90) 50));(setq k3aa (polar p3 PI 50)   k3a (polar k3aa (dtr 270) 50)   k3bb (polar k3a PI 50)   k3b (polar k3bb (dtr 270) 50)   k3cc (polar k3b pi 50)   k3c (polar k3cc (dtr 270) 50));(setq k4aa (polar p4 0 50)   k4a (polar k4aa (dtr 270) 50)   k4bb (polar k4a 0 50)   k4b (polar k4bb (dtr 270) 50)   k4cc (polar k4b 0 50)   k4c (polar k4cc (dtr 270) 50));(command "LINE" k1a k4a "")(command "LINE" k1b k4b "")(command "LINE" k1c k4c "")(command "LINE" k2a k3a "")(command "LINE" k2b k3b "")(command "LINE" k2c k3c "") (setvar "osmode" magneet) (setq *error* fout) ;(setvar "CMDECHO" 1));defunAnyone has any idea what is wrong in my code?
 
Thanks
 
Wesley
Example of shadow lines.pdf
columnshadow.lsp

MSasu 发表于 2022-7-5 23:45:39

Seems that you should disable the OSMODE system variable before calling the COMMAND function to draw.

...(setvar "OSMODE" 0)(command "LINE" k1a k4a "")...

Wesley_Amsterda 发表于 2022-7-6 00:06:32

 
Works great now!
Thanks MSasu!

MSasu 发表于 2022-7-6 00:15:49

Sound good, Wesley_Amsterdam; you're welcome!
 
And, by the way, welcome to the Forum!

BIGAL 发表于 2022-7-6 00:35:58

Pretty common to have to set snaps etc
 

;put at start(setq oldsnap (getvar "osmode"))(setq osmode 0); code; end of code(setvar "osmode" oldsnap)
other usefulls "Clayer" "curtab" "textstyle" "Angbase Angdir Lunits Luprec Aunits Auprec"
页: [1]
查看完整版本: LISP-routine does weird things