I'm looking for a lisp routine that can find and replace multileader text.
I want to replace "T." with "T+" and "B." with "B+".
All the multileaders are on layers with a suffix of "-elev".
Any help will be greatly appreciated.
Thanks in advance,
Larry
@Anonymous wrote:I'm looking for a lisp routine that can find and replace multileader text.
I want to replace "T." with "T+" and "B." with "B+".
All the multileaders are on layers with a suffix of "-elev".
Any help will be greatly appreciated.
Thanks in advance,
Larry
command: _find
settings....
Text types
Dimension/Leader text
Why the need for lisp codes?
Anyway, since i'm replying.
(defun c:REpME (/ sel e) (setq sel (ssget "_X" '((0 . "MULTILEADER")(8 . "*-elev")))) (repeat (sslength sel) (setq e (vlax-ename->vla-object (ssname sel 0))) (vla-put-textstring e (vl-string-translate "B.T." "B+T+" (vla-get-textstring e))) (ssdel (ssname sel 0) sel) ) )
HTH
Scratch the previous post
This is more specific:
(defun c:REpME (/ sel e) (if (setq sel (ssget '((0 . "MULTILEADER")(8 . "*-elev")))) (repeat (sslength sel) (setq e (vlax-ename->vla-object (ssname sel 0)) str (vla-get-textstring e)) (if (setq f (cond ((wcmatch str "*B.*") (list "B." "B+")) ((wcmatch str "*T.*") (list "T." "T+")))) (vla-put-textstring e (vl-string-subst (cadr f)(car f) str) ) ) (ssdel (ssname sel 0) sel) ) ) (princ) )
@Anonymous wrote:Would this work if a block with an attribute is embedded in the multileader?
Yes i think its possible, what do you have in mind?
Sounds simple enough, before anything elseI notice the program name is Revup, Does that mean if i change all 4 to 5, the existing 5 will remain as 5 or be bump-up to 6 and so on?
Well, cant wait for you to reply. its getting pretty late here.
but if its just changing one value to another
(defun c:Revup ( / aDoc source SVal Mle MleD AT2Edit) (defun _CheckMl (Tag ent / a) (vlax-for itm ent (if (and (eq (vla-get-Objectname itm) "AcDbAttributeDefinition") (eq (vla-get-TagString itm) Tag)) (setq a (vla-get-ObjectID itm)))) a ) (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (setq ssmldrs (ssget "X" '((0 . "MULTILEADER")))) (setq oldval (strcase (getstring "\nEnter current value: "))) (setq newval (strcase (getstring "\nEnter new value: "))) ) (repeat (setq i (sslength ssmldrs)) (if (and (= (vla-get-ContentType (setq Mle (vlax-ename->vla-object (ssname ssmldrs (setq i (1- i)))))) 1) (setq MleD (vla-item (vla-get-blocks Adoc) (vla-get-ContentBlockName Mle))) (setq AT2Edit (_CheckMl "REVNUM" MleD)) (eq (vla-GetBlockAttributeValue Mle AT2Edit) oldval) ) (vla-SetBlockAttributeValue Mle AT2Edit newval) ) )(vla-regen aDoc acActiveViewport ) ) (princ) ) (vl-load-com) (princ)
HTH
Works fine here. post a sample drawing with the mleader.
Make sure you run the code i posted [post # 12]
Better yet rename the defun to something else
Anyhoo. try this
(defun c:RevOne ( / aDoc source SVal Mle MleD AT2Edit) (defun _CheckMl (Tag ent / a) (vlax-for itm ent (if (and (eq (vla-get-Objectname itm) "AcDbAttributeDefinition") (eq (vla-get-TagString itm) Tag)) (setq a (vla-get-ObjectID itm)))) a ) (setq aDoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (setq ssmldrs (ssget "X" '((0 . "MULTILEADER")))) (setq oldval (strcase (getstring "\nEnter current value: "))) (setq newval (strcase (getstring "\nEnter new value: "))) ) (repeat (setq i (sslength ssmldrs)) (if (and (= (vla-get-ContentType (setq Mle (vlax-ename->vla-object (ssname ssmldrs (setq i (1- i)))))) 1) (setq MleD (vla-item (vla-get-blocks Adoc) (vla-get-ContentBlockName Mle))) (setq AT2Edit (_CheckMl "REVNUM" MleD)) (eq (strcase (vla-GetBlockAttributeValue Mle AT2Edit)) oldval) ) (vla-SetBlockAttributeValue Mle AT2Edit newval) ) )(vla-regen aDoc acActiveViewport ) ) (princ) ) (vl-load-com) (princ)
command:RevOne
BTW: are you using a 64bit OS?
i have adifferent related problem i want to remove certain part of mleder text and i have a lips to do that but in mtext not mleader and i wonder if you can help me with that, the detail problem is as follow
I am working on AutoCad plant 3d and it generates isometric drawing contains mleader with coordinates as shown in the sample dwg attached.
I want to remove the lines contains "E XXXXX , N XXXX" From MLEADER the problem is that the lisp cannot see the Mleader text only sees any apply on mtext so it there is away to made this lisp work on mleader
thanks for your time , the lisp and sample dwg is attached.
Hi Sir, I'd been trying to use this code but It didn't work both MLEADER and ATTRIBUTE, I'm currently using AutoCAD 2018 64bit, lisp is working no error because of it asks me for current value and replaced value then after I press enter nothing happen. Pls, help thank you.
As I can see , MTEXT , surrounded by the magenta circle DO NOT belong to a MLEADER. Neither the mleader have any text
See result from vlax-dump for mleader
SELECCIONE LA ENTIDAD ; IAcadMLeader: AutoCAD Multi-Leader Interface ; Property values: ; Application (RO) = #<VLA-OBJECT IAcadApplication 00000001401151a8> ; ArrowheadBlock = "" ; ArrowheadSize = 2.5 ; ArrowheadType = 0 ; BlockConnectionType = 0 ; BlockScale = 1.0 ; ContentBlockName = "" ; ContentBlockType = 6 ; ContentType = 0 ; Document (RO) = #<VLA-OBJECT IAcadDocument 00000000342b27e8> ; DogLegged = -1 ; DoglegLength = 3.06186 ; EntityTransparency = "ByLayer" ; Handle (RO) = "74D4" ; HasExtensionDictionary (RO) = 0 ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000000003cb6e368> ; LandingGap = 2.0 ; Layer = "Annotation" ; LeaderCount (RO) = 1 ; LeaderLineColor = #<VLA-OBJECT IAcadAcCmColor 000000003cb6e420> ; LeaderLinetype = "ByBlock" ; LeaderLineWeight = -2 ; LeaderType = 1 ; Linetype = "ByLayer" ; LinetypeScale = 1.0 ; Lineweight = -1 ; Material = "ByLayer" ; ObjectID (RO) = 44 ; ObjectName (RO) = "AcDbMLeader" ; OwnerID (RO) = 43 ; PlotStyleName = "ByLayer" ; ScaleFactor = 1.0 ; StyleName = "AdskIso" ; TextAttachmentDirection = 0 ; TextBackgroundFill = Ocurrió una excepción ; TextBottomAttachmentType = 0 ; TextDirection = Ocurrió una excepción ; TextFrameDisplay = 0 ; TextHeight = 4.0 ; TextJustify = Ocurrió una excepción ; TextLeftAttachmentType = 1 ; TextLineSpacingDistance = Ocurrió una excepción ; TextLineSpacingFactor = Ocurrió una excepción ; TextLineSpacingStyle = Ocurrió una excepción ; TextRightAttachmentType = 1 ; TextRotation = Ocurrió una excepción ; TextString = Ocurrió una excepción ; TextStyleName = Ocurrió una excepción ; TextTopAttachmentType = 0 ; TextWidth = Ocurrió una excepción ; TrueColor = #<VLA-OBJECT IAcadAcCmColor 000000003cb6e900> ; Visible = -1
Note that all TEXT related property say AN EXCEPTION OCCUR.
Your mleader style have no content
and the MTEX is just a MTEXT
SELECCIONE LA ENTIDAD ; IAcadMText: AutoCAD MText Interface ; Property values: ; Application (RO) = #<VLA-OBJECT IAcadApplication 00000001401151a8> ; AttachmentPoint = 7 ; BackgroundFill = -1 ; Document (RO) = #<VLA-OBJECT IAcadDocument 00000000342b27e8> ; DrawingDirection = 5 ; EntityTransparency = "ByLayer" ; Handle (RO) = "74E6" ; HasExtensionDictionary (RO) = 0 ; Height = 2.5 ; Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 000000003cd63868> ; InsertionPoint = (127.0 61.0 -1.35003e-13) ; Layer = "Annotation" ; LineSpacingDistance = 4.16667 ; LineSpacingFactor = 1.0 ; LineSpacingStyle = 1 ; Linetype = "ByLayer" ; LinetypeScale = 1.0 ; Lineweight = -1 ; Material = "ByLayer" ; Normal = (0.0 0.0 1.0) ; ObjectID (RO) = 46 ; ObjectName (RO) = "AcDbMText" ; OwnerID (RO) = 43 ; PlotStyleName = "ByLayer" ; Rotation = 0.0 ; StyleName = "AdskIsoAnnotation" ; TextString = "CONT'D ON\n1\"-AMP-980-0368-SS\nW 13116\nN 23303\nEL +8044" ; TrueColor = #<VLA-OBJECT IAcadAcCmColor 000000003cd64c40> ; Visible = -1 ; Width = 0.0
Hope it help to clear it .
Hi! Just wondering if you ended finding a solution to use this lisp with a multileader. Thanks!
Can't find what you're looking for? Ask the community or share your knowledge.