+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 14
  1. #1
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2016
    Join Date
    Apr 2017
    Posts
    56

    Default MLeader LSP not working

    Registered forum members do not see this ad.

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

    Code:
    (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!

  2. #2
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,085

    Default

    Hi,
    Need to add double quotes.
    Code:
    (command "-layer" "m" "E-Anno-Note" "")

  3. #3
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2016
    Join Date
    Apr 2017
    Posts
    56

    Default

    Quote Originally Posted by Tharwat View Post
    Hi,
    Need to add double quotes.
    Code:
    (command "-layer" "m" "E-Anno-Note" "")
    Code:
    (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...

  4. #4
    Luminous Being Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draughtsman
    Discipline
    Mechanical
    Details
    HVAC, Drainage, Water Supply, Fire Fighting and a little about Electricity.
    Using
    AutoCAD 2015
    Join Date
    Oct 2009
    Location
    Great Syria , Living in Abu Dhabi
    Posts
    6,085

    Default

    Quote Originally Posted by ryankevin15 View Post
    Still doesn't work when I run this...
    You have omitted one bracket before the command call.

  5. #5
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,899

    Default

    The -layer N is new, M is make new and make current, so does two steps.

    So a slight variation
    Code:
    (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
    Code:
    (if (not (tblsearch "layer" "E-Anno-Note"))
        (command "-layer" "m" "E-Anno-Note" "c" "2" "E-Anno-Note" ""))
        (setvar 'clayer "E-Anno-Note")
    )
    A man who never made mistakes never made anything

  6. #6
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2016
    Join Date
    Apr 2017
    Posts
    56

    Default

    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.

  7. #7
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    573

    Default

    Quote Originally Posted by ryankevin15 View Post
    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:
    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)
      )
    )

  8. #8
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2016
    Join Date
    Apr 2017
    Posts
    56

    Default

    Anyone know of any way I can import an MLeader style right before it starts drawing the MLeader?

  9. #9
    Super Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    573

    Default

    Quote Originally Posted by ryankevin15 View Post
    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.

  10. #10
    Full Member
    Discipline
    Electrical
    Using
    AutoCAD 2016
    Join Date
    Apr 2017
    Posts
    56

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by ronjonp View Post
    You could add something like this to the code:
    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!

Similar Threads

  1. Set MLeader to Existing MLeader Style via LISP
    By parkerdepriest in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 22nd Sep 2017, 09:13 am
  2. Select MLeader by Mleader style
    By pmayer in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 3rd Apr 2017, 06:56 pm
  3. Combining two LISP Routines - Leader to Mleader and Mleader Rotate
    By Cylis0509 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 13th Jan 2016, 09:12 pm
  4. Mleader ;;; vla-put-???
    By Lee Roy in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 24th Aug 2011, 05:56 pm
  5. Mleader
    By au-s in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 20th Apr 2009, 12:39 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts