本帖最后由 wuwubaibai 于 2021-1-8 00:02 编辑
[img][/img][img][/img]小弟在网络上找到一个想在圆心替换图块后炸开~炸开后的文字大小比例可以选取图框(撷取图框比例)或直接输入比例所以 acx为一变量~卡关了~~烦请各位大大帮小弟修改一下感激不尽~谢谢~ 以下有大大讲明不知我想要的成果因无法上传照片或档案到此~显示档案过大所以只能口述
请大大们只要一个图块框~加一个带有文字的图块~使用下面代码便知道成果了 麻烦大大们~再次感谢 附上我自行综合许多大大的源码修改成现用的源码
(defun ax:getboundingbox (entname / entpl entprptlist) (vla-getboundingbox (vlax-ename->vla-object entname) 'entpl 'entpr) (setqptlist (mapcar 'vlax-safearray->list (list entpl entpr))) (mapcar'(lambda (x) (trans x 0 1)) ptlist) ) (defun getentdxf (ent dxf) (cond ((= (typeent) 'ename) (cdr(assoc dxf (entget ent '("*")))) ) ((= (typeent) 'vla-object) (cdr(assoc dxf (entget (vlax-vla-object->ename ent) '("*")))) ) ) ) (setq *en2obj* vlax-ename->vla-object)
(defun c:M3-TP (/ ss en elist p0 rad p1 sc entdataentgrp entname n ptlist scale GET IST) (setvar"cmdecho" 0) (command"._undo" "_begin") (if (setq ss(ssget '((0 . "circle")))) (progn (setq n-1) (repeat (sslengthss) (setq en(ssname ss (setq n (1+ n)))) (setqelist (entget en)) (setq pt(cdr (assoc '10 elist))) (entdelen) (command"insert" "C:\\lisp\\\工具选项板图块\\\攻牙\\\M3.dwg"pt "" "" "");; (command"explode" "l") ;炸开插入的图块 );; repeat );;progn );; if (if (setqentname (entsel "\n请选择图框")) (if (="INSERT" (getentdxf (car entname) 0)) (progn (command "zoom" "o" (car entname) "") (setqptlist (ax:getboundingbox (car entname))) (setqentgrp (ssget "W" (car ptlist) (cadr ptlist) '((8 ."*TEXT")))) (setqscale (vla-get-XScaleFactor (*en2obj* (car entname)))) (repeat (setq n (sslength entgrp)) (setq entname (ssname entgrp (setq n (1- n)))) (cond ((wcmatch (getentdxf entname 0) "*TEXT") (vla-put-Height (*en2obj* entname) (* scale 3 (getvar"textsize") )) ) ) ) ) ) ) (command"._undo" "_end") (setvar"cmdecho" 1) (princ) )
(defun c:M4-TP (/ ss en elist p0 rad p1 sc entdataentgrp entname n ptlist scale scaleget) (setvar"cmdecho" 0) (command"._undo" "_begin") (if (setq ss(ssget '((0 . "circle")))) (progn (setq n -1) (repeat(sslength ss) (setq en(ssname ss (setq n (1+ n)))) (setqelist (entget en)) (setq pt(cdr (assoc '10 elist))) (entdelen) (command"insert" "C:\\lisp\\\工具选项板图块\\\攻牙\\\M4.dwg"pt "" "" "");; (command"explode" "l") ;炸开插入的图块 );; repeat );;progn );; if ;以下想增加一个判断与手动输入比例 (if (setqentname (entsel "\n请选择图框或输入比例")) (if (=scaleget nil) (progn (setq sc acx) ) (progn (setq sc entname) ) ) ;以上想增加一个判断与手动输入比例 (if (="INSERT" (getentdxf (car entname) 0)) (progn (command "zoom" "o" (car entname) "") (setqptlist (ax:getboundingbox (car entname))) (setq entgrp (ssget "W" (carptlist) (cadr ptlist) '((8 . "*TEXT")))) (setqscale (vla-get-XScaleFactor (*en2obj* (car entname)))) (repeat (setq n (sslength entgrp)) (setq entname (ssname entgrp (setq n (1- n)))) (cond ((wcmatch (getentdxf entname 0) "*TEXT") (vla-put-Height (*en2obj* entname) (* scale 3 (getvar"textsize") )) ) ) ) ) ) ) (command"._undo" "_end") (setvar"cmdecho" 1) (princ) )
|