Jump to content

Checking for Mleader Styles


TunzaGibbo

Recommended Posts

(defun c:FilletWeldBottL ()
 (InsertBlockExplode) [color="lime"]; I added this line to call the below function [/color]
 (setvar "cmleaderstyle" "Fillet Weld Bott L")
 (command "_mleader")
)

 

The first defun works perfect without the second line. I have added 15 mleader styles (One called "Fillet Weld B-S") to my template drawing with, So now each time I open a new drawing I have all the leader styles available. Unfortunately when I open an older drawing that wasn't created with my current template I don't have those mleader styles. So I thought I would try to get Lisp to help me and came up with the this defun below. I'm trying to get lisp to recognize that if "Fillet Weld B-S" is not present in this drawing the it should load "MW Leader Styles.dwg"

It's not happening. Can somebody help with this?? Thanks

 

(defun InsertBlockExplode ()
 (if (= ("mleaderstyle" "Fillet Weld B-S") nil)
   (command "_.insert" "MW Leader Styles" "0,0,0" 1 0))
)

Link to comment
Share on other sites

Consider the following function to test whether a given MLeader Style is defined within the active drawing:

(defun mleaderstyle-p ( mls / dic )
   (and (setq dic (dictsearch (namedobjdict) "acad_mleaderstyle"))
        (dictsearch (cdr (assoc -1 dic)) mls)
   )
)

 

In your code:

(defun InsertBlockExplode ( )
   (if (not (mleaderstyle-p "Fillet Weld B-S"))
       (command "_.-insert" "MW Leader Styles" nil)
   )
)

(defun mleaderstyle-p ( mls / dic )
   (and (setq dic (dictsearch (namedobjdict) "acad_mleaderstyle"))
        (dictsearch (cdr (assoc -1 dic)) mls)
   )
)

Link to comment
Share on other sites

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...