Importing Multileaderstyles from a Drawing with Superseding Existing Styles

Importing Multileaderstyles from a Drawing with Superseding Existing Styles

Anonymous
Not applicable
1,486 Views
2 Replies
Message 1 of 3

Importing Multileaderstyles from a Drawing with Superseding Existing Styles

Anonymous
Not applicable

I have a central file that contains all our various styles including our multileader styles. We use a simple macro to insert this drawing into our working drawings to bring in all the styles and such, which is fine and good. The issue is that we have recently changed our mleaderstyles (I have made the changes to them in the template file) and now we want to be able to update our leaderstyles by reimporting them in all our working drawings, and when we use the macro to insert the template it doesn't update any information because it sees that mleaderstyles already exist in the ACAD_MLEADERSTYLE dictionary.

The ideal solution would be a way to make cad accept the new values instead of sticking to the existing definitions in the drawing.

Failing that I have been trying to come up with a lisp routine that will rename all the existing leaderstyles by appending "temp" to the end of there name, import the template (now that the names are no longer in use), then change the leaderstyle of all existing leader objects in the drawing to the correct leaderstyle, and lastly purge the now unused leaderstyles with "temp" in the name. Attempting this method I have encountered issues with entmod statements not seeming to have any effect on the style names. This is the current rough attempt at renaming the leader styles in the drawing:

 

(defun c:UPDATE_LEADERSTYLES ( / dic styles)
    (setq dic (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE"));get the leaderstyle dictionary
    (foreach data dic ;for each piece of data in the dictionary object
        (if (= (car data) 350);if the data is a leaderstlye object
            (setq styles (append styles (list (cdr data))));add it to a list
        )
    )
    (foreach style styles ;for each style object found
        (entmod (subst (cons 3 (strcat (cdr (assoc 3 (entget style))) "temp")) (assoc 3 (entget style)) (entget style)));replace the name of the style with the current name + "temp"
    )
    (princ);quiet exit
)

 

I'd also be interested in a method that uses visual lisp if it is less verbose or more efficient, but my knowledge of visual lisp is not great and I've been struggling to find good documentation for things I need, so along those lines I've only gotten so far as finding the dictionary object that contains the mleaderstyles:

(setq mleaderdic (vla-item (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))) "ACAD_MLEADERSTYLE"))

 

Any help to come up with an effective solution would be greatly appreciated.

0 Likes
Accepted solutions (1)
1,487 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Accepted solution

I've had some success with continued tinkering, it seems to modify the names of defined mleader styles you must apply the entmod to the mleader styles dictionary rather than the individual style definition entities. For those interested please see the attached lisp file for current code.

This routine seems to work for now, but there can be some issues if the mleader styles were previous inserted in the drawing as a block previously (which is the case for a large portion of our drawings), so if you intend to use this you may have to experiment with adding a portion at the beginning to erase all copies of that block from the drawing then purge it of the block definition.

I would still be interested in a more efficient solution if one exists.

Message 3 of 3

lanceX2G2C
Contributor
Contributor

Thank you for your hard work, Tim! I've been trying to figure out how to do this myself for years without any luck. I'm not very good at LISP so I was hoping someone would do it someday. I will give your LISP a try and see how it goes.

Thanks again!

0 Likes