kaan27 Posted September 15, 2013 Posted September 15, 2013 I have a lisp about nesting pattern for circular part as follows ,the code works like the first figure ,but I want it to be like in the second figure. I wonder how this code can be corrected? (defun dtr (a) (* pi (/ a 180.0)) ) (defun gpuser () (setq sp (getpoint "\nStart point of path: ")) (setq ep (getpoint "\nEnd point of path: ")) (setq hwidth (getdist "\nHalf width of path: " sp)) (setq trad (getdist "nRadius of tiles: " sp)) (setq tspac (getdist "\nSpacing between tiles: " sp)) (setq pangle (angle sp ep)) (setq plength (distance sp ep)) (setq width (* 2 hwidth)) (setq angp90 (+ pangle (dtr 90))) ; Path angle + 90 deg (setq angm90 (- pangle (dtr 90))) ; Path angle - 90 deg ) (defun drawout () (Command "pline" (setq p (polar sp angm90 hwidth)) (setq p (polar p pangle plength)) (setq p (polar p angp90 width)) (polar p (+ pangle (dtr 180)) plength) "close" )) (defun drow (pd offset) (setq pfirst (polar sp pangle pd)) (setq pctile (polar pfirst angp90 offset)) (setq pltile pctile) (while ( (Command "circle" pltile trad) (setq pltile (polar pltile angp90 (+ tspac trad trad)))) (setq pltile (polar pctile angm90 (+ tspac trad trad))) (while ( (Command "circle" pltile trad) (setq pltile (polar pltile angm90 (+ tspac trad trad))))) (defun drawtiles () (setq pdist (+ trad tspac)) (setq off 0.0) (while ( (drow pdist off) (setq pdist (+ pdist (* (+ tspac trad trad) (sin (dtr 60))))) (if (= off 0.0) (setq off (* (+ tspac trad trad) (cos (dtr 60)))) (setq off 0.0)))) (defun C:PATH () (gpuser) (setq sblip (getvar "blipmode")) (setq scmde (getvar "cmdecho")) (setvar "blipmode" 0) (setvar "cmdecho" 0) (drawout) (drawtiles) (setvar "blipmode" sblip) (setvar "cmdecho" scmde) (princ) ) Thanks in advance for your helps Quote
kaan27 Posted September 15, 2013 Author Posted September 15, 2013 (defun c: PATH () I apologize for the mistake. Quote
Tharwat Posted September 15, 2013 Posted September 15, 2013 Kaan , take a quick read about to include the codes in a tag codes from HERE . What is the difference between the two figures ? Quote
kaan27 Posted September 15, 2013 Author Posted September 15, 2013 (defun dtr (a) (* pi (/ a 180.0)) ) (defun gpuser () (setq sp (getpoint "\nStart point of path: ")) (setq ep (getpoint "\nEnd point of path: ")) (setq hwidth (getdist "\nHalf width of path: " sp)) (setq trad (getdist "nRadius of tiles: " sp)) (setq tspac (getdist "\nSpacing between tiles: " sp)) (setq pangle (angle sp ep)) (setq plength (distance sp ep)) (setq width (* 2 hwidth)) (setq angp90 (+ pangle (dtr 90))) ; Path angle + 90 deg (setq angm90 (- pangle (dtr 90))) ; Path angle - 90 deg ) (defun drawout () (Command "pline" (setq p (polar sp angm90 hwidth)) (setq p (polar p pangle plength)) (setq p (polar p angp90 width)) (polar p (+ pangle (dtr 180)) plength) "close" )) (defun drow (pd offset) (setq pfirst (polar sp pangle pd)) (setq pctile (polar pfirst angp90 offset)) (setq pltile pctile) (while (< (distance pfirst pltile) (- hwidth trad)) (Command "circle" pltile trad) (setq pltile (polar pltile angp90 (+ tspac trad trad)))) (setq pltile (polar pctile angm90 (+ tspac trad trad))) (while (< (distance pfirst pltile) (- hwidth trad)) (Command "circle" pltile trad) (setq pltile (polar pltile angm90 (+ tspac trad trad))))) (defun drawtiles () (setq pdist (+ trad tspac)) (setq off 0.0) (while (<= pdist (- plength trad)) (drow pdist off) (setq pdist (+ pdist (* (+ tspac trad trad) (sin (dtr 60))))) (if (= off 0.0) (setq off (* (+ tspac trad trad) (cos (dtr 60)))) (setq off 0.0)))) (defun C:PATH () (gpuser) (setq sblip (getvar "blipmode")) (setq scmde (getvar "cmdecho")) (setvar "blipmode" 0) (setvar "cmdecho" 0) (drawout) (drawtiles) (setvar "blipmode" sblip) (setvar "cmdecho" scmde) (princ) ) Thanks for the warning Tharwat. Drawing seems with angle on the screen the first figure, but I don't understand why drawing angle. Quote
marko_ribar Posted September 15, 2013 Posted September 15, 2013 (defun gpuser () (setq sp (getpoint "\nStart point of path: ")) (setq ep (getpoint [highlight]sp[/highlight] "\nEnd point of path: ")) ... And turn on ORTHO ( F8 ) Quote
Tharwat Posted September 15, 2013 Posted September 15, 2013 (edited) I have just wrote this quickie code and hope it would meet your needs It's rectangular method . (defun c:Test (/ p1 p2 p3 rd sp w h a b l1 l2 w1 h1 h p pt ang) ;; Author ; Tharwat Al Shoufi 15. Sep. 2013 ;;; (if (and (setq p1 (getpoint "\n Specify first point of Path :")) (setq p2 (getcorner "\n End point :" p1)) (setq rd (getdist "\n Specify Radius of Tile [Circle] :")) (setq sp (getdist "\n Specify Spaceing between Tiles :")) (if (> (setq w (distance p1 (list (car p2) (cadr p1) 0.))) (* rd 2.) ) t (progn (alert "Diameter of Tile is longer than the Width of Rectangle <!>" ) nil ) ) (if (> (setq h (distance p1 (list (car p1) (cadr p2) 0.))) (* rd 2.) ) t (progn (alert "Diameter of Tile is longer than the Height of Rectangle <!>" ) nil ) ) ) (progn (setq a (apply 'min (mapcar 'car (list p1 p2))) b (apply 'max (mapcar 'cadr (list p1 p2))) l1 (+ rd sp) w1 l1 l2 (+ rd sp) h1 l2 p (list a b 0.) ang (angle p (if (> (cadr p1) (cadr p2)) (list (car p2) (cadr p1) 0.) (list (car p1) (cadr p2) 0.) ) ) p (polar (list a b 0.) (+ ang (* pi 1.5)) l1) p3 p ) (repeat (fix (/ h (+ sp rd rd))) (repeat (fix (/ w (+ sp rd rd))) (setq pt (polar p3 ang l1) l1 (+ l1 (+ w1 rd)) ) (entmakex (list '(0 . "CIRCLE") (cons 40 rd) (cons 10 pt))) ) (setq p3 (polar p (+ ang (* pi 1.5)) (+ rd l2)) l2 (+ l2 (+ h1 rd)) l1 w1 ) ) (command "_.rectang" "_none" p1 "_none" p2) ) ) (princ) ) Edited September 16, 2013 by Tharwat Quote
kaan27 Posted September 15, 2013 Author Posted September 15, 2013 Tharwat thanks for code, I tried that but, it didn't work.I think it's a problem about dimensions. I wonder if you have tried it? Quote
Tharwat Posted September 15, 2013 Posted September 15, 2013 It should work , but the way that I wrote the code is different than the one you posted earlier . First you should pick a point and the second point should represent a rectangle and after that the radius of the circle [ tile ] and the space between the circles . Quote
kaan27 Posted September 15, 2013 Author Posted September 15, 2013 Although the radius of the circle is small, it gives alert. Quote
Tharwat Posted September 15, 2013 Posted September 15, 2013 Although the radius of the circle is small, it gives alert. Correct , there was a small mistake with the smaller than operator , it is okay now I fix it . Try it one more time please Quote
kaan27 Posted September 16, 2013 Author Posted September 16, 2013 Thanks Tharwat it is work. So how do I get into the rectangle them? That is, I want to appear the rectangle the outside of the shape. Quote
Tharwat Posted September 16, 2013 Posted September 16, 2013 Thanks Tharwat it is work. So how do I get into the rectangle them? That is, I want to appear the rectangle the outside of the shape. You're welcome . Rectangle added to the code . Quote
kaan27 Posted September 16, 2013 Author Posted September 16, 2013 Thanks for your time again Tharwat. Quote
Tharwat Posted September 16, 2013 Posted September 16, 2013 Thanks for your time again Tharwat. You're welcome anytime . Quote
SLW210 Posted September 16, 2013 Posted September 16, 2013 Please edit your original post to include the Code in Code Tags. Quote
kaan27 Posted November 7, 2013 Author Posted November 7, 2013 (defun dtr (a) (* pi (/ a 180.0)) ) (defun gpuser () (setq sp (getpoint "\nStart point of path: ")) (setq ep (getpoint sp "\nEnd point of path: ")) (setq hwidth (getdist "\nHalf width of path: " sp)) (setq trad (getdist "nRadius of tiles: " sp)) (setq tspac (getdist "\nSpacing between tiles: " sp)) (setq pangle (angle sp ep)) (setq plength (distance sp ep)) (setq width (* 2 hwidth)) (setq angp90 (+ pangle (dtr 90))) ; Path angle + 90 deg (setq angm90 (- pangle (dtr 90))) ; Path angle - 90 deg ) (defun drawout () (Command "pline" (setq p (polar sp angm90 hwidth)) (setq p (polar p pangle plength)) (setq p (polar p angp90 width)) (polar p (+ pangle (dtr 180)) plength) "close" )) (defun drow (pd offset) (setq pfirst (polar sp pangle pd)) (setq pctile (polar pfirst angp90 offset)) (setq pltile pctile) (while (< (distance pfirst pltile) (- hwidth trad)) (Command "circle" pltile trad) (setq pltile (polar pltile angp90 (+ tspac trad trad)))) (setq pltile (polar pctile angm90 (+ tspac trad trad))) (while (< (distance pfirst pltile) (- hwidth trad)) (Command "circle" pltile trad) (setq pltile (polar pltile angm90 (+ tspac trad trad))))) (defun drawtiles () (setq pdist (+ trad tspac)) (setq off 0.0) (while (<= pdist (- plength trad)) (drow pdist off) (setq pdist (+ pdist (* (+ tspac trad trad) (sin (dtr 60))))) (if (= off 0.0) (setq off (* (+ tspac trad trad) (cos (dtr 60)))) (setq off 0.0)))) (defun C:PATH () (gpuser) (setq sblip (getvar "blipmode")) (setq scmde (getvar "cmdecho")) (setvar "blipmode" 0) (setvar "cmdecho" 0) (drawout) (drawtiles) (setvar "blipmode" sblip) (setvar "cmdecho" scmde) (princ) ) I wonder if this method can be applied in irregular shapes? 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.