Author Topic: search for MLEADERSTYLES in dwg  (Read 1754 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
search for MLEADERSTYLES in dwg
« on: July 13, 2010, 05:30:12 AM »
Hello there,

I work with mleaders for the first time. I obviously can’t not look for the styles in a dwg with tblsearch. How can I find out with lisp if a certain style in the drawing?

Thanks in advance

Bernd

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: search for MLEADERSTYLES in dwg
« Reply #1 on: July 13, 2010, 07:30:42 AM »
Hi,

Look at the ACAD_MLEADERSTYLE dictionnary in (namedobjdict).
Speaking English as a French Frog

Amsterdammed

  • Guest
Re: search for MLEADERSTYLES in dwg
« Reply #2 on: July 13, 2010, 08:11:09 AM »
Thanks!!

gile

  • Gator
  • Posts: 2520
  • Marseille, France
Re: search for MLEADERSTYLES in dwg
« Reply #3 on: July 13, 2010, 08:20:48 AM »
You're welcome.

You can use or get some inspiration from this sub:

Code: [Select]
;; gc:GetDictEntries
;; Returns the dictionary entries as a list  of dotted pairs: (entryName . entryename)
;;
;; Argument : dict the dictionary (ENAME or DXF list)

(defun gc:GetDictEntries (dict / result)
  (and (= (type dict) 'ENAME) (setq dict (entget dict)))
  (while
    (setq dict (vl-member-if (function (lambda (x) (= (car x) 3))) (cdr dict)))
     (setq result (cons (cons (cdar dict) (cdadr dict)) result))
  )
  (reverse result)
)

for your task: (gc:getDictEntries (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"))
Speaking English as a French Frog

Lee Mac

  • Seagull
  • Posts: 12922
  • London, England
Re: search for MLEADERSTYLES in dwg
« Reply #4 on: July 13, 2010, 10:43:35 AM »
Perhaps these may help also  :-)

Code: [Select]
;;-------------------=={ 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)
)