0 Members and 1 Guest are viewing this topic.
A quick noteCode: [Select] (if (not (setq TrussID (strcase (getstring "\n Enter truss identifier: <A>")))) (setq TrussID "A") )This will never put the default as ' A '. ' getstring ' will never return nil. If enter is pressed, it returns an empty string ' "" ', so test to see ' TrussID ' equals that, and if so then default to ' A '.
(if (not (setq TrussID (strcase (getstring "\n Enter truss identifier: <A>")))) (setq TrussID "A") )
So do you still need help?
Thanks Tim,I got it working as hoped. Still scratching my head at the code though (maybe some commenting )I am in the process of dissecting it nowThanks again
(defun GetPointAtAngle ( pt baseAng / tempList pt2 flag ang pt3 tempAng ) (setq flag T) (while (and flag (not (member (car (setq tempList (grread T 0))) '(11 25))) ) ; above just lets you move the mouse until an enter is hit, by right click or not (redraw) ; just to get the old graphic line off the screen (if (member (car tempList) '(3 5)) ; if the mouse is moved, or left clicked do what is below (progn (setq pt2 (cadr tempList)) ; get the point of the mouse (setq ang (angle pt pt2)) ; get the angle between the supplied point, and where the mouse is (setq tempAng (caar (vl-sort (mapcar '(lambda (x) (cons x (abs (- x ang))) ) ; make a list of lists, ( the 90 degree angle list . the amount of difference between that angle, and the on one between the supplied point, and the mouse ) ; this will be used to see what angle the mouse is closest to, so that we can show the correct angle being snaped to. (list baseAng (rem (+ baseAng (* pi 0.5)) (* pi 2.)) (rem (+ baseAng pi) (* pi 2.)) (rem (+ baseAng (* pi 1.5)) (* pi 2.)) ) ; make a list of all the angles off the supplied angle, 90 degree list ) '(lambda (a b) (< (cdr a) (cdr b)) ) ; sort the list by the smallest angle ) ) ) ; set the correct 90 degree angle (setq pt3 (polar pt tempAng (* (cos (if (> tempAng ang) (- tempAng ang) (- ang tempAng) ) ; to find the correct angle for the trig function, we have to find the angle that is the difference of the angle of points, and the angle of 90 degrees ; since we need it to be positive, and in the right direction, we have to subtract the smaller angle from the larger one. ) (distance pt pt2) ; this is the hypothnus ) ; getting the correct distance takes a trig function. since we know the angle and the hypothnus, then we can figure out the adjacent distance. ) ) (grdraw pt pt3 1) (if (equal (car tempList) 3) (setq flag nil) (setq pt3 nil) ) ; if the point is picked, and not just draged about, then set flag to nil to end the while ) ) ) (redraw) pt3)
Code: [Select] (not (member (car (setq tempList (grread T 0))) '(11 25)))
(not (member (car (setq tempList (grread T 0))) '(11 25)))
OK here is the semi-final results of your help. This is what I was shooting for. This has been approved for use at my company.A bit more tweaking and it'l be totally ready to go.Thanks again TIM
Quote from: T.Willey on February 11, 2009, 03:24:29 PMCode: [Select] (not (member (car (setq tempList (grread T 0))) '(11 25)))Tim, according to the autolisp reference, seems the the 1st element of grread function's return values is 2, through 12. How did you get the 25? Thanks.
Hi xycadd,Try enter (grread) at command line, then right click. It returns 11 or 25 according to SHORTCUTMENU sysvar value.