Remove first part and break from mtext

Remove first part and break from mtext

stijn.dedeckerM4Q3S
Participant Participant
636 Views
10 Replies
Message 1 of 11

Remove first part and break from mtext

stijn.dedeckerM4Q3S
Participant
Participant

Hi, 

i have a lisp that removes the first part of a mtext block, 

Thats ok but is still leaves the \P 

 

i cant figure it out? 

 

(defun c:removefirstpart (/ ss ents ent text breakline-pos updated-text)
(setq ss (ssget "_X" '((0 . "MTEXT"))))
(if ss
(progn
(setq ents (sslength ss))
(repeat ents
(setq ent (ssname ss (setq ents (1- ents))))
(setq text (cdr (assoc 1 (entget ent))))
(setq breakline-pos (vl-string-search "\\P" text))
(setq updated-text (if breakline-pos
(substr text (1+ breakline-pos))
""))
(entmod (subst (cons 1 updated-text) (assoc 1 (entget ent)) (entget ent)))
)
(princ "Text before breakline and breakline removed.")
)
(princ "No MText found.")
)
(princ)
)

 

0 Likes
637 Views
10 Replies
Replies (10)
Message 2 of 11

paullimapa
Mentor
Mentor

change this:

(substr text (1+ breakline-pos))

to this:

(substr text (+ 3 breakline-pos))

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 11

stijn.dedeckerM4Q3S
Participant
Participant

ok, this works but is still leaving a space at front so how to remove that also.

0 Likes
Message 4 of 11

paullimapa
Mentor
Mentor

Easy change + 3 to + 4


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 5 of 11

stijn.dedeckerM4Q3S
Participant
Participant

i have tried that but then it removes also the first character of the second part.

 

My MTEXT looks like: example.JPG

0 Likes
Message 6 of 11

paullimapa
Mentor
Mentor

Share a dwg with your Mtext


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 7 of 11

komondormrex
Mentor
Mentor

hey,

check this thread

0 Likes
Message 8 of 11

stijn.dedeckerM4Q3S
Participant
Participant

here is a example dwg

0 Likes
Message 9 of 11

paullimapa
Mentor
Mentor

so for example looking at these 3 lines of an MText (which I changed color to 3 to make it easier to see) before Removefirstpart is run:

paullimapa_1-1706688119049.png

The MText actually contains 2 locations of \\P:

paullimapa_2-1706688180454.png

Now after Removefirstpart runs this is how that MText looks like:

paullimapa_3-1706688233966.png

Now there's only 1 location of \\P left:

paullimapa_4-1706688267711.png

Then I run Removefirstpart one more time & now it looks like this:

paullimapa_5-1706688321126.png

There are no more \\P left:

paullimapa_6-1706688340641.png

I also don't see any spaces in front.

What are you trying to get at?

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 10 of 11

stijn.dedeckerM4Q3S
Participant
Participant

i am sorry but i dont think there is a problem, i think it was just a problem with one specifc drawing

0 Likes
Message 11 of 11

paullimapa
Mentor
Mentor

Glad problem is solved…cheers!!!


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes