See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Creating Multileader Style using LISP

  1. #1
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Creating Multileader Style using LISP

    Hello,

    I am trying to create a Multileader Style using LISP but gettig nowhere.

    I tried _MLEADERSTYLE but that opens the dialog box, I tried filedia to avoid dialog box pop-ups but that doesn't work.

    Can somebody help me find the proper functions or variables that will allow me to create a new Multileader Style using AutoLISP (preferred)

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP


  3. #3
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP

    In the below mentioned link I found the following:

    (foreach item
    (list
    '("AlignSpace" 5.0)
    '("Annotative" 0)

    AlignSpace and Annotative are those variables or functions?
    How does the (vlax-put-property .... ) function work?
    Is there a "simple" lisp option available to create the mleader style?

  4. #4
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP

    You could be able to create mleader style
    using entmake function but this would be worst a lot of time
    For the link I've suggested try add:
    (vl-load-com)
    at the start of code

  5. #5
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP

    The code doesn't work...I am getting the following error:
    ; error: too few arguments

  6. #6
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    1

    Default Re: Creating Multileader Style using LISP

    I just slightly tweaked this code,
    see if this will works
    Code:
    ;; original code by VVA
    (defun make_mleader_style	(mleaderstylename
    				 textcolor
    				 leadercolor
    				 /
    				 adoc
    				 mldrdict
    				 newldrstyle
    				 objcolor
    				)
      (vl-load-com)
      (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
      (setq	mldrdict
    	 (vla-item (vla-get-dictionaries adoc) "ACAD_MLEADERSTYLE")
      ) ;_ end of setq
      (setq	newldrstyle
    	 (vlax-invoke
    	   mldrdict
    	   'addobject
    	   mleaderstylename
    	   "AcDbMLeaderStyle"
    	 ) ;_ end of vlax-invoke
      ) ;_ end of setq
      (setq	objcolor (vla-getinterfaceobject
    		   (vlax-get-acad-object)
    		   (strcat "AutoCAD.AcCmColor."
    			   (substr (getvar "acadver") 1 2)
    		   ) ;_ end of strcat
    		 ) ;_ end of vla-getinterfaceobject
      ) ;_ end of setq
      (vla-put-colorindex objcolor textcolor)
      (vla-put-textcolor newldrstyle objcolor)
      (vla-put-colorindex objcolor leadercolor)
      (vla-put-leaderlinecolor newldrstyle objcolor)
    
    
      (foreach item
    	   (list
    	     '("AlignSpace" 4)
    	     (list
    	       "ArrowSize"
    	       (fix (/ (vla-get-arrowsize (vla-item mldrdict "Standard"))
    		       2
    		    ) ;_ end of /
    	       ) ;_ end of fix
    	     ) ;_ end of list
    	     '("BitFlags" 0)
    	     '("BlockConnectionType" 1)
    	     '("BlockRotation" 0.0)
    	     '("BlockScale" 1.0)
    	     '("BreakSize" 0.125)
    	     '("ContentType" 2)		;mtext
    	     '("Description" "My Style Description")
    	     '("DoglegLength" 1.25)
    	     '("DrawLeaderOrderType" 0)
    	     '("DrawMLeaderOrderType" 1)
    	     '("EnableBlockRotation" -1)
    	     '("EnableBlockScale" -1)
    	     '("EnableDogleg" -1)
    	     '("EnableFrameText" 0)
    	     '("EnableLanding" -1)
    	     '("FirstSegmentAngleConstraint" 0)
    	     (list "LandingGap"
    		   (vla-get-landinggap (vla-item mldrdict "Standard"))
    	     ) ;_ end of list
    	     '("LeaderLineType" 1)
    	     '("LeaderLineTypeId" "ByLayer")
    	     '("LeaderLineTypeId" "ByLayer")
    	     '("LeaderLineWeight" -3)
    	     '("MaxLeaderSegmentsPoints" 2)
    	     '("ScaleFactor" 1.0)
    	     '("SecondSegmentAngleConstraint" 0)
    	     '("TextAlignmentType" 0)
    	     '("TextAngleType" 0)
    	     '("TextHeight" 1.5)
    	     '("TextLeftAttachmentType" 4) ;original 3
    	     '("TextRightAttachmentType" 4);original 3
    	     '("TextString" "Default\\PText")
    	     '("TextStyle" "STANDARD")
    	   ) ;_ end of list
    
        (vlax-put newldrstyle (car item) (cadr item))
      ) ;_ end of foreach
      newldrstyle
    ) ;_ end of defun
    
    ;; Test
    (defun c:msv (/ *error* ms)
      (vl-load-com)
    
      (defun *error* (msg)
        (command "_undo" "_e")
    
        (if	(and msg
    	     (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
    	) ;_ end of and
          (princ (strcat "\nError: " msg))
        ) ;_ end of if
        (princ)
      ) ;_ end of defun
      (command "_undo" "_be")
    
      (if (vl-catch-all-error-p
    	(vl-catch-all-apply
    	  '(lambda ()
    	     (setq ms (make_mleader_style "MyCoolstyle" 5 72));change "MyCoolstyle" and colors to suit
    	   ) ;_ end of lambda
    	) ;_ end of vl-catch-all-apply
          ) ;_ end of vl-catch-all-error-p
        (alert "Problem creating Mleader Style")
        (setvar "CMLEADERSTYLE" "MyCoolstyle");change "MyCoolstyle"  to suit
      ) ;_ end of if
      (if (vl-catch-all-error-p
    	(vl-catch-all-apply
    	  '(lambda () (vla-put-arrowsymbol ms "_Origin2"));; existing arrow block in the drawing
    	) ;_ end of vl-catch-all-apply
          ) ;_ end of vl-catch-all-error-p
        (not
          (vl-catch-all-error-p
    	(vl-catch-all-apply
    	  '(lambda () (vla-put-arrowsymbol ms acarrowdefault))
    	) ;_ end of vl-catch-all-apply
          ) ;_ end of vl-catch-all-error-p
        ) ;_ end of not
      ) ;_ end of if
      (princ)
    ) ;_ end of defun

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,714
    Login to Give a bone
    1

    Default Re: Creating Multileader Style using LISP

    FWIW -

    If you've already defined the desired MLeader Style in a template, or some other drawing, you could always just STEAL it.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  8. #8
    Active Member
    Join Date
    2012-06
    Posts
    96
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP

    Thank you very much gentlemen,

    fixo, the modified code now works!!!
    BlackBox, thank you for the link...that code is great!!!!

    Once again, thank you all.

  9. #9
    Woo! Hoo! my 1st post
    Join Date
    2015-02
    Posts
    1
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP

    Quote Originally Posted by fixo View Post
    I just slightly tweaked this code,
    see if this will works
    Code:
    ;; original code by VVA
    (defun make_mleader_style	(mleaderstylename
    				 textcolor
    				 leadercolor
    				 /
    				 adoc
    				 mldrdict
    				 newldrstyle
    				 objcolor
    				)
      (vl-load-com)
      (setq adoc (vla-get-activedocument (vlax-get-acad-object)))
      (setq	mldrdict
    	 (vla-item (vla-get-dictionaries adoc) "ACAD_MLEADERSTYLE")
      ) ;_ end of setq
      (setq	newldrstyle
    	 (vlax-invoke
    	   mldrdict
    	   'addobject
    	   mleaderstylename
    	   "AcDbMLeaderStyle"
    	 ) ;_ end of vlax-invoke
      ) ;_ end of setq
      (setq	objcolor (vla-getinterfaceobject
    		   (vlax-get-acad-object)
    		   (strcat "AutoCAD.AcCmColor."
    			   (substr (getvar "acadver") 1 2)
    		   ) ;_ end of strcat
    		 ) ;_ end of vla-getinterfaceobject
      ) ;_ end of setq
      (vla-put-colorindex objcolor textcolor)
      (vla-put-textcolor newldrstyle objcolor)
      (vla-put-colorindex objcolor leadercolor)
      (vla-put-leaderlinecolor newldrstyle objcolor)
    
    
      (foreach item
    	   (list
    	     '("AlignSpace" 4)
    	     (list
    	       "ArrowSize"
    	       (fix (/ (vla-get-arrowsize (vla-item mldrdict "Standard"))
    		       2
    		    ) ;_ end of /
    	       ) ;_ end of fix
    	     ) ;_ end of list
    	     '("BitFlags" 0)
    	     '("BlockConnectionType" 1)
    	     '("BlockRotation" 0.0)
    	     '("BlockScale" 1.0)
    	     '("BreakSize" 0.125)
    	     '("ContentType" 2)		;mtext
    	     '("Description" "My Style Description")
    	     '("DoglegLength" 1.25)
    	     '("DrawLeaderOrderType" 0)
    	     '("DrawMLeaderOrderType" 1)
    	     '("EnableBlockRotation" -1)
    	     '("EnableBlockScale" -1)
    	     '("EnableDogleg" -1)
    	     '("EnableFrameText" 0)
    	     '("EnableLanding" -1)
    	     '("FirstSegmentAngleConstraint" 0)
    	     (list "LandingGap"
    		   (vla-get-landinggap (vla-item mldrdict "Standard"))
    	     ) ;_ end of list
    	     '("LeaderLineType" 1)
    	     '("LeaderLineTypeId" "ByLayer")
    	     '("LeaderLineTypeId" "ByLayer")
    	     '("LeaderLineWeight" -3)
    	     '("MaxLeaderSegmentsPoints" 2)
    	     '("ScaleFactor" 1.0)
    	     '("SecondSegmentAngleConstraint" 0)
    	     '("TextAlignmentType" 0)
    	     '("TextAngleType" 0)
    	     '("TextHeight" 1.5)
    	     '("TextLeftAttachmentType" 4) ;original 3
    	     '("TextRightAttachmentType" 4);original 3
    	     '("TextString" "Default\\PText")
    	     '("TextStyle" "STANDARD")
    	   ) ;_ end of list
    
        (vlax-put newldrstyle (car item) (cadr item))
      ) ;_ end of foreach
      newldrstyle
    ) ;_ end of defun
    
    ;; Test
    (defun c:msv (/ *error* ms)
      (vl-load-com)
    
      (defun *error* (msg)
        (command "_undo" "_e")
    
        (if	(and msg
    	     (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
    	) ;_ end of and
          (princ (strcat "\nError: " msg))
        ) ;_ end of if
        (princ)
      ) ;_ end of defun
      (command "_undo" "_be")
    
      (if (vl-catch-all-error-p
    	(vl-catch-all-apply
    	  '(lambda ()
    	     (setq ms (make_mleader_style "MyCoolstyle" 5 72));change "MyCoolstyle" and colors to suit
    	   ) ;_ end of lambda
    	) ;_ end of vl-catch-all-apply
          ) ;_ end of vl-catch-all-error-p
        (alert "Problem creating Mleader Style")
        (setvar "CMLEADERSTYLE" "MyCoolstyle");change "MyCoolstyle"  to suit
      ) ;_ end of if
      (if (vl-catch-all-error-p
    	(vl-catch-all-apply
    	  '(lambda () (vla-put-arrowsymbol ms "_Origin2"));; existing arrow block in the drawing
    	) ;_ end of vl-catch-all-apply
          ) ;_ end of vl-catch-all-error-p
        (not
          (vl-catch-all-error-p
    	(vl-catch-all-apply
    	  '(lambda () (vla-put-arrowsymbol ms acarrowdefault))
    	) ;_ end of vl-catch-all-apply
          ) ;_ end of vl-catch-all-error-p
        ) ;_ end of not
      ) ;_ end of if
      (princ)
    ) ;_ end of defun
    hi, the code works great. It it posibble to define the multileader style scale value and style name according to our preference?

  10. #10
    Member
    Join Date
    2017-01
    Posts
    3
    Login to Give a bone
    0

    Default Re: Creating Multileader Style using LISP

    Hi,

    I'm also looking for the same thing.. Were you able to find "MLEADERSTYLE" variables?

    - - - Updated - - -

    I'm also looking for the same thing.. were you abler to find multileaderstyle variables?

    - - - Updated - - -

    I'm also looking for the same thing.. were you abler to find multileaderstyle variables?

Page 1 of 2 12 LastLast

Similar Threads

  1. MULTILEADER STYLE
    By Moubis106433 in forum AutoCAD General
    Replies: 4
    Last Post: 2015-07-10, 02:09 AM
  2. changing multileader style
    By Peter Sedlacek in forum AutoCAD Annotation
    Replies: 5
    Last Post: 2012-02-06, 01:58 PM
  3. Modify Multileader Style - Help please
    By john.lincoln in forum AutoCAD General
    Replies: 4
    Last Post: 2008-12-29, 10:53 PM
  4. Multileader Style Change...
    By sevenDeuce in forum AutoCAD Annotation
    Replies: 5
    Last Post: 2008-09-11, 06:30 PM
  5. Multileader style location?
    By Steve_Bennett in forum AutoCAD Annotation
    Replies: 5
    Last Post: 2007-05-15, 06:51 PM

Tags for this Thread

Posting Permissions

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