AutoCAD LISP 建立或刪除複線樣式
可以利用由 Lee Mac 所寫的函數
新增MLine樣式
;;-------------------=={ Add MLine Style }==------------------;;
;; ;;
;; Adds an MLine Style to the ACAD_MLINESTYLE dictionary ;;
;;------------------------------------------------------------;;
;; Author: Lee McDonnell, 2010 ;;
;; ;;
;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; data - a DXF list of MLineStyle data ;;
;;------------------------------------------------------------;;
;; Returns: MLineStyle Dictionary Entity, else nil ;;
;;------------------------------------------------------------;;
(defun LM:AddMLineStyle ( data / dic obj )
;; © Lee Mac 2010
(if (and (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
(not (dictsearch (setq dic (cdr (assoc -1 dic))) (cdr (assoc 2 data))))
(setq obj (entmakex data)))
(dictadd dic (cdr (assoc 2 data)) obj)
)
)
刪除MLine樣式
;;-----------------=={ Delete MLine Style }==-----------------;;
;; ;;
;; Removes an MLine Style from the ACAD_MLINESTYLE ;;
;; dictionary ;;
;;------------------------------------------------------------;;
;; Author: Lee McDonnell, 2010 ;;
;; ;;
;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
;;------------------------------------------------------------;;
;; Arguments: ;;
;; name - the name of an MLine Style to remove ;;
;;------------------------------------------------------------;;
;; Returns: Entity name of removed style, else nil ;;
;;------------------------------------------------------------;;
(defun LM:DeleteMLineStyle ( name / dic )
;; © Lee Mac 2010
(if (setq dic (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
(dictremove (cdr (assoc -1 dic)) name)
)
)
測試新增樣式
(defun Example ( / lst ) (setq lst (list (cons 0 "MLINESTYLE") (cons 100 "AcDbMlineStyle") (cons 2 "Example") ; Name 樣式名稱 (cons 70 (+ 272)) ; caps/fill/joints 樣式旗標(收頭/填滿/接合) (cons 3 "") ; Desc 樣式說明 (cons 51 (/ pi 2.)); Start ang 起始角度 (cons 52 (/ pi 2.)); End ang 結束角度 (cons 71 2) ; Number of lines 元素數目 (cons 49 -0.5) ; Element Offset 元素偏移 (cons 62 256) ; Element Colour 元素顏色 (cons 6 "BYLAYER") ; Element Linetype 元素線型 (cons 49 0.5) (cons 62 256) (cons 6 "BYLAYER") ) ) (LM:AddMLineStyle lst) )
留言
張貼留言