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

    Default LISP for creating MLeader Style

    Registered forum members do not see this ad.

    Hello,

    I was wondering if anyone is able to create an MLeader style based on the parametrs below and set it to the current Mleader style in LSP code? Also could the new MLeader style be named "Alpha".

    I am completely aware that there is a way to just copy over the MLeader style, and this is not my goal. I am looking for the code to automate this!

    I want to be able to add it to the startup LSP so that it is present and set to current every drawing that is opened.

    This would be a huge help for our CAD group.

    Here are the MLeader settings that need to be hard coded:







    Thanks in advance.

  2. #2
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    392

    Default

    Here's a start .. you'll need to find all the properties you want to change and add them.

    Code:
    (defun _makemleaderstyle (name txtstyle / d mld mlo)
      ;; RJP - 09.16.2017
      (if
        (and
          (setq d (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
          (= 'vla-object (type (setq mld (vl-catch-all-apply 'vla-item (list d "ACAD_MLEADERSTYLE")))))
          (= 'vla-object
    	 (type
    	   (setq mlo (vl-catch-all-apply 'vlax-invoke (list mld 'addobject name "AcDbMLeaderStyle")))
    	 )
          )
        )
         (progn (vla-put-alignspace mlo 0.1)
    	    (vla-put-annotative mlo :vlax-true)
    	    (vla-put-arrowsize mlo 0.18)
    	    (vla-put-blockconnectiontype mlo 0)
    	    (vla-put-breaksize mlo 0.1)
    	    (vla-put-description mlo "")
    	    (vla-put-dogleglength mlo 0.125)
    	    (vla-put-enablelanding mlo :vlax-true)
    	    (vla-put-firstsegmentangleconstraint mlo 0)
    	    (vla-put-landinggap mlo 0.05)
    	    (vla-put-maxleadersegmentspoints mlo 2)
    	    (vla-put-scalefactor mlo 1)
    	    (vla-put-secondsegmentangleconstraint mlo 0)
    	    (vlax-put mlo 'textalignmenttype 0)
    	    (vlax-put mlo 'textleftattachmenttype 1)
    	    (vlax-put mlo 'textrightattachmenttype 1)
    	    (vla-put-textheight mlo 0.1)
    	    ;; Make sure you load your texstyle first or it will default to standard
    	    (vla-put-textstyle
    	      mlo
    	      (if (tblobjname "style" txtstyle)
    		txtstyle
    		"standard"
    	      )
    	    )
    	    mlo
         )
      )
    )
    ;; (_makemleaderstyle "Bazinga!" "Standard")
    (vl-load-com)
    ;; Properties below
    
    					; IAcadMLeaderStyle: AutoCAD MLeaderStyle Interface
    					; Property values:
    					;   AlignSpace = 5.0
    					;   Annotative = 0
    					;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff701d75188>
    					;   ArrowSize = 0.18
    					;   ArrowSymbol = ""
    					;   BitFlags = 0
    					;   Block = ""
    					;   BlockColor = #<VLA-OBJECT IAcadAcCmColor 0000022367bcf870>
    					;   BlockConnectionType = 0
    					;   BlockRotation = 0.0
    					;   BlockScale = 1.0
    					;   BreakSize = 0.125
    					;   ContentType = 2
    					;   Description = ""
    					;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000022358e47788>
    					;   DoglegLength = 2.0
    					;   DrawLeaderOrderType = 0
    					;   DrawMLeaderOrderType = 1
    					;   EnableBlockRotation = -1
    					;   EnableBlockScale = -1
    					;   EnableDogleg = -1
    					;   EnableFrameText = 0
    					;   EnableLanding = -1
    					;   FirstSegmentAngleConstraint = 0
    					;   Handle (RO) = "2FA"
    					;   HasExtensionDictionary (RO) = 0
    					;   LandingGap = 0.4
    					;   LeaderLineColor = #<VLA-OBJECT IAcadAcCmColor 0000022367bcf690>
    					;   LeaderLinetype = 1
    					;   LeaderLineTypeId = AutoCAD.Application: Null object ID
    					;   LeaderLineWeight = -2
    					;   MaxLeaderSegmentsPoints = 2
    					;   Name = "test"
    					;   ObjectID (RO) = 3212
    					;   ObjectName (RO) = "AcDbMLeaderStyle"
    					;   OverwritePropChanged (RO) = 0
    					;   OwnerID (RO) = 2921
    					;   ScaleFactor = 1.0
    					;   SecondSegmentAngleConstraint = 0
    					;   TextAlignmentType = 0
    					;   TextAngleType = 0
    					;   TextAttachmentDirection = 0
    					;   TextBottomAttachmentType = 0
    					;   TextColor = #<VLA-OBJECT IAcadAcCmColor 0000022367bcf6f0>
    					;   TextHeight = 0.2
    					;   TextLeftAttachmentType = 2
    					;   TextRightAttachmentType = 3
    					;   TextString = ""
    					;   TextStyle = AutoCAD.Application: Null object ID
    					;   TextTopAttachmentType = 0
    					; Methods supported:
    					;   Delete ()
    					;   GetExtensionDictionary ()
    					;   GetXData (3)
    					;   SetXData (2)

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

    Default

    Quote Originally Posted by ronjonp View Post
    Here's a start .. you'll need to find all the properties you want to change and add them.

    Code:
    (defun _makemleaderstyle (name txtstyle / d mld mlo)
      ;; RJP - 09.16.2017
      (if
        (and
          (setq d (vla-get-dictionaries (vla-get-activedocument (vlax-get-acad-object))))
          (= 'vla-object (type (setq mld (vl-catch-all-apply 'vla-item (list d "ACAD_MLEADERSTYLE")))))
          (= 'vla-object
    	 (type
    	   (setq mlo (vl-catch-all-apply 'vlax-invoke (list mld 'addobject name "AcDbMLeaderStyle")))
    	 )
          )
        )
         (progn (vla-put-alignspace mlo 0.1)
    	    (vla-put-annotative mlo :vlax-true)
    	    (vla-put-arrowsize mlo 0.18)
    	    (vla-put-blockconnectiontype mlo 0)
    	    (vla-put-breaksize mlo 0.1)
    	    (vla-put-description mlo "")
    	    (vla-put-dogleglength mlo 0.125)
    	    (vla-put-enablelanding mlo :vlax-true)
    	    (vla-put-firstsegmentangleconstraint mlo 0)
    	    (vla-put-landinggap mlo 0.05)
    	    (vla-put-maxleadersegmentspoints mlo 2)
    	    (vla-put-scalefactor mlo 1)
    	    (vla-put-secondsegmentangleconstraint mlo 0)
    	    (vlax-put mlo 'textalignmenttype 0)
    	    (vlax-put mlo 'textleftattachmenttype 1)
    	    (vlax-put mlo 'textrightattachmenttype 1)
    	    (vla-put-textheight mlo 0.1)
    	    ;; Make sure you load your texstyle first or it will default to standard
    	    (vla-put-textstyle
    	      mlo
    	      (if (tblobjname "style" txtstyle)
    		txtstyle
    		"standard"
    	      )
    	    )
    	    mlo
         )
      )
    )
    ;; (_makemleaderstyle "Bazinga!" "Standard")
    (vl-load-com)
    ;; Properties below
    
    					; IAcadMLeaderStyle: AutoCAD MLeaderStyle Interface
    					; Property values:
    					;   AlignSpace = 5.0
    					;   Annotative = 0
    					;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff701d75188>
    					;   ArrowSize = 0.18
    					;   ArrowSymbol = ""
    					;   BitFlags = 0
    					;   Block = ""
    					;   BlockColor = #<VLA-OBJECT IAcadAcCmColor 0000022367bcf870>
    					;   BlockConnectionType = 0
    					;   BlockRotation = 0.0
    					;   BlockScale = 1.0
    					;   BreakSize = 0.125
    					;   ContentType = 2
    					;   Description = ""
    					;   Document (RO) = #<VLA-OBJECT IAcadDocument 0000022358e47788>
    					;   DoglegLength = 2.0
    					;   DrawLeaderOrderType = 0
    					;   DrawMLeaderOrderType = 1
    					;   EnableBlockRotation = -1
    					;   EnableBlockScale = -1
    					;   EnableDogleg = -1
    					;   EnableFrameText = 0
    					;   EnableLanding = -1
    					;   FirstSegmentAngleConstraint = 0
    					;   Handle (RO) = "2FA"
    					;   HasExtensionDictionary (RO) = 0
    					;   LandingGap = 0.4
    					;   LeaderLineColor = #<VLA-OBJECT IAcadAcCmColor 0000022367bcf690>
    					;   LeaderLinetype = 1
    					;   LeaderLineTypeId = AutoCAD.Application: Null object ID
    					;   LeaderLineWeight = -2
    					;   MaxLeaderSegmentsPoints = 2
    					;   Name = "test"
    					;   ObjectID (RO) = 3212
    					;   ObjectName (RO) = "AcDbMLeaderStyle"
    					;   OverwritePropChanged (RO) = 0
    					;   OwnerID (RO) = 2921
    					;   ScaleFactor = 1.0
    					;   SecondSegmentAngleConstraint = 0
    					;   TextAlignmentType = 0
    					;   TextAngleType = 0
    					;   TextAttachmentDirection = 0
    					;   TextBottomAttachmentType = 0
    					;   TextColor = #<VLA-OBJECT IAcadAcCmColor 0000022367bcf6f0>
    					;   TextHeight = 0.2
    					;   TextLeftAttachmentType = 2
    					;   TextRightAttachmentType = 3
    					;   TextString = ""
    					;   TextStyle = AutoCAD.Application: Null object ID
    					;   TextTopAttachmentType = 0
    					; Methods supported:
    					;   Delete ()
    					;   GetExtensionDictionary ()
    					;   GetXData (3)
    					;   SetXData (2)
    I'm not sure I understand what you, mean... It looks like you have the properties listed there... Which properties are missing from this? Or are you saying I just need to change what is there to what I want to see in an MLeader?

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

    Default

    And, when I run this it says "Error too few arguments" and shouldn't the first have an alias with c (defun _makemleaderstyle (name txtstyle / d mld mlo)

  5. #5
    Senior Member
    Computer Details
    ronjonp's Computer Details
    Operating System:
    Windows 10
    Using
    AutoCAD 2018
    Join Date
    Apr 2009
    Location
    Colorado
    Posts
    392

    Default

    The function accepts a name and textsyle (_makemleaderstyle "Alpha" "Ascent") .. I added some of the properties, but there may be more needed for the style you're creating.

    IMO .. it's much easier to have a template that contains all your styles then start with that, or insert it as a block.

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

    Default

    Quote Originally Posted by ronjonp View Post
    The function accepts a name and textsyle (_makemleaderstyle "Alpha" "Ascent") .. I added some of the properties, but there may be more needed for the style you're creating.

    IMO .. it's much easier to have a template that contains all your styles then start with that, or insert it as a block.
    Yeah we have a template and added our mleader style... I guess the reason we wanted this was so that whenever we open a drawing, the ascent mleaderstyle is automatically in the drawing already and set to current... but I think we can get around this by just having it already in the template though...

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

    Default

    Quote Originally Posted by ryankevin15 View Post
    Yeah we have a template and added our mleader style... I guess the reason we wanted this was so that whenever we open a drawing, the ascent mleaderstyle is automatically in the drawing already and set to current... but I think we can get around this by just having it already in the template though...
    Add something like this to your startup:
    Code:
    (command "_.insert" "fullpathtotemplate" nil)
    (setvar 'cmleaderstyle "Alpha")

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

    Default

    I guess what I'm trying to say is if we started working on an outside company drawing.

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

    Default

    Quote Originally Posted by ryankevin15 View Post
    I guess what I'm trying to say is if we started working on an outside company drawing.
    See previous response.

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

    Default

    Registered forum members do not see this ad.

    Doesn't look like that code worked... says nil when executed.

Similar Threads

  1. Set MLeader to Existing MLeader Style via LISP
    By parkerdepriest in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: Yesterday, 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. Changing arrowhead style for mleader LISP
    By broncos15 in forum AutoLISP, Visual LISP & DCL
    Replies: 0
    Last Post: 14th Dec 2015, 10:32 pm
  5. Set Default mLeader Style by LISP???
    By woodman78 in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 18th Oct 2010, 04:29 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