MODIFY SELECTED MULTILEADERS

MODIFY SELECTED MULTILEADERS

venturini.anthony
Advocate Advocate
351 Views
5 Replies
Message 1 of 6

MODIFY SELECTED MULTILEADERS

venturini.anthony
Advocate
Advocate

Im looking to have a lisp where i can select any amount of the same type of multileader and it will remove certain characters to make them all look the same. just looking to remove and replace the text. is this possible? 

im looking to turn this label: 

venturinianthony_0-1675794607531.png

 into this label: 

venturinianthony_1-1675794656283.png

 

0 Likes
352 Views
5 Replies
Replies (5)
Message 2 of 6

Kent1Cooper
Consultant
Consultant

FIND can do that.  You can replace " INCH CORRUGATED" [including the space at the beginning] with just the inch mark, in as many objects as you want all at once, and likewise replace " PIPE:" with just a space.  Just make sure you have this category checked for it to see the ones you want:

Kent1Cooper_0-1675796103051.png

 

Kent Cooper, AIA
0 Likes
Message 3 of 6

venturini.anthony
Advocate
Advocate

Yeah, that what i typically use, just wondering if there's a way for it to be faster and just done in one selection, and this way i can share with others to make things go just that much faster

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant

This sequence will do that.  It changes the upper one here to the lower:

Kent1Cooper_0-1675797232855.png

(setq ss (ssget "_X" '((0 . "MULTILEADER") (304 . "* very important *")))); finds all with content-to-be-replaced
(setq ml (ssname ss 0)); first one [full routine would step through if multiple]
(setq mldata (entget ml)); entity data list
(entmod

  (subst

    (cons 304 (vl-string-subst " " " very important " (cdr (assoc 304 mldata))))

       ; new content entry [304] with designated content replaced with [in this case] a space 

    (assoc 304 mldata); original content entry

    mldata; list to substitute it in

  )

)

 

A full routine could have substitution content(s) built in, if you have regular ones to do, or could ask the User each time for what to replace with what.  Are you capable of constructing such a thing from this operational content?

 

[I think that might not quite do it if the MultiLeader text content is very long -- it may split up the text content into multiple entity data entries.]

Kent Cooper, AIA
0 Likes
Message 5 of 6

Sea-Haven
Mentor
Mentor

Just an idea have a look up list for (oldword neword), then run something like this to select words in a string.

 

 

; thanks to Lee-mac for this defun
(defun csv->lst ( str / pos )
(if (setq pos (vl-string-position 32 str))
    (cons (substr str 1 pos) (csv->lst (substr str (+ pos 2))))
    (list str)
    )
)
(setq str "24 inch corrugated hdpe pipe: BOP 123.45")
(setq lst (csv->lst str))
(setq lst (cons "Please choose" lst))
(if (not AH:Toggs)(load "Multiple toggles.lsp"))
(setq ans (reverse (ah:toggs  lst)))

; eg result ("0" "1" "1" "0" "1" "0" "0") the 1 is selected button in list.

 

 

SeaHaven_0-1675827501763.png

So would then compare to look up and remake string. Should be able to set the replace to a string of "" so no extra spaces. Just a bit worried how many words in string the toggle will do up to about 20.

0 Likes
Message 6 of 6

pbejse
Mentor
Mentor

@venturini.anthony wrote:

Im looking to have a lisp where i can select any amount of the same type of multileader and it will remove certain characters to make them all look the same. just looking to remove and replace the text. is this possible? 


(Defun c:demo ( / ss i ent str )
      (if (setq ss (ssget "_X" '((0 . "Multileader")(304 . "* INCH CORRUGATED *"))))
          (repeat (setq i (sslength ss))
                (setq ent (entget (setq e (ssname ss (setq i (1- i))))))
                (setq str (getpropertyvalue e "Mtext/Contents"))                                
                (While (vl-string-search " INCH CORRUGATED " str)
                      (setq str (vl-string-subst " " " INCH CORRUGATED " str))
                      )
                (entmod (subst (cons 304 str)(assoc 304 ent) ent))
                )
          )
      )

HTH