嵌入MLine非常麻烦,并且会导致异常-您可以嵌入MLineStyle,但最好使用ActiveX方法创建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)
- )
- )
- ;;-----------------=={ 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)
- )
- )
- ;;------------------------------------------------------------;;
- ;; Test Function
- (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)
- )
- ;;----------------------=={ Add MLine }==---------------------;;
- ;; ;;
- ;; Adds a VLA MLine Object to the supplied Block container ;;
- ;; object, going through the supplied vertex list. ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; space - VLA Block Object ;;
- ;; ptLst - List of 3D Points for MLine Vertices ;;
- ;;------------------------------------------------------------;;
- ;; Returns: VLA MLine Object, else nil ;;
- ;;------------------------------------------------------------;;
- (defun LM:AddMLine ( space ptLst )
- ;; © Lee Mac 2010
- (vla-AddMline space (LM:PointVariant ptLst))
- )
- ;;------------------=={ Safearray Variant }==-----------------;;
- ;; ;;
- ;; Creates a populated Safearray Variant of a specified ;;
- ;; data type ;;
- ;;------------------------------------------------------------;;
- ;; Author: Lee McDonnell, 2010 ;;
- ;; ;;
- ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;;
- ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;;
- ;;------------------------------------------------------------;;
- ;; Arguments: ;;
- ;; datatype - variant type enum (eg vlax-vbDouble) ;;
- ;; data - list of static type data ;;
- ;;------------------------------------------------------------;;
- ;; Returns: VLA Variant Object of type specified ;;
- ;;------------------------------------------------------------;;
-
|