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.
[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Ioaoe110[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 2020-310[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Oiu15010[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 2020-211[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Ia15010[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aizyao10[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Uos15010[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 BPl3tjj[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Ziao1510
[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Oo-2-110[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Zuoiy_10[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aizyao11[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Iyb_1510[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe1-111[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Uos15011[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe2da10[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe2da11[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe10

[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁

向下

[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Empty [討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁

發表 由 RyanGuo 周四 22 8月 2013 - 14:41

資料來源:明經通道
http://www.mjtd.com/function/info-126-523.html

在我看來這可以用來拼接用defun-q定義的副程式.
代碼:
;;;待拼接的副程式A1
(defun-q A1
    (/ X)
    (IF (null X)
      (SETQ X 0)
      (SETQ X (1+ X))
    )
    (PRINT X)
)

;;;待拼接的副程式A2
(defun-q A2
    (/ X)
    (IF (null X)
      (SETQ X 0)
      (SETQ X (1+ X))
    )
    (PRINT X)
)

;;;待拼接的副程式A3
(defun-q A3
    (/ X)
    (IF (null X)
      (SETQ X 0)
      (SETQ X (1+ X))
    )
    (PRINT X)
)

;;;將A1、A2、A3拼接起來
(defun-q-list-set
  'A
  (append (defun-q-list-ref 'A1)
     (cdr (defun-q-list-ref 'A2))
     (cdr (defun-q-list-ref 'A3))
  )
)
如果加上判斷式理論上可以依照需求將副程式拼接起來,
但應該是沒有需要這樣大費周章拼接副程式吧?
與其這樣用不如直接在程式中逐一執行副程式不是嗎?@@?

[似乎想到用法]
多選一的用法,舉例來說
代碼:
(defun 發動 (xxx / yyy 機器 引擎 機車零件 汽車零件)
;;;待拼接的副程式引擎
  (defun-q 引擎
      (/ X)
      .
      .
      .
  )
;;;待拼接的副程式機車零件
  (defun-q 機車零件
      (/ X)
      .
      .
      .
  )
;;;待拼接的副程式汽車零件
  (defun-q 汽車零件
      (/ X)
      .
      .
      .
  )
;;;依照需求組裝
  (cond
    ((eq xxx "摩托車")
     (defun-q-list-set
       '機器
       (append (defun-q-list-ref '引擎)
          (cdr (defun-q-list-ref '機車零件))
       )
     )
    ) ;_end cond 1
    ((eq xxx "汽車")
     (defun-q-list-set
       '機器
       (append (defun-q-list-ref '引擎)
          (cdr (defun-q-list-ref '汽車零件))
       )
     )
    ) ;_end cond 2
  ) ;_end cond
;;;發動機器
  (setq yyy (機器))
)
但也是可以用在都使用的情況,拿掉判斷式,上例就變成
代碼:
(defun 發動 (/ yyy zzz 機車 汽車 引擎 機車零件 汽車零件)
;;;待拼接的副程式引擎
  (defun-q 引擎
      (/ x)
      .
      .
      .
  )
;;;待拼接的副程式機車零件
  (defun-q 機車零件
      (/ x)
      .
      .
      .
  )
;;;待拼接的副程式汽車零件
  (defun-q 汽車零件
      (/ x)
      .
      .
      .
  )
;;;都組裝
  (defun-q-list-set
    '機車
    (append (defun-q-list-ref '引擎)
       (cdr (defun-q-list-ref '機車零件))
    )
  )
  (defun-q-list-set
    '汽車
    (append (defun-q-list-ref '引擎)
       (cdr (defun-q-list-ref '汽車零件))
    )
  )
;;;發動機器
  (setq yyy (機車))
  (setq zzz (汽車))
) ;_last
簡單來說這可以用在處理具有重複性的副程式中,
像是用在將副程式所需要的參數全部壓在一個list的情況,
在副程式開頭的時候就需要把list逐層解開定義,
這樣的話上例的部分就變得像是
代碼:
;;;x=(x1 (xx1 xx2))
(defun-q 引擎
    (x / x1 xx1 xx2)
    (setq x1  (car x)
          xx1 (car (cadr x))
          xx2 (cadr (cadr x))
    )
)
;;;為了測試沒裝上引擎時機車零件是否完整,先給它暫用的
;;;需求x1 xx1 xx2
(defun-q 機車零件
    (x1 xx1 xx2)
    .
    .
    .
)
這樣用的話可以確保每個副程式list解開的方式和解開後的名稱是一樣的,
在編寫上如果遇到需要變動list架構時,
也只需要重新編寫一次就可以了.

基本的用法應該就是這樣吧@@a

____________________________________________________________________________________


[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Acad2010 [討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Acad1810
[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Acad1211 [討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Acad1311 [討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Acad1511
RyanGuo
RyanGuo
初級會員
初級會員

文章總數 : 206
年齡 : 41
來自 : 屏東
職業 : 機械繪圖
愛好 : 玩遊戲
個性 : 嗚嗚男
使用年資 : 1年多
使用版本 : 2011
積分 : 3
經驗值 : 5323
威望值 : 316
注冊日期 : 2013-04-18
男 射手座 狗

回頂端 向下

回頂端


 
這個論壇的權限:
無法 在這個版面回復文章
[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Ioaoe110[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 2020-310[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Oiu15010[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 2020-211[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Ia15010[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aizyao10[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Uos15010[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 BPl3tjj[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Ziao1510
[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Oo-2-110[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Zuoiy_10[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aizyao11[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Iyb_1510[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe1-111[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Uos15011[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe2da10[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe2da11[討論]AUTOLISP函數defun-q-list-set的應用,附明經通道的說明網頁 Aoe10