uuoo10levi Posted January 7, 2013 Posted January 7, 2013 I'm trying to figure out what I would understand to be something simple. I want to create a lisp that I can tell it to draw 3 lines and then I can specify if it goes to the left or to the right. Here is the basic of what I have so far. (defun c:ju() (setq oldosmode (getvar "osmode")) (setq oldlayer (getvar "clayer")) (setq p1 (getpoint "\nPick Top Point:") p2 (getpoint "\nPick Bottom Point:") lvl (getint "\nJumper Level: (1,2,3,4...)") ) (setq p3 (list (+ (car p1) (* lvl 0.09375)) (- (cadr p1) (* lvl 0.03125)) ) ) (setq p4 (list (+ (car p2) (* lvl 0.09375)) (+ (cadr p2) (* lvl 0.03125)) ) ) (setvar "clayer" "text0") (command "line" p1 p3 "") (command "line" p2 p4 "") (command "line" p3 p4 "") (setvar "clayer" oldlayer) (setvar "osmode" oldosmode) ) This is what it creates Now, that works great and I need is to specify that I would want that jumper to go to the right or the left of the 2 white lines. I could use some help. Quote
kraz Posted January 8, 2013 Posted January 8, 2013 (edited) Do you want link this?? (defun c:ju() (setq oldosmode (getvar "osmode")) (setq oldlayer (getvar "clayer")) (setq p1 (getpoint "\nPick Top Point:") p2 (getpoint "\nPick Bottom Point:") lvl (getint "\nJumper Level: (1,2,3,4...)") ) (setq q (strcase (getstring "\nLeft/Right[Enter:R]:"))) (if (eq "" q) (setq q "R")) (cond ((eq q "R") (setq opt "+")) ((eq q "L") (setq opt "-")) ) (setq p3 (list ((eval (read opt)) (car p1) (* lvl 0.09375)) (- (cadr p1) (* lvl 0.03125)) ) ) (setq p4 (list ((eval (read opt)) (car p2) (* lvl 0.09375)) (+ (cadr p2) (* lvl 0.03125)) ) ) (setvar "clayer" "text0") (command "line" p1 p3 "") (command "line" p2 p4 "") (command "line" p3 p4 "") (setvar "clayer" oldlayer) (setvar "osmode" oldosmode) )[/color] I'm trying to figure out what I would understand to be something simple. I want to create a lisp that I can tell it to draw 3 lines and then I can specify if it goes to the left or to the right. Here is the basic of what I have so far. (defun c:ju() (setq oldosmode (getvar "osmode")) (setq oldlayer (getvar "clayer")) (setq p1 (getpoint "\nPick Top Point:") p2 (getpoint "\nPick Bottom Point:") lvl (getint "\nJumper Level: (1,2,3,4...)") ) (setq p3 (list (+ (car p1) (* lvl 0.09375)) (- (cadr p1) (* lvl 0.03125)) ) ) (setq p4 (list (+ (car p2) (* lvl 0.09375)) (+ (cadr p2) (* lvl 0.03125)) ) ) (setvar "clayer" "text0") (command "line" p1 p3 "") (command "line" p2 p4 "") (command "line" p3 p4 "") (setvar "clayer" oldlayer) (setvar "osmode" oldosmode) ) This is what it creates [ATTACH]39491[/ATTACH] Now, that works great and I need is to specify that I would want that jumper to go to the right or the left of the 2 white lines. I could use some help. Edited January 9, 2013 by kraz Quote
BIGAL Posted January 8, 2013 Posted January 8, 2013 Easiest way is to not have to type an answer add pick left or right as a 3rd getpoint using mouse is faster, then do one routine just need a swap end points test for left or right. (setq pt1 (getpoint "\npick 1st point to place pit : ")) (setq pt2 (getpoint "\nPick 2nd point for orientation")) (setvar "osmode" 0) (setq pt7 (getpoint "\Pick pt on pit side : ")) (setq ang (angle pt1 pt2)) (setq ang5 (angle pt2 pt7)) (setq diffang (- ang ang5)) (if (> diffang 1.5707) (setq ang2 (- ang 1.570796)) (setq ang2 (+ ang 1.570796)) ) ps dont upset moderator put code in tags Quote
kraz Posted January 8, 2013 Posted January 8, 2013 (edited) Do you want faster than type "L" or "R" ? then, pointing left or right of p1 (defun c:ju() (setq oldosmode (getvar "osmode")) (setq oldlayer (getvar "clayer")) (setq p1 (getpoint "\nPick Top Point:") p2 (getpoint "\nPick Bottom Point:") lvl (getint "\nJumper Level: (1,2,3,4...)") ) (setq q (getpoint p1 "\nDirection:")) (if (>= (car q) (car p1)) (setq opt "+") (setq opt "-") ) (setq p3 (list ((eval (read opt)) (car p1) (* lvl 0.09375)) (- (cadr p1) (* lvl 0.03125)) ) ) (setq p4 (list ((eval (read opt)) (car p2) (* lvl 0.09375)) (+ (cadr p2) (* lvl 0.03125)) ) ) (setvar "clayer" "text0") (command "line" p1 p3 "") (command "line" p2 p4 "") (command "line" p3 p4 "") (setvar "clayer" oldlayer) (setvar "osmode" oldosmode) ) Edited January 9, 2013 by kraz Quote
SLW210 Posted January 8, 2013 Posted January 8, 2013 kraz, Please read the CODE POSTING GUIDELINES and edit your post to include Code Tags. Quote
kraz Posted January 9, 2013 Posted January 9, 2013 Thanks SLW210. I didn't know about that. All of my reply was fixed. thanks again 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.