aswad Posted July 3, 2015 Share Posted July 3, 2015 Hi Guys as you can see , this is the coding for doing rectangle routine by put the length of rec .. the problem is , i want to put the circle in the rectangle in a row which is i need to specify how much the circle i want .. the length between circle must be 109.00 inch (defun c:SREC ( / pt h) (princ " RECTANGLE ") (if (and (setq pt (getpoint "\nSpecify rectangle start point: ")) (setq h (getreal "\nEnter the rectangle length: "))) (command "._rectang" pt "_dimensions" ( + 0 h) h pt) (prompt "\n** Invalid input ** ")) (princ)) : the example is attached : I really appreciate for those who willing to help me :):D 2750 , 109.dwg Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 3, 2015 Share Posted July 3, 2015 (edited) As you have already started here is some advice rather than code, hopefully it makes sense, if your stuck post again, a good example for learning lisp. I would like to think you can learn from here rather than others just post code answer. You can do this in a couple of ways but look at the math length =L Offset = 109.0 Num = divide L/109 (set num (/ L offset)) Remainder (* L (- num (fix num))) Pt x (car pt) pt y (cadr pt) Is remainder > 2*circ dia (if (> (* 2.0 dia... if yes then continue if no num=num-1 circle to close to edge (setq num (- num 1)) Work out now 1st circle placement (set q newpt (polar pt ....(polar pt .. X across y up a double polar then copy and repeat num times across (repeat (fix num).... do again for top row you could use array also rather than copy or circle command Edited July 3, 2015 by BIGAL Quote Link to comment Share on other sites More sharing options...
tombu Posted July 3, 2015 Share Posted July 3, 2015 Assuming height is constant and the length varies you could create a dynamic block that would add or remove circles depending on the length. It could also be done easily in lisp, just a suggestion in case you might be more comfortable doing it that way. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted July 4, 2015 Share Posted July 4, 2015 Good idea tombu as the spacing is defined in the dynamic block if you change this value then it updates straight away. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted July 4, 2015 Share Posted July 4, 2015 Hi, The Dynamic Block is the best choice with this trick as recommended by tombu but here is my lisp program if you don't want to go with Dynamic Block option . (defun c:Test (/ _C rad spc len pt r p d) ;; Tharwat 04.07.2015 ;; (setq rad 3.5 spc 109.0 ) (if (and (setq len (getdist "\nSpecify Length of Rectangle :")) (if (< 109 len) t (progn (princ "\nLength of rectangle is smaller than 109.0 !") nil ) ) (setq pt (getpoint "\nSpecify Rectangle Base point :")) ) (progn (defun _C (n _p) (repeat n (entmakex (list '(0 . "CIRCLE") (cons 10 _p) (cons 40 rad))) (setq _p (polar _p 0. spc)) ) ) (setq r (1+ (fix (/ len 109.0))) p (polar (polar pt 0. (setq d (/ (- len (* (fix r) 109.)) 2.))) (* pi 1.5) 12. ) ) (command "_.rectang" "_none" pt "_none" (polar (polar pt 0. len) (* pi 1.5) len)) (_C r p) (_C r (setq p (polar (polar pt (* pi 1.5) (- len 12.)) 0. d)) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
iconeo Posted July 20, 2015 Share Posted July 20, 2015 2750 , 109.dwg I like dynamic blocks... 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.