samifox Posted June 6, 2014 Posted June 6, 2014 hi i want to create a loop with persistent negative-positive values , meaning if for example the loop contain a expression to make a line from p1 to p2, the next reversal of the loop will offset the next line (p1+10) to (p2 + 10) , and the next loop will be (p1-10) to (p2-10) and so until the loop is death in the next code i tried to layout the actions sequences i want it. i didnt now how to design a loop out of it hope it make sense Thanks Shay (setq p1 (getpoint "click 1")) (command "_circle" p "d" "20" "") (setq p2 (getpoint "click 2")) (setq ofs (polar p2 (+ (angle p1 p2) (/ pi 2.0)) 40 )) (command "_circle" ofs "d" "20" "") (setq p2 (getpoint "click 3")) (setq ofs (polar p2 (- (angle p1 p2) (/ pi 2.0)) 40 )) (command "_circle" ofs "d" "20" "") Quote
samifox Posted June 7, 2014 Author Posted June 7, 2014 ok i got it no one understand what i want...( sorry my wife gave me only 5 min ok...one picture worth 1000 words... in the attached image you can see what im trying to achieve , and hopefully my problem to set the mid point in different location each loop iteration. this is the code i manage to write , in order to solve the problem , i've created a list (list '(+ -)) , and each loop iteration im trying to call that list with (car list) and than (reverse list) , so each iteration will trigger different function. [color="red"][b](setq opr (list '(+ -)))[/b][/color] (setvar "orthomode" 1) (defun rebarseq (/ plst fstpt mdlpt endpt pinp mid clk cclk p1 p2 ang dis) (setq plst (cons (getpoint "\nPick first point") plts)) (while plst (if (= (length plst) 1) ;_if its the first iteration (progn (setq plst (cons (getpoint (car plst) "\nPick second point") plst)) (setq ang (angle (car plst) (cadr plst))) (setq dis (distance (car plst) (cadr plst))) (setq mid (getmid (car plst) (cadr plst))) (command "_point" mid) (setq clk (polar mid ang (+ (/ dis 2.0) 50.0))) ;_polar helf distance + 50 (setq cclk (polar mid (+ ang pi) (+ (/ dis 2.0) 50.0))) ;_polar helf distance + 50 (entmakex (list (cons 0 "LINE") (cons 10 clk) (cons 11 cclk))) ) ;_ end of progn (progn ;_if its not the first iteration (setq plst (cons (getpoint (car plst) "\nPick next point") plst)) (setq dis (distance (car plst) (cadr plst))) (setq mid (polar (getmid (car plst) (cadr plst)) ([color="red"][b](car opr)[/b][/color] ang (/ pi 2)) 20.0 ) ;_ end of polar ) ;_ end of setq [color="blue"] (reverse opr)[/color] (command "_point" mid) (setq clk (polar mid ang (+ (/ dis 2.0) 50.0))) ;_polar helf distance + 50 (setq cclk (polar mid (+ ang pi) (+ (/ dis 2.0) 50.0))) ;_polar helf distance + 50 (entmakex (list (cons 0 "LINE") (cons 10 clk) (cons 11 cclk))) ) ;_ end of progn ) ;_ end of if ) ;_ end of while ) ;_ end of defun (defun getmid (p1 p2) (list ;_get mid point (/ (+ (car p1) (car p2)) 2.0) (/ (+ (cadr p1) (cadr p2)) 2.0) ) ;_ end of list ) ;_ end of defun so...how to pass the + function as an argument to ((car opr) ang (/ pi 2))? hope its clear now Thanks Shay Quote
samifox Posted June 7, 2014 Author Posted June 7, 2014 I solve it already. Ill post tje solution in different thread 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.