有点复杂的autolisp编程问题
哪位大佬帮忙编写一个autolisp小程序:将选中的若干个圆的圆心相连,按下一个命令可在刚连圆心的所有直线中点画一条中点重合的10mm的垂直线,再按下一个命令后将所有垂直...
哪位大佬帮忙编写一个autolisp小程序:将选中的若干个圆的圆心相连,按下一个命令可在刚连圆心的所有直线中点画一条中点重合的10mm的垂直线,再按下一个命令后将所有垂直线向两边各偏移2mm,并删除原本的垂直线,小弟感激不尽!!
展开
展开全部
;;QQ:406868625
(defun c:addMidLines(/ oldOsmode ss count num midPointList angList ang pmid ssPer ang0 p0 p01 p1 p2 tmpStr)
(setq oldOsmode (getvar "osmode"))
(setvar "osmode" 0)
(prompt "请选择圆:")
(setq ss (ssget '((0 . "CIRCLE"))))
(setq count 1
num (sslength ss)
)
(setq midPointList '())
(setq angList '())
(repeat (1- num)
(setq p1 (cdr (assoc 10 (entget (ssname ss (1- count)))))
p2 (cdr (assoc 10 (entget (ssname ss count))))
)
(setq ang (angle p1 p2)
pmid (polar p1 ang (* 0.5 (distance p1 p2)))
)
(setq midPointList (append midPointList (list pmid)))
(setq angList (append angList (list ang)))
(command ".line" p1 p2 nil)
(setq count (1+ count))
)
(setq ssPer (ssadd))
(setq len (* 0.5 10))
(setq count 0)
(setq num (length midPointList))
(repeat num
(setq p0 (nth count midPointList))
(setq ang0 (nth count angList))
(setq p1 (polar p0 (+ ang0 (* 0.5 pi)) len)
p2 (polar p0 (- ang0 (* 0.5 pi)) len)
)
(command ".line" p1 p2 nil)
(ssadd (entlast) ssper)
(setq count (1+ count))
)
(setq tmpStr (getstring "按任意键继续... "))
(command ".erase" ssper "")
(setq dis0 2.0)
(setq count 0)
(repeat num
(setq p0 (nth count midPointList))
(setq ang0 (nth count angList))
(setq p01 (polar p0 ang0 dis0))
(setq p1 (polar p01 (+ ang0 (* 0.5 pi)) len)
p2 (polar p01 (- ang0 (* 0.5 pi)) len)
)
(command ".line" p1 p2 nil)
(setq p01 (polar p0 (+ ang0 pi) dis0))
(setq p1 (polar p01 (+ ang0 (* 0.5 pi)) len)
p2 (polar p01 (- ang0 (* 0.5 pi)) len)
)
(command ".line" p1 p2 nil)
(setq count (1+ count))
)
(setvar "osmode" oldOsmode)
(princ)
)
(defun c:addMidLines(/ oldOsmode ss count num midPointList angList ang pmid ssPer ang0 p0 p01 p1 p2 tmpStr)
(setq oldOsmode (getvar "osmode"))
(setvar "osmode" 0)
(prompt "请选择圆:")
(setq ss (ssget '((0 . "CIRCLE"))))
(setq count 1
num (sslength ss)
)
(setq midPointList '())
(setq angList '())
(repeat (1- num)
(setq p1 (cdr (assoc 10 (entget (ssname ss (1- count)))))
p2 (cdr (assoc 10 (entget (ssname ss count))))
)
(setq ang (angle p1 p2)
pmid (polar p1 ang (* 0.5 (distance p1 p2)))
)
(setq midPointList (append midPointList (list pmid)))
(setq angList (append angList (list ang)))
(command ".line" p1 p2 nil)
(setq count (1+ count))
)
(setq ssPer (ssadd))
(setq len (* 0.5 10))
(setq count 0)
(setq num (length midPointList))
(repeat num
(setq p0 (nth count midPointList))
(setq ang0 (nth count angList))
(setq p1 (polar p0 (+ ang0 (* 0.5 pi)) len)
p2 (polar p0 (- ang0 (* 0.5 pi)) len)
)
(command ".line" p1 p2 nil)
(ssadd (entlast) ssper)
(setq count (1+ count))
)
(setq tmpStr (getstring "按任意键继续... "))
(command ".erase" ssper "")
(setq dis0 2.0)
(setq count 0)
(repeat num
(setq p0 (nth count midPointList))
(setq ang0 (nth count angList))
(setq p01 (polar p0 ang0 dis0))
(setq p1 (polar p01 (+ ang0 (* 0.5 pi)) len)
p2 (polar p01 (- ang0 (* 0.5 pi)) len)
)
(command ".line" p1 p2 nil)
(setq p01 (polar p0 (+ ang0 pi) dis0))
(setq p1 (polar p01 (+ ang0 (* 0.5 pi)) len)
p2 (polar p01 (- ang0 (* 0.5 pi)) len)
)
(command ".line" p1 p2 nil)
(setq count (1+ count))
)
(setvar "osmode" oldOsmode)
(princ)
)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询