elfert Posted November 8, 2012 Share Posted November 8, 2012 Hello Users! I am in a need for a lisp that can draw a specific polyline like shown below: The user have to give: 1. User point 1 and 2. 2. Length X About Lisp code: The program the have to figure the out how to draw the Polyline, so i think it have to calculate the y length by it self. Horisontal: - If the user first give the user point 1 and the Point 2 then the lisp command have to draw the Poly line like shown in the picture 1. - If the user first give the user point 2 and the Point 1 then the lisp command have to draw the Poly line like shown in the picture 2. Vertical: - If the user first give the user point 1 and then Point 2. the lisp command have to draw it like shown on picture 3. - If the user first give the user point 2 and then Point 1. the lisp command have to draw it like shown on picture 4. Why i need this: I use the Polylines for a welding signatures on Flatpattern drawings so the welder/Blacksmith knows were he have to weld the x lenght when he/she weld a Flatbar on a 'Flatpattern' plate. Thanx in advance. Quote Link to comment Share on other sites More sharing options...
nod684 Posted November 9, 2012 Share Posted November 9, 2012 Looks like you need a new Linetype for that...not a lisp Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 9, 2012 Share Posted November 9, 2012 (edited) Here is some very simple code: ([color=BLUE]defun[/color] c:zigzag ( [color=BLUE]/[/color] a d i l p q x y ) ([color=BLUE]defun[/color] l ( a b ) ([color=BLUE]entmake[/color] ([color=BLUE]list[/color] '(0 . [color=MAROON]"LINE"[/color]) ([color=BLUE]cons[/color] 10 a) ([color=BLUE]cons[/color] 11 b))) ) ([color=BLUE]setq[/color] x 10.0 y 10.0 ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] p ([color=BLUE]getpoint[/color] [color=MAROON]"\n1st Point: "[/color])) ([color=BLUE]setq[/color] q ([color=BLUE]getpoint[/color] [color=MAROON]"\n2nd Point: "[/color] p)) ) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] p ([color=BLUE]trans[/color] p 1 0) q ([color=BLUE]trans[/color] q 1 0) a ([color=BLUE]angle[/color] p q) d ([color=BLUE]distance[/color] p q) i ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0) ) ([color=BLUE]repeat[/color] ([color=BLUE]fix[/color] ([color=BLUE]/[/color] d x)) (l p ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p a x))) (l p ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p ([color=BLUE]+[/color] a ([color=BLUE]setq[/color] i ([color=BLUE]-[/color] i))) y))) ) ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]equal[/color] 0.0 ([color=BLUE]rem[/color] d x) 1e-) (l p ([color=BLUE]polar[/color] p a ([color=BLUE]rem[/color] d x))) ) ) ) ([color=BLUE]princ[/color]) ) Edited November 9, 2012 by Lee Mac Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 9, 2012 Share Posted November 9, 2012 Lee , The last line might become with zero length if the following criteria took a place . (rem 100. 10.) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 9, 2012 Share Posted November 9, 2012 Good catch Tharwat, updated above. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 10, 2012 Share Posted November 10, 2012 You can do all sorts of pline stuff including arcs I wrote a number of batting routines zig-zag wavy curves etc they work the way you want start-end width, I can not post code copyrited but more than happy to help how to do. Search here for batting there are some examples Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 11, 2012 Share Posted November 11, 2012 (edited) Another with Polyline entity . Hope you like it . (defun c:PolyZag (/ a ang d l p1 p2 p3 p4) ;;; Author: Tharwat Al Shoufi ;;; ;;; Codes to make zig zag polyline ;;; (vl-load-com) (setq x (if x *x* 1.0 ) ) (setq y (if y *y* 1.0 ) ) (if (and (setq *x* (cond ((getdist (strcat "\n Specify X segment < " (rtos x 2 2) " > :" ) ) ) (t x) ) ) (setq *y* (cond ((getdist (strcat "\n Specify Y segment < " (rtos y 2 2) " > :" ) ) ) (t y) ) ) (setq p1 (getpoint "\n Specify start point :")) (setq p2 (getpoint "\n Specify next point :" p1)) (if (< (setq d (distance p1 p2)) *x*) (progn (alert " Distance between points must be bigger than X segment " ) nil ) t ) ) (progn (setq ang (angle p1 p2) a '- x *x* y *y* ) (setq l (cons p1 l)) (repeat (fix (/ d *x*)) (setq l (cons (setq p3 (polar p1 ang *x*)) l)) (setq l (cons (setq p4 (polar p3 ((if (eq a '-) (eval (setq a '+)) (eval (setq a '-)) ) ang (* pi 0.5) ) *y* ) ) l ) ) (setq p1 p4) ) (cond ((eq (rem d *x*) 0.0) (setq l (vl-remove (car l) l))) ((not (equal (/ d *x*) 0.0)) (setq l (cons (polar p1 ang (rem d *x*)) l)) ) ) (entmakex (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(70 . 0) (cons 90 (length l)) ) (mapcar '(lambda (x) (cons 10 (list (car x) (cadr x)))) l) ) ) ) (princ) ) (princ "\n Written by Tharwat Al Shoufi") (princ) ) Edited November 11, 2012 by Tharwat Quote Link to comment Share on other sites More sharing options...
elfert Posted November 11, 2012 Author Share Posted November 11, 2012 Nice Replys to all the replys in this thread ! Many thanks... Tha****: - can you do some 'explanation what the code does. Then i could better understand the code and maybe change it. - if you see my picture you will notice that the y is the horizontal line segment between the x line segments maybe i should have called it X1 one instead then there wasn't a misunderstanding there my fault... But any way the lisp code have to calculate the y line segment by itself. - The code is asking for the y coordinates from the start point but in the pictures it says it always have to be 20mm. - The first x line segment and the last x line segment have to have the same y-coordiantes like shown on the picture. - The way that the poly turns direction depending on witch way the user gives the start and end point seams working..thanks! Thanx forum members.... Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 12, 2012 Share Posted November 12, 2012 Here's a fun one for you to play with: [color=GREEN];; Dynamic Zig-Zag - Lee Mac[/color] ([color=BLUE]defun[/color] c:zz ( [color=BLUE]/[/color] a d g i l p q r x y ) ([color=BLUE]setq[/color] x 10.0 y 10.0 i ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0) ) ([color=BLUE]if[/color] ([color=BLUE]setq[/color] p ([color=BLUE]getpoint[/color] [color=MAROON]"\nSpecify 1st Point: "[/color])) ([color=BLUE]progn[/color] ([color=BLUE]princ[/color] [color=MAROON]"\nSpecify 2nd Point [+/-] <Exit>: "[/color]) ([color=BLUE]while[/color] ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] g ([color=BLUE]grread[/color] [color=BLUE]t[/color] 15 0) q ([color=BLUE]cadr[/color] g) g ([color=BLUE]car[/color] g) ) ([color=BLUE]cond[/color] ( ([color=BLUE]member[/color] g '(3 5)) ([color=BLUE]redraw[/color]) ([color=BLUE]setq[/color] a ([color=BLUE]angle[/color] p q) d ([color=BLUE]distance[/color] p q) i ([color=BLUE]abs[/color] i) r p ) ([color=BLUE]repeat[/color] ([color=BLUE]fix[/color] ([color=BLUE]/[/color] d x)) ([color=BLUE]grdraw[/color] r ([color=BLUE]setq[/color] r ([color=BLUE]polar[/color] r a x)) 1 1) ([color=BLUE]grdraw[/color] r ([color=BLUE]setq[/color] r ([color=BLUE]polar[/color] r ([color=BLUE]+[/color] a ([color=BLUE]setq[/color] i ([color=BLUE]-[/color] i))) y)) 1 1) ) ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]equal[/color] 0.0 ([color=BLUE]rem[/color] d x) 1e-) ([color=BLUE]grdraw[/color] r ([color=BLUE]polar[/color] r a ([color=BLUE]rem[/color] d x)) 1 1) ) ([color=BLUE]=[/color] 5 g) ) ( ([color=BLUE]=[/color] 2 g) ([color=BLUE]cond[/color] ( ([color=BLUE]member[/color] q '(43 61)) ([color=BLUE]setq[/color] x ([color=BLUE]1+[/color] x)) ) ( ([color=BLUE]member[/color] q '(45 95)) ([color=BLUE]setq[/color] x ([color=BLUE]max[/color] ([color=BLUE]1-[/color] x) 1)) ) ) ) ) ) ) ([color=BLUE]if[/color] ([color=BLUE]=[/color] 3 g) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] i ([color=BLUE]abs[/color] i) p ([color=BLUE]trans[/color] p 1 0) q ([color=BLUE]trans[/color] q 1 0) a ([color=BLUE]angle[/color] p q) ) ([color=BLUE]repeat[/color] ([color=BLUE]fix[/color] ([color=BLUE]/[/color] d x)) ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 p) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p a x))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p ([color=BLUE]+[/color] a ([color=BLUE]setq[/color] i ([color=BLUE]-[/color] i))) y))) l) ) ) ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]equal[/color] 0.0 ([color=BLUE]rem[/color] d x) 1e-) ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]polar[/color] p a ([color=BLUE]rem[/color] d x))) l)) ) ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] ([color=BLUE]list[/color] '(000 . [color=MAROON]"LWPOLYLINE"[/color]) '(100 . [color=MAROON]"AcDbEntity"[/color]) '(100 . [color=MAROON]"AcDbPolyline"[/color]) ([color=BLUE]cons[/color] 90 ([color=BLUE]length[/color] l)) '(70 . 0) ) ([color=BLUE]reverse[/color] l) ) ) ) ) ([color=BLUE]redraw[/color]) ) ) ([color=BLUE]princ[/color]) ) Example: Quote Link to comment Share on other sites More sharing options...
elfert Posted November 12, 2012 Author Share Posted November 12, 2012 (edited) Thanks Lee Mac ...but...it was not spot on. I will try to explain again: The User have to give the following: - length of one of the horizontal x line segment. (Marked red) - start point. (Marked red) - end point. (Marked red) 1. The code have calculate the horizontal y line segments when the user have given start and end point. It not important how long y is. (Marked green) 2. At the start point it has to be a X line segment and just before endpoint there has to be a Horizontal X line segment. 3. The distance between X line segment and Y line segment is vertical always 20mm. 4. The poly line have to change direction according to the first post i write in this thread. Thx in advance...Lee Mac. Edited November 12, 2012 by elfert failure Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 12, 2012 Share Posted November 12, 2012 Great codes Lee . elfert , why do not you give yourself a favor and try to learn from the plenty examples in this post ? Quote Link to comment Share on other sites More sharing options...
elfert Posted November 12, 2012 Author Share Posted November 12, 2012 Great codes Lee . elfert , why do not you give yourself a favor and try to learn from the plenty examples in this post ? LEE MAC i am sorry if i did't 'a one step to far' in the last post. I wasn't a bad code you made there but i wasn't what am i seeking. I would try to fool around / change it. But i would be more easy task if the was a. ;;Explanation to every line what i does. And to Tharwat: Actually You code wasn't far of what i am seeking...and i could try to fool around/ change it but i would be more easy if the there was an ;;Explanation to every line what i does. I asked about this see page 1: Tha****: - can you do some 'explanation what the code does. Then i could better understand the code and maybe change it. I also know this is not a free lisp code forum ... every body have to learn and work to make it function. It would be a hard job to decipher every line of code to novice user like me. Sorry guys Quote Link to comment Share on other sites More sharing options...
BIGAL Posted November 13, 2012 Share Posted November 13, 2012 Start learning by brushing up on the polar command this works out the next point along the pline. newpt = (Polar pt angle distance) Some more hints take pt1 pt2 get the "distance" between them divide by the horizontal step length this is how many times you need to "repeat" horizontal line, your line type is made of 4 steps right, up, right, down and a last step the remainder line. Then your proceedure becomes pt1 pt2 height width right up right down right up right down and so on you start the pline command and do a repeat for as many as required. Lee as usual has taken the project to a top level and enhanced it by allowing drag. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 13, 2012 Share Posted November 13, 2012 1. The code have calculate the horizontal y line segments when the user have given start and end point. It not important how long y is. (Marked green) Unless there is a specified number of 'x' segments of a given length, the calculated 'y' segments will be simply the division of the remainder of the distance between the two picked points divided by the length of the 'x' segments, by the number of 'x' segments minus one - this will be a small distance indeed. Great codes Lee . Many thanks Tharwat Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 13, 2012 Share Posted November 13, 2012 Unless there is a specified number of 'x' segments of a given length, the calculated 'y' segments will be simply the division of the remainder of the distance between the two picked points divided by the length of the 'x' segments, by the number of 'x' segments minus one - this will be a small distance indeed. To demonstrate this point: ([color=BLUE]defun[/color] c:zigzag ( [color=BLUE]/[/color] a d h i l n p q x y ) ([color=BLUE]setq[/color] x 10.0 h 20.0 ) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] p ([color=BLUE]getpoint[/color] [color=MAROON]"\n1st Point: "[/color])) ([color=BLUE]setq[/color] q ([color=BLUE]getpoint[/color] [color=MAROON]"\n2nd Point: "[/color] p)) ([color=BLUE]setq[/color] p ([color=BLUE]trans[/color] p 1 0) q ([color=BLUE]trans[/color] q 1 0) a ([color=BLUE]angle[/color] p q) d ([color=BLUE]distance[/color] p q) i ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0) n ([color=BLUE]fix[/color] ([color=BLUE]/[/color] d x)) ) ) ([color=BLUE]if[/color] ([color=BLUE]<[/color] 1 n) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] y ([color=BLUE]/[/color] ([color=BLUE]rem[/color] d x) ([color=BLUE]1-[/color] n))) ([color=BLUE]repeat[/color] ([color=BLUE]1-[/color] n) ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 p) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p a x))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p ([color=BLUE]-[/color] a i) h))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p a y))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p ([color=BLUE]+[/color] a i) h))) l) ) ) ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] ([color=BLUE]list[/color] '(000 . [color=MAROON]"LWPOLYLINE"[/color]) '(100 . [color=MAROON]"AcDbEntity"[/color]) '(100 . [color=MAROON]"AcDbPolyline"[/color]) ([color=BLUE]cons[/color] 90 ([color=BLUE]1+[/color] ([color=BLUE]length[/color] l))) '(70 . 0) ) ([color=BLUE]reverse[/color] ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]polar[/color] p a x)) l)) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nDistance too small."[/color]) ) ) ([color=BLUE]princ[/color]) ) [ rather messy code ] Quote Link to comment Share on other sites More sharing options...
elfert Posted November 20, 2012 Author Share Posted November 20, 2012 Thanks Lee Mac that's a great code you made there..i took the liberty to change some of it that part of it that i have little knowledge to change. (defun c:zigzag ( / a d h i l n p q x y ) (setq h 20.0) (if (and (setq x (getreal "\nWeld legnth: ")) (setq p (getpoint "\n1st Point: ")) (setq q (getpoint "\n2nd Point: " p)) (setq p (trans p 1 0) q (trans q 1 0) a (angle p q) d (distance p q) i (/ pi 2.0) n (fix (/ d x)) ) ) (if (< 1 n) (progn (setq y (/ (rem d x) (1- n))) (repeat (1- n) (setq l (cons (cons 10 p) l) l (cons (cons 10 (setq p (polar p a x))) l) l (cons (cons 10 (setq p (polar p (- a i) h))) l) l (cons (cons 10 (setq p (polar p a y))) l) l (cons (cons 10 (setq p (polar p (+ a i) h))) l) ) ) (entmake (append (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (1+ (length l))) '(70 . 0) ) (reverse (cons (cons 10 (polar p a x)) l)) ) ) ) (princ "\nDistance too small.") ) ) (princ) ) You right about that the y line segment is very small. But i need the to change the code so the y line segment is calculate like in this example: Let we say that the distance between the 1 point and 2 point is 160mm. The weld length is 25mm. (X line segment) Then code should calculate the y line segment to be 20mm. Hope this help! I have read...and...read...but i simple can't find the place to change the code please....please....help. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 20, 2012 Share Posted November 20, 2012 Let we say that the distance between the 1 point and 2 point is 160mm.The weld length is 25mm. (X line segment) Then code should calculate the y line segment to be 20mm. Unless I'm overlooking something obvious, by what relationship are you calculating the length of Y to be 20mm? 80% of X? 160/25 = 6.4, 6x25 = 150, 160-150 = 10, 10x2 = 20? Quote Link to comment Share on other sites More sharing options...
elfert Posted November 21, 2012 Author Share Posted November 21, 2012 Unless I'm overlooking something obvious, by what relationship are you calculating the length of Y to be 20mm? 80% of X? 160/25 = 6.4, 6x25 = 150, 160-150 = 10, 10x2 = 20? First i need to find out how many X line segments i need between the 2 points: 160/2 = 80 , 80/25 = 3.2 , (3+1) = 4 line segments. Second i need to out how many Y line segments i need between the 2 points: 160/25 = 6,4 this i round off to 6, (6+1) - 4 line segments = 3 line segments. This means that the length of y line segment is. 160-(4x25)=60 , 60/3=20mm. Check if i am correct: (4*25)+(3*20) = 160mm. yes it fits. I hope this helps....Thx lee mac. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 21, 2012 Share Posted November 21, 2012 Simplifying your calculations, try this quick mod: ([color=BLUE]defun[/color] c:zigzag ( [color=BLUE]/[/color] a d h i l n p q x y ) ([color=BLUE]setq[/color] h 20.0) ([color=BLUE]if[/color] ([color=BLUE]and[/color] ([color=BLUE]setq[/color] x ([color=BLUE]getdist[/color] [color=MAROON]"\nWeld Length: "[/color])) ([color=BLUE]setq[/color] p ([color=BLUE]getpoint[/color] [color=MAROON]"\n1st Point: "[/color])) ([color=BLUE]setq[/color] q ([color=BLUE]getpoint[/color] [color=MAROON]"\n2nd Point: "[/color] p)) ([color=BLUE]setq[/color] p ([color=BLUE]trans[/color] p 1 0) q ([color=BLUE]trans[/color] q 1 0) a ([color=BLUE]angle[/color] p q) d ([color=BLUE]distance[/color] p q) i ([color=BLUE]/[/color] [color=BLUE]pi[/color] 2.0) n ([color=BLUE]fix[/color] ([color=BLUE]/[/color] d x 2.0)) ) ) ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 n) ([color=BLUE]progn[/color] ([color=BLUE]setq[/color] y ([color=BLUE]/[/color] ([color=BLUE]-[/color] d ([color=BLUE]*[/color] x ([color=BLUE]1+[/color] n))) n)) ([color=BLUE]repeat[/color] n ([color=BLUE]setq[/color] l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 p) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p a x))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p ([color=BLUE]-[/color] a i) h))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p a y))) l) l ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]setq[/color] p ([color=BLUE]polar[/color] p ([color=BLUE]+[/color] a i) h))) l) ) ) ([color=BLUE]entmake[/color] ([color=BLUE]append[/color] ([color=BLUE]list[/color] '(000 . [color=MAROON]"LWPOLYLINE"[/color]) '(100 . [color=MAROON]"AcDbEntity"[/color]) '(100 . [color=MAROON]"AcDbPolyline"[/color]) ([color=BLUE]cons[/color] 90 ([color=BLUE]1+[/color] ([color=BLUE]length[/color] l))) '(70 . 0) ) ([color=BLUE]reverse[/color] ([color=BLUE]cons[/color] ([color=BLUE]cons[/color] 10 ([color=BLUE]polar[/color] p a x)) l)) ) ) ) ([color=BLUE]princ[/color] [color=MAROON]"\nDistance too small."[/color]) ) ) ([color=BLUE]princ[/color]) ) Quote Link to comment Share on other sites More sharing options...
elfert Posted November 25, 2012 Author Share Posted November 25, 2012 Thanks lee mac for the last code that is was seeking in last week. (Great) But to my surprise on Thursday i have to make another routine where the user guess a length between x line segment. I called this line segment y1. Then the code have to calculate the y line segment and add this to the y1 line segment to give the the space between the x line segments. An example: User input: Distance between 1 st. point and 2.nd is 135mm. Weld length x is 25mm. A guess weld length y1 is 20mm Lisp routine: - Then the code should calculate the y line segment to 10mm and draw the polyline. I have tried to make some change to code but no luck: (defun c:wzz ( / a d h i l n p q x y y1) (setq h 20.0) (if (and (setq x (getdist "\nWeld Length: ")) (setq y1 (getreal "\nGuess a Weld length space: ")) (setq p (getpoint "\n1st Point: ")) (setq q (getpoint "\n2nd Point: " p)) (setq p (trans p 1 0) q (trans q 1 0) a (angle p q) d (distance p q) i (/ pi 2.0) n (fix (/ d (x+y1))) ) ) (if (< 0 n) (progn (setq y (/ (- d (* x (1+ n))) n)) (repeat n (setq l (cons (cons 10 p) l) l (cons (cons 10 (setq p (polar p a x))) l) l (cons (cons 10 (setq p (polar p (- a i) h))) l) l (cons (cons 10 (setq p (polar p a y))) l) l (cons (cons 10 (setq p (polar p (+ a i) h))) l) ) ) (entmake (append (list '(000 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (1+ (length l))) '(70 . 0) ) (reverse (cons (cons 10 (polar p a x)) l)) ) ) ) (princ "\nDistance too small.") ) ) (princ) ) I pretty sure that math is something like this: n=d/x+y1+y y=((d-x)/n)-(x+y1) This means from d=135mm x=25mm y1=20mm n=135/25+20+10=2,4545 = 2. y=((135-25)/2)-(25+20)=10mm. Please help! Quote Link to comment Share on other sites More sharing options...
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.