Samuela89 Posted April 12, 2013 Posted April 12, 2013 I have been asked to design a tri-gasket whereby the holes around the gasket are user defined. i am having problems with the code that defines where the holes are on the gasket ensuring they are equally spaced whenever the user changes the input. Any help would be much appreciated. attached is my code so far and a picture of what i want to achieve. tri gasket.LSP Quote
ReMark Posted April 12, 2013 Posted April 12, 2013 Had you considered creating a dynamic block that utilized constraints? Quote
SLW210 Posted April 12, 2013 Posted April 12, 2013 Why did you sign in with a new user name? Why didn't you just continue your other thread? I moved this thread to the AutoLISP, Visual LISP & DCL forum. Quote
Samuela89 Posted April 12, 2013 Author Posted April 12, 2013 Thanks for your reply ReMark, is there another way than using blocks as i dont want it to use blocks, i have had a look at blocks but i would prefer to use a different method if possible, im basically stuck on the correct command that determines the hole pattern along the line. SLW210 , i havent signed in with a different user name, there are several people in my class so this thread may have been previously posted by another class mate. Quote
SLW210 Posted April 12, 2013 Posted April 12, 2013 (edited) That was my second suspicion, several using the same IP, that's why I didn't combine the threads. Still it would have been nice for you to add on to your classmates post since they are related. Looks like an AutoLISP assignment? Did you look at your classmates thread? Edited April 12, 2013 by SLW210 Quote
Samuela89 Posted April 12, 2013 Author Posted April 12, 2013 Yeh its an assignment. I looked earlier after you said this had been posted before but could find much relating to the command im after. I have had a look at some links on the web about the type of pattern im after, am i right in thinking i need a rectangular array command to copy the circle around the triangle?? i have a polar array command already but dont know how to change it to rectangular, any suggestions. I appreciate any help you can give. thanks Quote
ReMark Posted April 12, 2013 Posted April 12, 2013 Aren't there but three options in 2011...Rectangular, Path and Polar? Quote
Samuela89 Posted April 12, 2013 Author Posted April 12, 2013 Yeh, i think so, do you know how to interpret the correct command in auto lisp ? Quote
ReMark Posted April 12, 2013 Posted April 12, 2013 Sorry, that is not something I am familiar with. You'll have to wait for one of our lisp gurus to help you out there. I would have expected that to have been covered in the other student's thread since it specifically mentioned using lisp. Quote
SLW210 Posted April 12, 2013 Posted April 12, 2013 Here is the other thread.. equally spaced holes around a triangle Quote
Tharwat Posted April 12, 2013 Posted April 12, 2013 Try this draft at the moment . (vl-load-com) (defun c:Test (/ _Circle ->lst w n p1 p2 l ang e del pt1 pt2 pt3) ;;;----- Tharwat 13. April. 2013 -----;;; (defun _Circle (pt dia) (entmakex (list '(0 . "CIRCLE") (cons 10 pt) (cons 40 dia))) ) (defun ->lst (no pt1 pt2 dis dia / p a d1 d2 lst) (setq d1 (/ dis no) d2 d1 p pt1 a (angle pt1 pt2) ) (repeat no (_Circle (polar p a d1) dia) (setq d1 (+ d1 d2)) ) lst ) (if (and (setq w (getdist "\n Specify width between Triangle :")) (setq n (getint "\n Specify number of circles :")) (setq p1 (getpoint "\n Specify start point :")) (setq p2 (getpoint "\n Specify end point :" p1)) (if (not (> (setq l (distance p1 p2)) w)) (progn (princ "\n Length of triangle must be at least longer 3 times than the width <!>" ) nil ) t ) ) (progn (setq ang (angle p1 p2) n (1+ n) ) (setq e (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") '(90 . 3) '(70 . 1) (cons 10 p1) (cons 10 p2) (cons 10 (polar p2 (+ (+ ang (* pi 0.5)) (/ pi 6.)) l)) ) ) ) (vla-offset (vlax-ename->vla-object e) w) (vla-offset (vlax-ename->vla-object e) (/ w 2.)) (setq del (entlast) pt1 (vlax-curve-getpointatparam del 0) pt2 (vlax-curve-getpointatparam del 1) pt3 (vlax-curve-getpointatparam del 2) ) (->lst n pt1 pt2 (distance pt1 pt2) (/ w 2.)) (->lst n pt2 pt3 (distance pt2 pt3) (/ w 2.)) (->lst n pt3 pt1 (distance pt3 pt1) (/ w 2.)) (foreach p (list pt1 pt2 pt3) (_Circle p (/ w 2.)) ) (entdel del) ) ) (princ "\nWritten by Tharwat Al Shoufi") (princ) ) Quote
Stefan BMR Posted April 12, 2013 Posted April 12, 2013 (edited) @Samuela89 I will not post full program but just a few indications. I hope you will find a way to put all together. First, grab all your inputs (setq p1 (getpoint "\nStart point: ")) (setq p2 (getpoint p1 "\nEnd point: ")) (setq w (getdist "\nWidth: ")) (setq n (getint "\nNumber of holes: ")) Here you need to test if all inputs are valid. Now lets calculate the constants within program (setq l_ext (distance p1 p2) ;length of exterior triangle l_int (- l_ext (* w 2.0 (sqrt 3.0))) ;length of interior triangle = l_ext-2*w/tan(30); tan(30)= 1/sqrt(3) d_hol (/ (+ l_int l_ext) (* 2.0 (- n 1))) ;dist between holes = [(l_ext+l_int)/2]/(n-1) ) The relative position of some elements in this figure is the same for each of triangle's sides, so we can use this property in a loop. See attached image for notations. I used colors to show objects created in each step in repeat loop. (repeat 3 (setq a (angle p1 p2) p3 (polar p1 (+ a (/ pi 6.0)) (* 2.0 w)) p4 (polar p3 a l_int) p5 (polar p1 (+ a (/ pi 6.0)) w) ) [color=blue]<draw_line p1 p2> <draw_line p3 p4> <draw_circle p5 radius>[/color] (repeat (- n 2) (setq p5 (polar p5 a d_hol)) [color=blue]<draw_circle p5 radius>[/color] );end repeat n-2 (setq p2 p1 p1 (polar p1 (+ a (/ pi 3.0)) l_ext) );end repeat 3 Edited April 15, 2013 by Stefan BMR Quote
neophoible Posted April 15, 2013 Posted April 15, 2013 From your program thus far, it appears you can figure out how to find the points to draw the inner and outer triangles. The holes are along a triangle as well. All you have to do is divide the side length of this third (middle) triangle by the number of holes along a side minus one to get your distances to the intermediate points. 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.