git_thailand Posted November 2, 2011 Posted November 2, 2011 (defun c:test () (setq p1 (getpoint "\nPick point L: ") p2 (getpoint "\nPick point R: ") p3 (polar p2 (dtr 270.0) (+ (/ 0.10 2)0.10)) p4 (polar p3 (dtr 180.0)0.10) p5 (polar p4 (dtr 150.0)0.10) sum (- (distance p1 p2 )0.373) p6 (polar p5 (dtr 180.0) sum) p7 (polar p6 (dtr 210.0)0.10) p8 (polar p7 (dtr 180.0)0.10) Layer "A-BEAM" );endq (command "_layer" "m" Layer "") (command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p1 "") (princ) ) (defun dtr (x) ;define degrees to radians function (* pi (/ x 180.0)) ;divide the angle by 180 then ;multiply the result by the constant PI ) ;end of function (princ) Quote
MSasu Posted November 2, 2011 Posted November 2, 2011 First, you will need to provide more information regarding what you want to achieve - after disabling the OSMODE the routine draw something, just cannot know if is wrong or not: (setvar "OSMODE" 0) Second, please edit your post to follow the rules for code posting. Regards, Mircea Quote
git_thailand Posted November 2, 2011 Author Posted November 2, 2011 pick p1 p2 draw section concrete slab on ground Quote
MSasu Posted November 2, 2011 Posted November 2, 2011 Please see below my corections in red: (defun c:test ( / [color=red]MyOldOsmode MyOldOrtho[/color] ) [color=red] ;retain current setting to be able to restore later (setq MyOldOsmode (getvar "OSMODE") MyOldOrtho (getvar "ORTHOMODE")) ;disable auto-Osnap and activate Ortho mode (setvar "OSMODE" 0) (setvar "ORTHOMODE" 1) [/color] (setq p1 (getpoint "\nPick point L: ") p2 (getpoint p1 "\nPick point R: ") p3 (polar p2 (dtr 270.0) (+ (/ 0.10 2)0.10)) p4 (polar p3 (dtr 180.0)0.10) p5 (polar p4 (dtr 150.0)0.10) sum (- (distance p1 p2 )0.373) p6 (polar p5 (dtr 180.0) sum) p7 (polar p6 (dtr 210.0)0.10) p8 (polar p7 (dtr 180.0)0.10) Layer "A-BEAM" );endq (command "_layer" "m" Layer "") (command "pline" p1 p2 p3 p4 p5 p6 p7 p8 p1 "") [color=red] ;restore previous environment (setvar "OSMODE" MyOldOsmode) (setvar "ORTHOMODE" MyOldOrtho) [/color] (princ) ) Regards, Mircea Quote
Tharwat Posted November 2, 2011 Posted November 2, 2011 Mircea , you have localized your added variables only , so what about the rest variables and the subfunction DTR ? Quote
MSasu Posted November 2, 2011 Posted November 2, 2011 Mircea , you have localized your added variables only , so what about the rest variables and the subfunction DTR ? There are many improvements that can be done to that piece of code - I have only fixed it to work as OP expected. I don't intent to re-write it. Regards, Mircea Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.