该lisp可能对任何寻求多个偏移样条线的人有用,但可以选择创建样条线,但只需要1个例程,而不是3或4个例程
方法创建具有不同选项的样条线拾取点偏移,它会一直接受输入,直到按为止,可以是3个选项中的任何一个。
您可以用3种不同的方式输入选项
输入3,它将向右偏移3个单位,宽度为零-3表示向左偏移3个单位。
输入15,3,它将使pline偏移15个单位,宽度为3
输入15,3140,它将使pline偏移15个单位,宽度为3,颜色为140
代码可以很容易地更改以支持层名称
输入15,3,电气
- ; multiple pline including width & col function
- ; single entry is offset only
- ; two values 3,1 means offset 3 with width 1
- ; three values 3,2,1 means offset 3 with start width 2 end 1
- ; by Alan H March 2014
- ; thanks to Lee-mac for this defun
- (defun _csv->lst ( str / pos )
- (if (setq pos (vl-string-position 44 str))
- (cons (substr str 1 pos) (_csv->lst (substr str (+ pos 2))))
- (list str)
- )
- )
- (defun aH:multpl ( / pt1 pt2 pt3 obj1 obj2 dist1 pwidst plcol lst howmany)
- (setvar "PLINEWID" 0) ;set PL width to 0
- (command "_pline")
- (while (= (getvar "cmdactive") 1 ) (command pause)
- )
- (setq pt1 nil)
- (setq obj1 (entlast)) ; grab pline
- (setq pt1 (getvar "lastpoint")) ; last pt
- (command "circle" pt1 1.0) ; do something smart here like screen scale for circle
- (setq obj2 (entlast)) ;grab circle
- (setq pt2 (vlax-invoke (vlax-ename->vla-object obj1) 'intersectWith (vlax-ename->vla-object obj2) acextendnone)); find int point
- (setq ang (angle pt1 pt2)) ;angle of pline now know left - right
- (command "erase" "last" "") ; remove circle
- (while (/= (setq offval (getstring "Enter offset distance -ve for left")) "")
- (setq lst (cons (_csv->lst offval) lst))
- (setq howmany (length (nth 0 lst))) ;determines single or multi answer
- (if (= howmany 1)(setq dist1 (atof (nth 0 (nth 0 lst)))) )
- (if (= howmany 2)
- (progn
- (setq dist1 (atof (nth 0 (nth 0 lst))))
- (setq pwidst (atof (nth 1 (nth 0 lst))))
- ) ; progn
- ); if
- (if (= howmany 3)
- (progn
- (setq dist1 (atof (nth 0 (nth 0 lst))))
- (setq pwidst (atof (nth 1 (nth 0 lst))))
- (setq pLcol (atof (nth 2 (nth 0 lst))))
- ) ; progn
- ); if
- (if (> dist1 0.0)
- (setq pt3 (polar pt2 (+ ang (/ pi 2.0)) (abs dist1)))
- (setq pt3 (polar pt2 (- ang (/ pi 2.0)) (abs dist1)))
- )
- (command "offset" (abs dist1) obj1 pt3 "")
- (if (>= howmany 2)
- (vla-put-ConstantWidth (vlax-ename->vla-object (entlast)) pwidst)
- )
- (if (= howmany 3)
- (vla-put-color (vlax-ename->vla-object (entlast)) plcol) ; note color as a number
- )
- ) ; end while
- (command "erase" obj1 "")
- ) ; end defun
- (AH:multpl)
- (princ)
|