圆形的嵌套模式
我有一个关于圆形零件嵌套模式的lisp,如下所示,代码的工作方式类似于第一个图,但我希望它类似于第二个图。我想知道如何更正这段代码?(defun dtr(a)
(*pi(/a 180.0))
)
(defun gpuser()
(setq sp(getpoint“\n路径的起始点:”)
(setq ep(getpoint“\n路径的第二点:”)
(setq hwidth(getdist“\n路径的自宽度:”sp))
(setq trad(getdist“nRadius of tiles:”sp))
(setq-tspac(getdist“\n分片之间的间距:“sp”)
(setq pangle(角度sp ep))
(setq plength(距离sp ep))
(设置宽度(*2宽度))
(setq angp90(+pangle(dtr 90)));路径角度+90度
(setq angm90(-pangle(dtr 90)));路径角度-90度
)
(取消提款()
(命令“pline”
(setq p(极性sp angm90 hwidth))
(setq p(极性p pangle plength))
(setq p(极性p angp90宽度))
(极p(+pangle(dtr 180))正压)
“关闭”
))
(defun drow(pd偏移)
(setq pfirst(极性sp pangle pd))
(setq pctile(极轴pfirst angp90偏移)
(setq pltile pctile)
(虽然(
(命令“圆形”pltile trad)
(setq pltile)
(polar pltile angp90(+tspac trad)))
(setq pltile(极性pctile angm90(+tspac trad trad)))
(虽然(
(命令“圆形”pltile trad)
(setq pltile)
(polar pltile angm90(+tspac tradЮЮ)Ю)
(defun drawtiles()
(setq pdist(+trad tspac))
(setq off 0.0)
(虽然(
(drow pdist关闭)
(setq pdist
(+pdist(*(+tspac trad trad)(sin(dtr 60 107;)а)
(如果(=关0.0)
(抵消(*+tspac trad)(cos(dtr 60)))
(抵消0.0)))
(defun C:路径()
(gpuser)
(setq sblip(getvar“blipmode”))
(setq-scmde(getvar“cmdecho”))
(setvar“blipmode”0)
(setvar“cmdecho”0)
(提款)
(图纸)
(setvar“blipmode”sblip)
(setvar“cmdecho”scmde)
(普林斯)
)
提前感谢您的帮助 (defun c:路径()
我为这个错误道歉。 Kaan,从这里快速阅读将代码包含在标记代码中。
这两个数字有什么不同? (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)
)并启用正交(F8) 谢谢你的帮助,M.R。 我刚刚编写了这个快速代码,希望它能满足您的需要
这是矩形法。
(defun gpuser ()
(setq sp (getpoint "\nStart point of path: "))
(setq ep (getpoint sp "\nEnd point of path: "))
...
谢谢你的代码,我试过了,但没用。我认为这是一个关于维度的问题。我想知道你是否试过? 它应该可以工作,但我编写代码的方式与您之前发布的不同。
首先,你应该选择一个点,第二个点应该代表一个矩形,然后是圆的半径[平铺]和圆之间的空间。 虽然圆的半径很小,但它会发出警报。 正确,小于运算符有一个小错误,现在我可以修复它了。
请再试一次
页:
[1]
2