ryankevin15 Posted August 14, 2017 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
Tharwat Posted August 14, 2017 Posted August 14, 2017 Hi, Need to add double quotes. (command "-layer" "m" "E-Anno-Note" [color="magenta"][b]""[/b][/color]) Quote
ryankevin15 Posted August 14, 2017 Author 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
Tharwat Posted August 14, 2017 Posted August 14, 2017 Still doesn't work when I run this... You have omitted one bracket before the command call. Quote
BIGAL Posted August 15, 2017 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
ryankevin15 Posted August 16, 2017 Author 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
ronjonp Posted August 16, 2017 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
ryankevin15 Posted August 17, 2017 Author Posted August 17, 2017 Anyone know of any way I can import an MLeader style right before it starts drawing the MLeader? Quote
ronjonp Posted August 17, 2017 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
ryankevin15 Posted August 17, 2017 Author 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
ryankevin15 Posted August 17, 2017 Author 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
ronjonp Posted August 17, 2017 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
ryankevin15 Posted August 22, 2017 Author 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
ryankevin15 Posted August 22, 2017 Author 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
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.