求助论坛高手帮忙编制一个批量标注CAD断面图超欠挖插件求助论坛高手帮忙编制一个批...
;文件名:PB.lsp;;功能说明:标注实际开挖线各点与设计开挖线之间的距离
;;;修改时间:2015-01-07ss en v-en pc ss1 en1 po-li n p11 pt pt@curve osm
(vl-load-com)
(defun c:PB(/ )
(setq osm (getvar "osmode"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(while
(progn
(prompt "\n请选择设计开挖线:")
(not(setq ss(ssget ":s" '((0 . "CIRCLE,*POLYLINE")))))
);end progn
(prompt "\n<<<<未选择到正确的对象,请重新选择!>>>>")
);end while
(setq en(ssname ss 0)
v-en(vlax-ename->vla-object en)
)
(setq pc(find-centerpoint en));找设计开挖线的型心
(while(progn(prompt "\n请选择实际开挖线:")
(not(setq ss1(ssget ":s" '((0 . "*POLYLINE")))))
);end progn
(prompt "\n<<<<未选择到正确的对象,请重新选择!>>>>")
);end while
(setq en1(ssname ss1 0))
(setq po-li (vl-remove-if 'not (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) (entget en1))));取多段线顶点表
(initget 6)
(setq n (getint "\n 请输入实际开挖线上标注间隔数(默认为0):"))
(if(null n)(setq n 0))
(if(/= n 0)(setq po-li(get-new-point-list po-li n)));end if
(foreach pt po-li
(setq pt@curve(vlax-curve-getClosestPointTo v-en pt))
(if(> (distance pt pc) (distance pt@curve pc));如果超挖
(progn
(setq p11 (polar pt@curve (angle pt@curve pt) (* 2 (distance pt pt@curve))))
;(make-dimension pt pt@curve p11 "隧道超挖+")
(make-dimension pt pt@curve p11)
; (command "_.pline" P11 pc "")
);end progn
);end if
(if(< (distance pt pc) (distance pt@curve pc));如果欠挖
(progn
(setq p11(polar pt(angle pt pt@curve ) (* 3 (distance pt pt@curve))))
;(make-dimension pt@curve pt p11 "隧道欠挖-")
(make-dimension pt@curve pt p11)
;(command "_.pline" Pt p11 "")
);end progn
);end if
);end foreach
(setvar "osmode" osm)
(princ)
);end defun
;;;sub-routine1
(defun find-centerpoint(en / po-li n y pc)
(setq entda(entget en)
ename(cdr(assoc 0 entda)))
(if(= ename "CIRCLE")
(setq pc(cdr(assoc 10 entda)))
(progn
(setq po-li (vl-remove-if 'not (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) entda)))
(setq n(length po-li))
(setq y(apply 'mapcar (cons '+ po-li)))
(setq pc(mapcar '/ y (list n n n)))
);progn
);end if
);end defun
;;;sub-routine2
(defun make-dimension (p13 p14 p11 dimsty)
(entmake (list '(0 . "DIMENSION")
'(100 . "AcDbEntity")
'(100 . "AcDbDimension")
(cons 10 p14)
(cons 11 p11)
'(70 . 33)
'(1 . "")
(cons 3 dimsty)
'(100 . "AcDbAlignedDimension")
(cons 13 p13)
(cons 14 p14)
)
);endmake
);end defun
;;;sub-routine3
;;;间隔N个数取点表
(defun get-new-point-list(li n / s-li i k)
(setq s-li nil i 0 k (1+ n))
(while(nth i li)
(setq s-li(cons (nth i li) s-li))
(setq i(+ i k))
);end while
(reverse s-li)
);end defun
(defun c:cqw (/ spl_real spl_design sty pt_n pt pt_near dim_mk) (setq spl_real (car (entsel "选择实际开挖线 red"))) (setq spl_design (car (entsel "选择设计开挖线 white"))) (setq sty nil) (setq pt_n (XD::Polyline:GetVertices spl_real)) (foreach pt pt_n(progn (setq pt_near (vlax-curve-getClosestPointTo spl_design pt)) ;求距离点最近的曲线上的点 (if (xdrx_point_isinside pt spl_design) (setq sty "隧道欠挖-") (setq sty "隧道超挖+") ) (setq dim_mk nil) ;直接生成有问题 ;(setq dim_mk (xdrx_dimension_MakeAlign pt pt_near pt_near sty)) ;(xdrx_dimension_update dim_mk) (setq dim_mk (xdrx_dimension_MakeAlign pt pt_near pt_near)) (xdrx_dimension_SetStyle dim_mk sty)) )) 都是有问题 有问题用不了 确定不是反编译的? 像是反编译的 不是其他人写的
页:
[1]