[已解決][問題]動態圖塊陣列時,顯示圖塊數量。
2 posters
阿毛叔- 一般會員
- 文章總數 : 4
年齡 : 45
來自 : 高雄
職業 : 機電
愛好 : 釣魚
個性 : 好學習,下班之餘會精進自己的技術
使用年資 : 8年左右
使用版本 : 2024
經驗值 : 397
威望值 : 6
注冊日期 : 2023-11-12
回復: [已解決][問題]動態圖塊陣列時,顯示圖塊數量。
- 代碼:
(defun mid (pt pt2 / X Y)
(mapcar '(lambda (X Y) (/ (+ X Y) 2.0)) pt pt2)
)
(defun c:ttttt(/ osm otext po po2 w h s ang p1 p2 p3 po-p3 ptm ptm2 ptmn ptn p1_p2 ptn2)
(setvar "cmdecho" 0)
(setq osm (getvar "osmode"));記錄物件鎖點
(setq otext (getvar "textstyle"))
(vl-cmdf "_.ucs" "_world")
(setq po (getpoint "\n->起始點:"))
(setq po2 (getpoint po "\n->終點:"))
(setq w (getreal "\n->矩形寬:"))
(setq h (getreal "\n->矩形高:"))
(setq s (fix (/ (distance po po2) w)))
(setq ang (angle po po2))
(setq p1 (polar po (+ 0 ang) w))
(setq p2 (polar p1 (+ (* pi 0.5) ang) h))
(setq p3 (polar po (+ (* pi 0.5) ang) h))
(setvar "osmode" 0)
(vl-cmdf "_.pline" po p1 p2 p3 po "")
(setq po-p3 (mid po p3))
(vl-cmdf "_.arc" "c" po-p3 p3 po)
(setq ptm (mid p1 p3))
(setq ptm2 (polar po-p3 (+ 180 ang) (/ w 4)))
(if (= (tblsearch "style" "text") nil)
(vl-cmdf "_.-style" "text" "romans.shx,chineset.shx" "0" "0.8" "0" "_N" "_N" "_N")
)
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptm)
(cons 11 ptm)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "B")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptm2)
(cons 11 ptm2)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "A")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setvar "textstyle" otext)
(repeat s
(setq po p1)
(setq p1 (polar po (+ 0 ang) w))
(setq p2 (polar p1 (+ (* pi 0.5) ang) h))
(setq p3 (polar po (+ (* pi 0.5) ang) h))
(vl-cmdf "_.pline" po p1 p2 p3 po "")
(setq ptmn (mid p1 p3))
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptmn)
(cons 11 ptmn)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "B")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setq po p1)
);repeat
(setq ptn (polar ptmn (+ (* pi 0.5) ang) h))
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptn)
(cons 11 ptn)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 (itoa (+ s 1)))
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setq p1_p2 (mid p1 p2))
(vl-cmdf "_.arc" "c" p1_p2 p1 p2)
(setq ptn2 (polar p1_p2 (+ 0 ang) (/ w 4)))
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptn2)
(cons 11 ptn2)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "A")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setvar "osmode" osm) ;將系統變數恢復
(princ)
)
可用看看這個 只適用單方向(左到右),右到左就會反過來,還有開頭的A部知道為什麼位置都是偏的,再看看有誰能修正。
masao_8- 初級會員
- 文章總數 : 72
年齡 : 31
來自 : 台中
職業 : 製圖
愛好 : 動漫
個性 : 內向
使用年資 : 4年
使用版本 : 2012
積分 : 1
經驗值 : 1396
威望值 : 126
注冊日期 : 2022-06-03
Tiger&蘋果爸 and 阿毛叔 like this post
回復: [已解決][問題]動態圖塊陣列時,顯示圖塊數量。
masao_8 寫到:
- 代碼:
(defun mid (pt pt2 / X Y)
(mapcar '(lambda (X Y) (/ (+ X Y) 2.0)) pt pt2)
)
(defun c:ttttt(/ osm otext po po2 w h s ang p1 p2 p3 po-p3 ptm ptm2 ptmn ptn p1_p2 ptn2)
(setvar "cmdecho" 0)
(setq osm (getvar "osmode"));記錄物件鎖點
(setq otext (getvar "textstyle"))
(vl-cmdf "_.ucs" "_world")
(setq po (getpoint "\n->起始點:"))
(setq po2 (getpoint po "\n->終點:"))
(setq w (getreal "\n->矩形寬:"))
(setq h (getreal "\n->矩形高:"))
(setq s (fix (/ (distance po po2) w)))
(setq ang (angle po po2))
(setq p1 (polar po (+ 0 ang) w))
(setq p2 (polar p1 (+ (* pi 0.5) ang) h))
(setq p3 (polar po (+ (* pi 0.5) ang) h))
(setvar "osmode" 0)
(vl-cmdf "_.pline" po p1 p2 p3 po "")
(setq po-p3 (mid po p3))
(vl-cmdf "_.arc" "c" po-p3 p3 po)
(setq ptm (mid p1 p3))
(setq ptm2 (polar po-p3 (+ 180 ang) (/ w 4)))
(if (= (tblsearch "style" "text") nil)
(vl-cmdf "_.-style" "text" "romans.shx,chineset.shx" "0" "0.8" "0" "_N" "_N" "_N")
)
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptm)
(cons 11 ptm)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "B")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptm2)
(cons 11 ptm2)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "A")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setvar "textstyle" otext)
(repeat s
(setq po p1)
(setq p1 (polar po (+ 0 ang) w))
(setq p2 (polar p1 (+ (* pi 0.5) ang) h))
(setq p3 (polar po (+ (* pi 0.5) ang) h))
(vl-cmdf "_.pline" po p1 p2 p3 po "")
(setq ptmn (mid p1 p3))
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptmn)
(cons 11 ptmn)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "B")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setq po p1)
);repeat
(setq ptn (polar ptmn (+ (* pi 0.5) ang) h))
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptn)
(cons 11 ptn)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 (itoa (+ s 1)))
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setq p1_p2 (mid p1 p2))
(vl-cmdf "_.arc" "c" p1_p2 p1 p2)
(setq ptn2 (polar p1_p2 (+ 0 ang) (/ w 4)))
(entmake
(list
(cons 0 "TEXT")
(cons 10 ptn2)
(cons 11 ptn2)
(cons 40 (/ h 2))
(cons 41 0.8)
(cons 1 "A")
(cons 7 "text")
(cons 50 ang)
(cons 71 0) ;Flags 0=Normal, 2=Backward, 4=Upside down
(cons 72 1) ;Horizontal text justification,0=Left,1=Center,2=Right,4=Center,5=Fit
(cons 73 2) ;Vertical text justification, 0=Baseline,1=Bottom,2=Middle,3=Top
)
)
(setvar "osmode" osm) ;將系統變數恢復
(princ)
)
可用看看這個 只適用單方向(左到右),右到左就會反過來,還有開頭的A部知道為什麼位置都是偏的,再看看有誰能修正。
謝謝你的回覆
後來我在國外論壇有看到一樣的問題。
他們是用定義屬性+功能變數來實現。圖塊陣列總長度/圖塊本身長度,十進位精度設定0
我有試過這個方法果然可以!!真的太高興了
阿毛叔- 一般會員
- 文章總數 : 4
年齡 : 45
來自 : 高雄
職業 : 機電
愛好 : 釣魚
個性 : 好學習,下班之餘會精進自己的技術
使用年資 : 8年左右
使用版本 : 2024
經驗值 : 397
威望值 : 6
注冊日期 : 2023-11-12
Tiger&蘋果爸 likes this post
這個論壇的權限:
您 無法 在這個版面回復文章