Jump to content

Recommended Posts

Posted

All,

 

I am looking for a page that has an eplanation and example showing how to create different styles in dxf.

 

Kind regards,

Matthew Harrison

Posted

Are you creating a Style symbol table entry?

Posted

I am not following "symbol" part, however, I will clarify; I am trying to create a mleader style to be added to my drawing file.

 

MSH

Posted

Does Lee Mac's link cover what you are asking about?

  • 1 month later...
Posted

I am looking specifically for how to create an mleaderstyle using DXF or even VLISP.

 

I need an example that shows using a Block as Content Type and a Mtext as Content Type.

Posted
I am looking specifically for how to create an mleaderstyle using DXF or even VLISP.

 

 

Here is what I use in VLisp .

 

(defun c:Test (/ mspace p1 p2 str lead)(vl-load-com)
 ;; Tharwat 08. 07. 2011
 (setq mspace (vla-get-modelspace
              (vla-get-activedocument (vlax-get-acad-object))
            )
)
(if
 (and
   (setq p1 (getpoint "\n specify First Point :"))
   (setq p2 (getpoint p1 "\n Specify Second point :"))
   (setq str (getstring t "\n Specify the Text Contents :"))
 )
  (progn
    (setq lead (vla-addmleader
      mspace
      (vlax-make-variant
        (vlax-safearray-fill
          (safearray vlax-vbdouble '(0 . 5))
          (apply 'append (list p1 p2))
        )
      )
     0
    )
  )
    (vla-put-textstring lead str)
)
 (princ)
 )
 (princ)
 )

 

Tharwat

Posted

Tharwat, I think the OP was looking to create an MLeaderStyle, not MLeader:

 

I am looking specifically for how to create an mleaderstyle using DXF or even VLISP.

 

Matt, did you look at the link I provided? It demonstrates how to add an item to a dictionary (in your case, adding an MLeaderStyle to the MLeaderStyle Dictionary).

 

Here is some quickly written example code:

 

(defun AddMLeaderStyle ( stylename data / dict item )
 (cond
   ( (not (setq dict (cdr (assoc -1 (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")))))
     nil
   )
   ( (setq item (dictsearch dict stylename))
     (entmod (cons (assoc -1 item) data))
   )
   ( (setq item (entmakex data))
     (dictadd dict stylename item)
   )
 )
)

 

The above requires a valid stylename (string) and a DXF data list to create the MLeaderStyle entity. If the style already exists it will be modified to match the supplied data list, else a new style will be added using the supplied data. The DXF Data of an MLeaderStyle entity may be found here.

 

Example function call using an entget dump of an existing style in my drawing:

 

(AddMLeaderStyle "test"
'(
   (0 . "MLEADERSTYLE")
   (100 . "AcDbMLeaderStyle")
   (179 . 2)
   (170 . 2)
   (171 . 1)
   (172 . 0)
   (90 . 2)
   (40 . 0.0)
   (41 . 0.0)
   (173 . 1)
   (91 . -1023410173)
   (92 . -2)
   (290 . 1)
   (42 . 1.0)
   (291 . 1)
   (43 . 1.0)
   (3 . "Standard")
   (44 . 1.0)
   (300 . "")
   (174 . 1)
   (178 . 1)
   (175 . 1)
   (176 . 0)
   (93 . -1073741824)
   (45 . 1.0)
   (292 . 0)
   (297 . 0)
   (46 . 0.18)
   (94 . -1056964608)
   (47 . 1.0)
   (49 . 1.0)
   (140 . 1.0)
   (293 . 1)
   (141 . 0.0)
   (294 . 1)
   (177 . 0)
   (142 . 1.0)
   (295 . 0)
   (296 . 0)
   (143 . 1.0)
   (271 . 0)
   (272 . 9)
   (273 . 9)
 )
)

Posted

I've never tried it in Visual LISP, but, following the route of other dictionaries, I would assume something like:

 

(defun AddMLeaderStyle ( style / _catchapply dict item )

 (defun _catchapply ( _function _parameters / result )
   (if
     (not
       (vl-catch-all-error-p
         (setq result (vl-catch-all-apply _function _parameters))
       )
     )
     result
   )
 )

 (cond
   (
     (not
       (setq dict
         (_catchapply 'vla-item
           (list
             (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object)))
             "ACAD_MLEADERSTYLE"
           )
         )
       )
     )
     nil
   )
   ( (setq item (_catchapply 'vla-getobject (list dict style)))
   )
   ( (_catchapply 'vla-addobject (list dict style "AcDbMLeaderStyle"))
   )
 )
)

But in this case you would have to modify each property of the MLeaderStyle Object to suit your needs.

Posted
Tharwat, I think the OP was looking to create an MLeaderStyle, not MLeader:

 

You're right , my mistake always reading quickly .:)

 

Thanks

 

Tharwat

Posted

Quick tip for your code:

 

(apply 'append (list p1 p2))  ==  (append p1 p2)

 

:wink:

Posted
Quick tip for your code:

 

(apply 'append (list p1 p2))  ==  (append p1 p2)

 

:wink:

 

Nice catch , and perfect :thumbsup:

 

Thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...