Andrew1979 Posted April 9, 2014 Share Posted April 9, 2014 (edited) I am trying to create an elevation of a door. I was pretty sure my code was correct but for some reason the frame thickness is always some strange number, not the 100 I have set. Also the door swing is a bit off too. Any ideas Here is my code: ...(defun d2r (a)(* pi (/ a 180)))(defun r2d (a)(* 180.0 (/ a pi)))(defun c:edoor ()(getDoorInput) (ProcessDoorInput)(drawDoor))(defun getDoorInput ()(setq IPdoor (getpoint "\nPick Bottom Left Corner of Door << "))(setq SPdoor (getcorner IPdoor "\nPick Top Right Corner of Door << ")))(defun ProcessDoorInput ()(setq DoorFrame 100)(setq ANG (angle IPdoor SPdoor))(setq ANG (r2d ANG)) ;Door Frame(setq DoorP1 (polar IPdoor (d2r (+ ANG 0.00)) DoorFrame))(setq DoorP2 (polar DoorP1 (d2r (+ ANG 270.00)) DoorFrame))(setq DoorP3 (polar SPdoor (d2r (+ ANG 180.00)) DoorFrame))(setq DoorP4 (polar DoorP3 (d2r (+ ANG 90.00)) DoorFrame));Door Swing(setq SwingP1 (list (car IPdoor) (cadr SPdoor)))(setq MidPoint (/ (distance IPdoor SwingP1) 2))(setq SwingP2 (polar IPdoor (d2r (+ ANG 90.00)) Midpoint)) (setq SwingP3 (list (car SPdoor) (cadr SwingP2)));Delete Frame(setq DeleteP1 (polar IPdoor (d2r (+ ANG 0.00)) 5))(setq DeleteP2 (polar DeleteP1 (d2r (+ ANG 90.00)) 200)) )(defun drawDoor ()(command;"erase" "f" DeleteP1 DeleteP2 "" """cecolor" "bylayer" "Clayer" "Alum""rectang" IPdoor SPdoor"draworder" "last" "" "back""cecolor" "yellow" "rectang" DoorP2 DoorP4"draworder" "last" "" "back";"-linetype" "set" "dashed""pline" IPdoor SwingP3 SwingP1 """cecolor" "bylayer");end command )...[/Code] Edited April 9, 2014 by Andrew1979 Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 9, 2014 Share Posted April 9, 2014 One source of issues may be the active Osnaps; try to avoid interferences either by setting (temporarily) OSMODE system variable to 0 or by using None mode before inputting a point. ... "[color=red]_[/color]rectang" [color=red]"_non"[/color] IPdoor [color=red]"_non"[/color] SPdoor ... "[color=red]_[/color]rectang" [color=red]"_non"[/color] DoorP2 [color=red]"_non"[/color] DoorP4 ... "[color=red]_[/color]pline" [color=red]"_non"[/color] IPdoor [color=red]"_non"[/color] SwingP3 [color=red]"_non"[/color] SwingP1 "" ... For your case will be easier to build the points as lists, then using POLAR: (setq DoorP2 (list (+ (car IPdoor) DoorFrame) (+ (cadr IPdoor) DoorFrame)) DoorP4 (list (- (car SPdoor) DoorFrame) (- (cadr SPdoor) DoorFrame))) (setq SwingP1 (list (car DoorP2) (cadr DoorP4)) SwingP3 (list (car DoorP4) (/ (+ (cadr DoorP2) (cadr DoorP4)) 2.0))) Please edit your previous post and add required code tags. Quote Link to comment Share on other sites More sharing options...
Andrew1979 Posted April 9, 2014 Author Share Posted April 9, 2014 thank you so much. Yes, the code you wrote works well (just made some minor adjustments for the swing) I have always used polar for points but I am now just getting used to car and cadr. Much more efficient. Thanks again. Quote Link to comment Share on other sites More sharing options...
MSasu Posted April 9, 2014 Share Posted April 9, 2014 Good to hear that is OK. You're welcome! Now, please do me a favor and fix the first post with code tags. Both point calculation approaches (POLAR vs. LIST) have their application, sometime is more effective to use one over the other, so don't dismiss one to stick with other only! Your inside frame corners may be calculated alternatively: (setq diagFrame (/ DoorFrame (sin (d2r 45.0))) DoorP2 (polar IPdoor (d2r 45.0) diagFrame) DoorP4 (polar SPdoor (d2r 225.0) diagFrame)) or (setq DoorP2t (polar IPdoor 0.0 DoorFrame) DoorP2 (polar DoorP2t (d2r 90.0) DoorFrame) DoorP4t (polar SPdoor (d2r 270.0) DoorFrame) DoorP4 (polar DoorP4t (d2r 180.0) DoorFrame)) Quote Link to comment Share on other sites More sharing options...
Andrew1979 Posted April 9, 2014 Author Share Posted April 9, 2014 Thanks for the additional information. I have also fixed the code tags too Quote Link to comment Share on other sites More sharing options...
BIGAL Posted April 10, 2014 Share Posted April 10, 2014 Just another suggestion its a good idea to use all reals in your calcs you have number as 90.0 and others as 100 lisp can do some funy things depending on the order of when you do say a / 3 v's / 3.0 compare (princ (/ 100 3)) (princ (/ 100 3.0)) Quote Link to comment Share on other sites More sharing options...
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.