CadFrank Posted January 23, 2012 Posted January 23, 2012 Hello every reader, Well i'm working on a routine here ill post a picture to show you what it make. but i want to have the chose either to reproduce this on the left or the right so i used the function getkword, if and progn to simulate it. now when i choose right it doesnt work. here's the (defun c:cofp (/ rep pt1 pt2) (setq pt1 (getpoint "\nClick on the first point ! ")) (setq pt2 (getpoint "\nClick on the second point ! ")) (initget 1 "left right") (setq rep (getkword "\nChoose the side of the beam [left/right] ")) (if (= rep Gauche) (progn (setq pt3 (list (- (car pt2) 20) (cadr pt2))) (setq pt4 (list (- (car pt1) 20) (cadr pt1))) (setq pt5 (list (- (car pt4) 90) (+ (cadr pt4) 20))) (setq pt6 (list (- (car pt4) 90) (cadr pt4))) (setq pt7 (list (car pt3) (- (cadr pt3) 38))) (setq pt8 (list (car pt3) (- (cadr pt3) 76))) );progn );if (if (= rep Droite) (progn (setq pt3 (list (+ (car pt2) 20) (cadr pt2))) (setq pt4 (list (+ (car pt1) 20) (cadr pt1))) (setq pt5 (list (+ (car pt4) 90) (+ (cadr pt4) 20))) (setq pt6 (list (+ (car pt4) 90) (cadr pt4))) (setq pt7 (list (car pt3) (- (cadr pt3) 38))) (setq pt8 (list (car pt3) (- (cadr pt3) 76))) );progn );if (setq os (getvar 'OSMODE)) (setvar 'OSMODE 0) (command "_insert" "2 x 4" pt6 "" "1" "") (command "_insert" "2 x 4" pt7 "" "1" "") (command "_insert" "2 x 4" pt8 "" "1" "") (command "_rectangle" pt1 pt3) (command "_rectangle" pt4 pt5) (command "_rectangle" pt5 pt8) (setvar 'OSMODE os) );defun c: So here it is ! thanks for the help in advance! Cheers beers. Quote
GP_ Posted January 23, 2012 Posted January 23, 2012 Try (defun c:cofp (/ rep pt1 pt2) (setq pt1 (getpoint "\nClick on the first point ! ")) (setq pt2 (getpoint "\nClick on the second point ! ")) (initget 1 "L R") (setq rep (getkword "\nChoose the side of the beam [Left/Right] ")) (if (= rep "L") (progn (setq pt3 (list (- (car pt2) 20) (cadr pt2))) (setq pt4 (list (- (car pt1) 20) (cadr pt1))) (setq pt5 (list (- (car pt4) 90) (+ (cadr pt4) 20))) (setq pt6 (list (- (car pt4) 90) (cadr pt4))) (setq pt7 (list (car pt3) (- (cadr pt3) 38))) (setq pt8 (list (car pt3) (- (cadr pt3) 76))) );progn );if (if (= rep "R") (progn (setq pt3 (list (+ (car pt2) 20) (cadr pt2))) (setq pt4 (list (+ (car pt1) 20) (cadr pt1))) (setq pt5 (list (+ (car pt4) 90) (+ (cadr pt4) 20))) (setq pt6 (list (+ (car pt4) 90) (cadr pt4))) (setq pt7 (list (car pt3) (- (cadr pt3) 38))) (setq pt8 (list (car pt3) (- (cadr pt3) 76))) );progn );if (setq os (getvar 'OSMODE)) (setvar 'OSMODE 0) (command "_insert" "2 x 4" pt6 "" "1" "") (command "_insert" "2 x 4" pt7 "" "1" "") (command "_insert" "2 x 4" pt8 "" "1" "") (command "_rectangle" pt1 pt3) (command "_rectangle" pt4 pt5) (command "_rectangle" pt5 pt8) (setvar 'OSMODE os) );defun c: Quote
CadFrank Posted January 23, 2012 Author Posted January 23, 2012 Hi Thank for the help it works! i think i forgot the "" Quote
BIGAL Posted January 24, 2012 Posted January 24, 2012 A shorter way maybe 2 clicks first pick pick line you can get start & end pts then compare pick point to figure out top bottom etc swap pts the 2nd pick is direction required. Code is copyrighted but a snippet (setq tp1 (entsel "\nSelect left side inner wall near end : ")) (setq tpp1 (entget (car tp1))) (setq pt1 (cdr (assoc 10 tpp1))) ;start (setq pt2 (cdr (assoc 11 tpp1))) ; end (setq pt3 (cadr tp1)) ;pick point Just compare distance pt3-pt1 pt3-pt2 the shorter is your start point. Quote
CadFrank Posted January 25, 2012 Author Posted January 25, 2012 Hi Bigal, I tried what you posted but i'm not sure it works when it's a pline. But since i want to make sure my pt1 is always the one in the bottom would there be a way to do it? cheers beers Quote
BIGAL Posted January 26, 2012 Posted January 26, 2012 The draw stud I have is based on a complete package so it expects lines you probbably could get it still to work with plines but the code will become a lot bigger,with some other stuff just took the cheap way out if pline then explode and continue. 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.