- ;;; CADALYST 08/08 www.cadalyst.com/code
- ; Tip 2305: Leader_To_Multileader.lsp LEADER to Multileader (c) 2008 Lyle Hardin
- ; Pick an old style LEADER and text to create a new MLEADER entity and erase the old LEADER and text.
- ; March/2008
- ;;; EDITED ON 15/04/2017 BY 3DWANNAB
- ; Reason for creating this, was to learn and create a LISP that I use on a regular basis.
- ; Commandline Syntax: Type "Leader_To_Multileader" OR "LTM" to run Program.
- ;
- ; ADDED - Case Conversion.
- ; OPTIONS:
- ; Titlecase Lowercase Uppercase Sentencecase toGglecase Keepcase.
- ;
- ; ADDED - Annotation support. Program simply matches the (entget) object to that of the (entlast) object. With the help of AT:isAnnotative written by Alan J. Thompson.
- ; ADDED - Custom LM:ssget fn written by LeeMac.
- ; ADDED - Multiple Selection. User can now select the LEADER and MTEXT together and no longer individually resulting in a much faster conversion.
- ; ADDED - Round off points - To nearest round number. That been 1. round fn written by Doug Broad. Additional credits to Joe Burke, Peter Toby.
- ; ADDED - Strip MTEXT - Of formatting option - LM:UnFormat fn written by LeeMac.
- ; ADDED - Text Rotation - MTEXT rotation is now preserved.
- ; ADDED - Undo levels - As opposed to one command at a time.
- ; ADDED - Picking of existing MLEADER to use as new style.
- ; RMB-SPACEBAR-ENTER to skip this step and use the current MLEADER style
- ; SETTINGS TRANSLATED IF PICKED:
- ; (vla-put-Layer newmleader existingMlLayer)
- ; (vla-put-ScaleFactor newmleader existingMlScale)
- ; (vla-put-StyleName newmleader existingMlStyle)
- ; (vla-put-TextWidth newmleader existingMlWidth)
- ;
- ; SETTINGS TRANSLATED IF NOT:
- ; (vla-put-Layer newmleader existingTxtLayer)
- ; (vla-put-TextRotation newmleader existingTxtRot)
- ; (vla-put-TextWidth newmleader existingTxtWidth)
- ;
- ; CHG - Changed to 'vla-get-TextString' as more robust.
- ; CHG - Moved new MLEADER to TEXT Layer as opposed to existing LEADER.
- ; CHG - Picking never fails, prompts user to keep picking until successful. LM:SelectIf fn written by LeeMac.
- ; FIX - ACADs built in functions to convert ill-formatted MTEXT creates a bug in the string result. LM:StringSubst by LeeMac.
- ; FIX - End position of MLEADER.
- ; FIX - Z coordinate to 0, resulting in no fuzzy text.
- ; FIX - Forces the MLEADER to be created from the 'LEADER arrowHead first' resulting in correct results all the time.
- ; FIX - Vertices, Leader_To_Multileader now supports 2 or 3 points.
- ; If 2 (Straight) it straightens the MLEADER up to the Y axis of the LEADER point for those LEADERS at an angle.
- ; If 3 (Dog Legged) it recreates those as they originally were.
- ; If <3 (Multiple) it recreates the 1st, 2nd & end point point of the original LEADER. The 4th vert or more, will get removed.
- ; NOTE: Not really any need for more than 3 points on an MLEADER, I don't think.
- ;
- ;;; KNOWN QUIRKS, BUGS
- ; Works in different UCSs, if you are fixing MTEXT & LEADERS which are upside down then the new MLEADER might be a little wacky.
- ;
- ;;; FUTURE ADDITIONS
- ; Convert based on how close the LEADER and MTEXT are away from each other. To enable multiple selection.
- ;
- ;;; COMMENT OUT
- ; First off, Big THANKS to Lyle Hardin for the original code.
- ; Big THANKS to LeeMac for the functions he has put up on his website.
- ; Finally getting the basics of this LISP'ing lark thanks to guys like him.
- ; Lots of other places on forums and Users too. To many users to mention.
- ; Let me know your thoughts on this Program or if you want to drop a Thank you.
- ; e. stephensherry147@yahoo.co.uk
- (defun c:LTM nil (c:Leader_To_Multileader))
- (defun c:Leader_To_Multileader ( /
- *error*
- cmde
- entLeader
- entLeaderName
- entTxt
- entTxtName
- entTxtVlaObj
- existingMlScale
- existingMlStyle
- existingMlvlaObj
- existingMlWidth
- existingTxtLayer
- existingTxtRot
- existingTxtString
- existingTxtWidth
- ldxf10_1
- ldxf10_2
- ldxf10_last
- lstleaderlen
- lstleaderpts
- os
- ss1
- ss2
- )
- (defun *error* (errmsg)
- (and acDoc (vla-EndUndoMark acDoc))
- (and errmsg
- (not (wcmatch (strcase errmsg) "*CANCEL*,*EXIT*"))
- (princ (strcat "\n<< Error: " errmsg " >>"))
- )
- (setvar 'cmdecho cmde)
- (setvar 'osmode os)
- )
- (setq acDoc (vla-get-ActiveDocument (vlax-get-acad-object)))
- (or (vla-EndUndoMark acDoc) (vla-StartUndoMark acDoc))
- (setq cmde (getvar "cmdecho"))
- (setq os (getvar "osmode"))
- (setvar 'cmdecho 0)
- (setvar 'osmode 0)
- (if
- (setq ss1
- (car
- (LM:SelectIf
- (strcat
- "\nSelect an existing MULTILEADER to use as the new style\nor RMB-SPACEBAR-ENTER to use current: '"
- (getvar "cmleaderstyle") "'."
- )
- (lambda ( x ) (eq "MULTILEADER" (cdr (assoc 0 (entget (car x)))))) entsel nil