AutoCAD顧問
還沒有註冊嗎...即日起免費註冊,所有最完整的AutoCAD討論、教學及資源都在論壇裡喔~

Join the forum, it's quick and easy

AutoCAD顧問
還沒有註冊嗎...即日起免費註冊,所有最完整的AutoCAD討論、教學及資源都在論壇裡喔~
AutoCAD顧問
Would you like to react to this message? Create an account in a few clicks or log in to continue.
[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Ioaoe110[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 2020-310[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Oiu15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 2020-211[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Ia15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aizyao10[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Uos15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 BPl3tjj[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Ziao1510
[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Oo-2-110[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Zuoiy_10[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aizyao11[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Iyb_1510[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe1-111[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Uos15011[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe2da10[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe2da11[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe10

[已解決][問題]動態圖塊陣列時,顯示圖塊數量。

2 posters

向下

[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Empty [已解決][問題]動態圖塊陣列時,顯示圖塊數量。

發表 由 阿毛叔 周日 12 11月 2023 - 20:15

大家好
小弟之前做了一個可拉伸的陣列動態圖塊,最近想要在裡面增加一個B塊的數量文字。
這樣就不用每次拉完還要對著螢幕數。自己試過很多方法都失敗..
請問有甚麼方法可以實現。謝謝大家
[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Zyae11
阿毛叔
阿毛叔
一般會員
一般會員

文章總數 : 4
年齡 : 44
來自 : 高雄
職業 : 機電
愛好 : 釣魚
個性 : 好學習,下班之餘會精進自己的技術
使用年資 : 8年左右
使用版本 : 2024
經驗值 : 195
威望值 : 6
注冊日期 : 2023-11-12
男 天蝎座 羊

回頂端 向下

[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Empty 回復: [已解決][問題]動態圖塊陣列時,顯示圖塊數量。

發表 由 masao_8 周一 13 11月 2023 - 21:25

代碼:
(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
masao_8
一般會員
一般會員

文章總數 : 46
年齡 : 31
來自 : 台中
職業 : 製圖
愛好 : 動漫
個性 : 內向
使用年資 : 4年
使用版本 : 2012
經驗值 : 1018
威望值 : 84
注冊日期 : 2022-06-03
男 水瓶座 雞

Tiger&蘋果爸 and 阿毛叔 like this post

回頂端 向下

[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Empty 回復: [已解決][問題]動態圖塊陣列時,顯示圖塊數量。

發表 由 阿毛叔 周四 16 11月 2023 - 22:12

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
年齡 : 44
來自 : 高雄
職業 : 機電
愛好 : 釣魚
個性 : 好學習,下班之餘會精進自己的技術
使用年資 : 8年左右
使用版本 : 2024
經驗值 : 195
威望值 : 6
注冊日期 : 2023-11-12
男 天蝎座 羊

Tiger&蘋果爸 likes this post

回頂端 向下

回頂端


 
這個論壇的權限:
無法 在這個版面回復文章
[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Ioaoe110[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 2020-310[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Oiu15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 2020-211[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Ia15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aizyao10[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Uos15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 BPl3tjj[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Ziao1510
[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe15010[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Oo-2-110[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Zuoiy_10[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aizyao11[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Iyb_1510[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe1-111[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Uos15011[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe2da10[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe2da11[已解決][問題]動態圖塊陣列時,顯示圖塊數量。 Aoe10