马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
(defun c:LoadMlStyles (/ mlFileName)
(setq mlFileName (getstring "\nEnter MLN file name: "))
(if (/= nil mlFileName)
(LoadMln mlFileName)
)
(princ)
)
(defun LoadMln (mlnFile / f mlineDict same newStyle xName)
(setq mlnFile (findfile mlnFile))
(setq f (open mlnFile "r"))
;;(setq f (open mlnFile "r"))
(if (= NIL f)
(princ "\nInvalid MLN file.\n")
(progn
;; Get the MLINESTLYE dictionary.
(setq mlineDict (dictsearch (namedobjdict) "ACAD_MLINESTYLE"))
;; Create the beginning of an MLINESTYLE object.
(setq same (list (cons 0 "MLINESTYLE")
;;(cons 102 "{ACAD_REACTORS")
;;(cons 330 (cdr (assoc -1 mlineDict)))
;;(cons 102 "}")
;;(cons 330 (cdr (assoc -1 mlineDict)))
(cons 100 "AcDbMlineStyle")
)
)
;;
;; Read the data of the MLINESTYLE
;;
(while (/= nil (setq mlStyle (ReadObject f)))
;; Create the complete MLINESTYLE object.
(setq newStyle (append same mlStyle)
xName (entmakex newStyle)
)
;; Append it to the MLINESTYLE dictionary.
(dictadd (cdr (assoc -1 mlineDict))
(cdr (assoc 2 newStyle))
xName
)
)
)
)
(close f)
(princ)
)
[hide](defun ReadObject (f / ObjectList firstLine code value)
(setq ObjectList nil)
;; Skip the 'MLSTYLE'.
(setq firstLine (read-line f))
(if (/= nil firstLine)
(progn
(while (/= 0 (setq code (atoi (read-line f))))
(setq value (vl-string-trim " " (read-line f)))
(if (or (= code 2)
(= code 3)
(= code 6)
)
(setq ObjectList (append ObjectList (list (cons code value))))
)
(if (or (= code 70)
(= code 62)
(= code 71)
)
(setq ObjectList (append ObjectList (list (cons code (atoi value)))))
)
(if (or (= code 51)
(= code 52)
)
;; Code 51 and 52 must be converted into degrees.
(setq ObjectList (append ObjectList (list (cons code (angtof value 0)))))
)
(if (= code 49)
(setq ObjectList (append ObjectList (list (cons code (atof value)))))
)
)
)
)
ObjectList
)
|