单线变双线
本帖最后由 GDFGFGF 于 2020-12-11 23:54 编辑现在这命令是向外偏移的,怎样改下是向内偏移的呢? 还有本程序处理量大时比较慢,怎样优化下了?望大神指导下!!!感谢
(defun dl_line_drawing ()
(if(= ang1 0)
(progn
(setq pt1 (polar pt_10 (* pi 0.5) r))
(setq pt2 (polar pt_10 (* pi 1.5) (+ r 10)))
)
(progn
(setq pt1 (polar pt_10 (+ ang1 (* pi 0.5)) r))
(setq pt2 (polar pt_10 (+ ang1 (* pi 1.5)) (+ r 10)))
)
)
(command "offset" r ent pt1 "")
(command "offset" r ent pt2 "")
(SETQ j (1+ j))
(entdel ent)
)
;;;
(defun c:SX (/ ss di r j ss_lth ent ent_data ent_type pt_10 pt_11 ang1 x y ri pt1 pt2 )
(setq olderr *error*
*error* clerr)
(setq scmde (getvar "CMDECHO"))
;(command "undo" "group")
;(setq clay (getvar "CLAYER"))
(setq sblip (getvar "BLIPMODE"))
(setq sgrid (getvar "GRIDMODE"))
;(setq shl (getvar "HIGHLIGHT"))
(setq sucsf (getvar "UCSFOLLOW"))
(setvar "CMDECHO" 0)
(setvar "GRIDMODE" 0)
;(setvar "UCSFOLLOW" 0)
(setq old_os (getvar "osmode"))
(setvar "osmode" 0)
(if (null oldscale) (setq oldscale 18.0))
(initget 6)
(setq di (getreal (strcat "\n输入宽度<" (rtos oldscale 2 2)">:")))
(if (null di) (setq di oldscale) (setq oldscale di))
(SETQ SS (ssget))
(setq r (/ di 2))
(setq j 0)
(setq ss_lth 0)
(setq SS_lth (sslength ss))
(WHILE (< j SS_lth)
(setq ent (ssname ss j))
(setq ent_data (entget ent))
(SETQ ent_type (cdr (ASSOC '0 ent_data)))
(IF (or (= ent_type "LINE") (= ent_type "LWPOLYLINE"))
(IF (= ent_type "LINE")
(progn
(setq pt_10 (cdr (assoc '10 ent_data)))
(setq pt_11 (cdr (assoc '11 ent_data)))
(setq ang1 (angle pt_10 pt_11))
(dl_line_drawing)
)
(progn
(setq pt_10 (cdr (assoc '10 ent_data)))
(setq ent_data_n (member (assoc '42 ent_data) ent_data))
(setq pt_11 (cdr (assoc '10 ent_data_n)))
(setq ang1 (angle pt_10 pt_11))
(dl_line_drawing)
)
)
(if (= ent_type "ARC")
(progn
(SETQ x (CADR (ASSOC 10 ent_data)))
(setq y (caddr (assoc 10 ent_data)))
(setq ri (cdr (assoc 40 ent_data)))
(setq pt1 (list (+ 5 (+ x ri)) (+ 5 (+ y ri))))
(setq pt2 (list (- x (/ ri 2)) (- y (/ ri 2))))
(command "offset" r ent pt1 "")
(command "offset" r ent pt2 "")
(SETQ j (1+ j))
(entdel ent)
)
(SETQ j (1+ j))
)
)
)
(setvar "osmode" old_os)
;(command "UCS" "") ; Restore previous UCS
(setvar "BLIPMODE" sblip) ; Restore saved modes
(setvar "GRIDMODE" sgrid)
;(setvar "HIGHLIGHT" shl)
;(setvar "UCSFOLLOW" sucsf)
;(command "undo" "e")
(setvar "CMDECHO" scmde)
(setq *error* olderr)
(princ)
)
(vl-load-com)
(defun c:xs ( / dd ss obj n )
(if (null *dd) (setq *dd 0.5))
(setq dd (getdist "请输入偏移距离:"))
(if (null dd) (setq dd *dd))
(while (null (setq ss (ssget))))
(repeat (setq n (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
(vla-Offset obj dd)
(vla-Offset obj (* -1 dd))
(entdel (ssname ss n))
)
(princ)
) wang_cn10 发表于 2020-12-12 11:21
(vl-load-com)
(defun c:xs ( / dd ss obj n )
(if (null *dd) (setq *dd 0.5))
谢谢
{:1_1:} wang_cn10 发表于 2020-12-12 11:21
(vl-load-com)
(defun c:xs ( / dd ss obj n )
(if (null *dd) (setq *dd 0.5))
这个输入偏移距离10,变双线后宽度是20,可以改成输入多少,变双线后宽度就是多少,这样好一点 184632152 发表于 2021-7-5 20:33
这个输入偏移距离10,变双线后宽度是20,可以改成输入多少,变双线后宽度就是多少,这样好一点
(vl-load-com)
(defun c:xs ( / dd ss obj n )
(if (null *dd) (setq *dd 0.5))
(setq dd (getdist "请输入偏移距离:"))
(if (null dd) (setq dd *dd))
(while (null (setq ss (ssget))))
(repeat (setq n (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq n (1- n)))))
(vla-Offset obj (* 0.5 dd))
(vla-Offset obj (* -1 (* 0.5 dd)))
(entdel (ssname ss n))
)
(princ)
) xj6019 发表于 2021-7-5 20:47
(vl-load-com)
(defun c:xs ( / dd ss obj n )
(if (null *dd) (setq *dd 0.5))
谢谢大神! 这个有用,经常用
页:
[1]