[已解決]插入炸開後圖塊文字比例參考
AutoCAD顧問 :: 技術(發言等級:一般會員) :: :: 進階討論
第1頁(共1頁)
[已解決]插入炸開後圖塊文字比例參考
請問大大們~
小弟想在圓心替換圖塊後炸開~炸開後的文字大小比例可以選取圖框(擷取圖框比例)或直接輸入比例
所以 acx為一變數~卡關了~~圓心替代使用了蘋果爸分享的lisp
煩請各位大大幫小弟修改一下感激不盡~謝謝
源碼如下
(defun ax:getboundingbox (entname / entpl entpr ptlist)
(vla-getboundingbox (vlax-ename->vla-object entname) 'entpl 'entpr)
(setq ptlist (mapcar 'vlax-safearray->list (list entpl entpr)))
(mapcar '(lambda (x) (trans x 0 1)) ptlist)
)
(defun getentdxf (ent dxf)
(cond
((= (type ent) 'ename)
(cdr (assoc dxf (entget ent '("*"))))
)
((= (type ent) '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 entdata entgrp entname n ptlist scale GET IST)
(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))))
(setq elist (entget en))
(setq pt (cdr (assoc '10 elist)))
(entdel en)
(command "insert" "C:\\lisp\\\工具選項板圖塊\\\攻牙\\\M3.dwg" pt "" "" "");;
(command "explode" "l") ;炸開插入的圖塊
);; repeat
);;progn
);; if
(if (setq entname (entsel "\n請選擇圖框"))
(if (= "INSERT" (getentdxf (car entname) 0))
(progn
(command "zoom" "o" (car entname) "")
(setq ptlist (ax:getboundingbox (car entname)))
(setq entgrp (ssget "W" (car ptlist) (cadr ptlist) '((8 . "*TEXT"))))
(setq scale (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 entdata entgrp 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))))
(setq elist (entget en))
(setq pt (cdr (assoc '10 elist)))
(entdel en)
(command "insert" "C:\\lisp\\\工具選項板圖塊\\\攻牙\\\M4.dwg" pt "" "" "");;
(command "explode" "l") ;炸開插入的圖塊
);; repeat
);;progn
);; if
;以下想增加一個判斷與手動輸入比例
(if (setq entname (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) "")
(setq ptlist (ax:getboundingbox (car entname)))
(setq entgrp (ssget "W" (car ptlist) (cadr ptlist) '((8 . "*TEXT"))))
(setq scale (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)
)
小弟想在圓心替換圖塊後炸開~炸開後的文字大小比例可以選取圖框(擷取圖框比例)或直接輸入比例
所以 acx為一變數~卡關了~~圓心替代使用了蘋果爸分享的lisp
煩請各位大大幫小弟修改一下感激不盡~謝謝
源碼如下
(defun ax:getboundingbox (entname / entpl entpr ptlist)
(vla-getboundingbox (vlax-ename->vla-object entname) 'entpl 'entpr)
(setq ptlist (mapcar 'vlax-safearray->list (list entpl entpr)))
(mapcar '(lambda (x) (trans x 0 1)) ptlist)
)
(defun getentdxf (ent dxf)
(cond
((= (type ent) 'ename)
(cdr (assoc dxf (entget ent '("*"))))
)
((= (type ent) '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 entdata entgrp entname n ptlist scale GET IST)
(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))))
(setq elist (entget en))
(setq pt (cdr (assoc '10 elist)))
(entdel en)
(command "insert" "C:\\lisp\\\工具選項板圖塊\\\攻牙\\\M3.dwg" pt "" "" "");;
(command "explode" "l") ;炸開插入的圖塊
);; repeat
);;progn
);; if
(if (setq entname (entsel "\n請選擇圖框"))
(if (= "INSERT" (getentdxf (car entname) 0))
(progn
(command "zoom" "o" (car entname) "")
(setq ptlist (ax:getboundingbox (car entname)))
(setq entgrp (ssget "W" (car ptlist) (cadr ptlist) '((8 . "*TEXT"))))
(setq scale (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 entdata entgrp 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))))
(setq elist (entget en))
(setq pt (cdr (assoc '10 elist)))
(entdel en)
(command "insert" "C:\\lisp\\\工具選項板圖塊\\\攻牙\\\M4.dwg" pt "" "" "");;
(command "explode" "l") ;炸開插入的圖塊
);; repeat
);;progn
);; if
;以下想增加一個判斷與手動輸入比例
(if (setq entname (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) "")
(setq ptlist (ax:getboundingbox (car entname)))
(setq entgrp (ssget "W" (car ptlist) (cadr ptlist) '((8 . "*TEXT"))))
(setq scale (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)
)
wuwubaibai- 一般會員
- 文章總數 : 70
年齡 : 42
來自 : 彰化市
職業 : 板金
愛好 : 電腦
個性 : 外向
使用年資 : 4
使用版本 : 2010
經驗值 : 4228
威望值 : 0
注冊日期 : 2014-04-18
AutoCAD顧問 :: 技術(發言等級:一般會員) :: :: 進階討論
第1頁(共1頁)
這個論壇的權限:
您 無法 在這個版面回復文章