ryankevin15 Posted August 14, 2017 Share Posted August 14, 2017 Hello, My manager made this LSP file for me and it doesn't work and we are both not sure why. Seems correct to me. How it works: Creates the E-Anno-Note layer, otherwise makes it current, then creates an MLeader (to avoid creating leaders on incorrect layers). (DEFUN C:NN () (setvar "cmdecho" 0) (if (not (tblsearch "layer" "E-Anno-Note")) (command "-layer" "n" "E-Anno-Note" "c" "2" "E-Anno-Note" "")) (command "-layer" "m" "E-Anno-Note") (COMMAND "mleader") (princ) ) Thanks! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 14, 2017 Share Posted August 14, 2017 Hi, Need to add double quotes. (command "-layer" "m" "E-Anno-Note" [color="magenta"][b]""[/b][/color]) Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 14, 2017 Author Share Posted August 14, 2017 Hi,Need to add double quotes. (command "-layer" "m" "E-Anno-Note" [color="magenta"][b]""[/b][/color]) (DEFUN C:mm () (setvar "cmdecho" 0) (if (not (tblsearch "layer" "E-Anno-Note")) (command "-layer" "n" "E-Anno-Note" "c" "2" "E-Anno-Note" "")) command "-layer" "m" "E-Anno-Note" "") (COMMAND "mleader" "") (princ) ) Still doesn't work when I run this... Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 14, 2017 Share Posted August 14, 2017 Still doesn't work when I run this... You have omitted one bracket before the command call. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 15, 2017 Share Posted August 15, 2017 The -layer N is new, M is make new and make current, so does two steps. So a slight variation (if (not (tblsearch "layer" "E-Anno-Note")) (command "-layer" "m" "E-Anno-Note" "c" "2" "E-Anno-Note" "") (command "-layer" "s" "E-Anno-Note" "") ) also (if (not (tblsearch "layer" "E-Anno-Note")) (command "-layer" "m" "E-Anno-Note" "c" "2" "E-Anno-Note" "")) (setvar 'clayer "E-Anno-Note") ) Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 16, 2017 Author Share Posted August 16, 2017 Thanks for the help. This works now. Could I make it also adjust the settings of the MLeader before it is drawn so that it will make the right alignment in the middle of the bottom row of text (this is a standard CAD thing that doesn't seem to be the default). Thanks in advance. Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 16, 2017 Share Posted August 16, 2017 Thanks for the help. This works now. Could I make it also adjust the settings of the MLeader before it is drawn so that it will make the right alignment in the middle of the bottom row of text (this is a standard CAD thing that doesn't seem to be the default). Thanks in advance. You could add something like this to the code: (if (setq e (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")) (progn (setq o (vlax-ename->vla-object (cdr (assoc -1 (dictsearch (cdr (assoc -1 e)) (getvar 'cmleaderstyle)))) ) ) (vla-put-textleftattachmenttype o 5) (vla-put-textrightattachmenttype o 5) ) ) Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 17, 2017 Author Share Posted August 17, 2017 Anyone know of any way I can import an MLeader style right before it starts drawing the MLeader? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 17, 2017 Share Posted August 17, 2017 Anyone know of any way I can import an MLeader style right before it starts drawing the MLeader? Make a template and insert it if the mleaderstyle does not exist. Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 17, 2017 Author Share Posted August 17, 2017 You could add something like this to the code: (if (setq e (dictsearch (namedobjdict) "ACAD_MLEADERSTYLE")) (progn (setq o (vlax-ename->vla-object (cdr (assoc -1 (dictsearch (cdr (assoc -1 e)) (getvar 'cmleaderstyle)))) ) ) (vla-put-textleftattachmenttype o 5) (vla-put-textrightattachmenttype o 5) ) ) I will try this with my manager and see if it works. Thanks! Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 17, 2017 Author Share Posted August 17, 2017 I was able to adjust the leader in the style, but will this code locate the style on my computer or how does that work? Quote Link to comment Share on other sites More sharing options...
ronjonp Posted August 17, 2017 Share Posted August 17, 2017 I was able to adjust the leader in the style, but will this code locate the style on my computer or how does that work? It just changes the current mleader style ( which might actually be bad practice ) ... I would check if the style exists and set it current, else import ( or create with code ) and set current. Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 22, 2017 Author Share Posted August 22, 2017 Here is my updated code. Can anyone add some code so that it will import the MLeaderStyle before making the MLeader? Our style is called "Ascent" (DEFUN C:mm () (setvar "cmdecho" 0) (if (not (tblsearch "layer" "E-Anno-Note")) (command "-layer" "n" "E-Anno-Note" "c" "2" "E-Anno-Note" "")) (command "-layer" "m" "E-Anno-Note" "") (command "-layer" "c" "2" "E-Anno-Note" "") (command "-layer" "ps" "style_1" "E-Anno-Note" "") (COMMAND "mleader") (princ) ) Quote Link to comment Share on other sites More sharing options...
ryankevin15 Posted August 22, 2017 Author Share Posted August 22, 2017 Actually, it looks like we need to create this MLeader style every time and set it to current if it doesn't exist... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.