嗨,布莱恩,
如果未使用AutoCAD 2015,请尝试以下程序。
“bpoly”函数在AC2015中产生错误(不确定原因)。。。
将默认提示“123”更改为面板大小。
- (vl-load-com)
- (defun c:demo ( / adoc bp cen lays msp pa pl plo reg sfa txt)
- (setq adoc (vla-get-activedocument (vlax-get-acad-object))
- msp (vla-get-modelspace adoc)
- lays (vla-get-layers adoc)
- )
- (vla-add lays "Router - Green - V groove")
- (while (and (setq pa (getpoint "\n Select Panel Area: "))
- (setq pl (getstring (strcat "\nEnter a Panel Label <" (cond (*pl) ("123")) ">: "))
- *pl (cond ((/= pl "") (strcase pl)) (*pl) ("123"))
- )
- (setq bp (bpoly pa))
- )
- (setq plo (vlax-ename->vla-object bp)
- sfa (vlax-make-safearray vlax-vbObject '(0 . 0))
- )
- (vla-put-layer plo "Router - Green - V groove")
- (vlax-safearray-put-element sfa 0 plo)
- (setq reg (car (vlax-safearray->list (vlax-variant-value (vla-addregion msp sfa))))
- cen (vlax-get reg 'centroid)
- )
- (vla-delete reg)
- (setq txt (vla-AddText msp *pl (vlax-3D-point (trans cen 1 0)) (getvar 'TEXTSIZE)))
- (vla-put-alignment txt 10)
- (vla-put-textalignmentpoint txt (vlax-3D-point (trans cen 1 0)))
- (vla-put-rotation txt (angle (list 0 0)(getvar 'UCSXDIR)))
- )
- (princ)
- )
希望有帮助
亨里克 |