jjatho Posted December 7, 2015 Posted December 7, 2015 I've been playing around with writing a quick script this morning and everything seems to be working right except the line highlighted in red. When I comment it out, everything else works as intended. If I leave it uncommented, the program stops and does not complete anything else after that line. Not really sure why getting the angle between the two points isn't working. For reference, the "first sheave" and "second sheave" selected by the user are both represented by equally sized circles. (defun C:Reeving() (setq degToRad 0.01745329251) ;Multiply by a degree value to get radians (setq radToDeg 57.2957795131) ;Multiply by a radian value to get degrees (setq snapMode (getvar "osmode")) (setq 3DSnapMode (getvar "3dosmode")) (setvar "osmode" 0) (setvar "3dosmode" 0) (setq Sheave1 (entget (car (entsel "\nSelect First Sheave\n")))) (setq Sheave2 (entget (car (entsel "\nSelect Second Sheave\n")))) (setq Sheave1Radius (cdr (assoc 40 Sheave1))) (setq Sheave2Radius (cdr (assoc 40 Sheave2))) (setq Sheave1Center (cdr (assoc 10 Sheave1))) (setq Sheave1X (car Sheave1Center)) (setq Sheave1Y (cadr Sheave1Center)) (setq Sheave1Z (caddr Sheave1Center)) (setq Sheave2Center (cdr (assoc 10 Sheave2))) (setq Sheave2X (car Sheave2Center)) (setq Sheave2Y (cadr Sheave2Center)) (setq Sheave2Z (caddr Sheave2Center)) (entmakex (list (cons 0 "LINE") ;Draw Centerline (cons 8 "MSGuidelines") (cons 10 Sheave1Center) (cons 11 Sheave2Center))) [color="red"](setq CLAngle (angle Sheave1Center Sheave2Center))[/color] (setq Sheave1Start (list (- Sheave1X Sheave1Radius) Sheave1Y Sheave1Z)) (setq Sheave1End (list (+ Sheave1X Sheave1Radius) Sheave1Y Sheave1Z)) (entmakex (list (cons 0 "LINE") (cons 8 "MSGuidelines") (cons 10 Sheave1Start) (cons 11 Sheave1End))) (setq ent (entlast)) (setq entdata (entget ent)) (setq Sheave1Guide (cdr (assoc -1 entdata))) ;(command "ROTATE" Sheave1Guide "" Sheave1Center "45") (setq Sheave2Start (list (- Sheave2X Sheave2Radius) Sheave2Y Sheave2Z)) (setq Sheave2End (list (+ Sheave2X Sheave2Radius) Sheave2Y Sheave2Z)) (entmakex (list (cons 0 "LINE") (cons 8 "MSGuidelines") (cons 10 Sheave2Start) (cons 11 Sheave2End))) (setq ent (entlast)) (setq entdata (entget ent)) (setq Sheave2Guide (cdr (assoc -1 entdata))) ;(command "ROTATE" Sheave2Guide "" Sheave2Center "45") (setvar "CLAYER" "0") (setvar "osmode" snapMode) (setvar "3dosmode" 3DSnapMode) ;(c:LispLoad) (princ) ) ;End defun Reeving Quote
BIGAL Posted December 8, 2015 Posted December 8, 2015 A different rtd & dtr often its easier to put these functions in a library that is autoloaded ;The dtr function converts degrees to radians (dtr a) ;The rtd function converts radians to degrees (rtd a) (defun dtr (a) (* pi (/ a 180.0)) ) ; (defun rtd (a) (/ (* a 180.0) pi) ) ; and some more common (setq pi90 (/ pi 2.0)) ; 180 is pi (setq pi270 (* 1.5 pi)) 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.