I have a lot of texts that need to be modified like this one: TC=50.12
Is it possible to input a number to add/subtract the value in that text?
I know there are other threads with similar discussion like this one, but it doesn't apply to this particular problem I'm having.
Thanks!
Solved! Go to Solution.
Solved by john.uhden. Go to Solution.
If you know the prefix is always 2 chars and an Equal sign then you simply step through each text entity, get the value, apply substr, then convert the string to a float apply your add factor and then rebuild and update the text value.
Here is a piece to get you started. All that is left is to set up a system to step through selection set instead of picking a single entity.
(defun c:quick()
(setq myaddvalue 2.4
mytextent (car (entsel "\nSelect Text String"))
mytextdata (entget mytextent)
mytextvalue (cdr (assoc 1 mytextdata))
mytextprefix (substr mytextvalue 1 3)
mytextnumber (substr mytextvalue 4 (1- (strlen mytextvalue)))
myoldvalue (assoc 1 mytextdata)
mynewvalue (cons 1 (strcat mytextprefix (rtos (+ (atof mytextnumber) myaddvalue) 2 4)))
myentdata (subst mynewvalue myoldvalue mytextdata)
)
(entmod myentdata)
)
Good luck
I think I posted this not that long ago, but I don't know where it went, so here it is again.
EDITNUM.lsp (attached)
; Adjusts any imbedded numeric strings of a selection set of text entities.
; v2.4 (3-1-96) added (max ... (@prec $cv_diff)) in line 133
; v2.5 (3-4-96) changed @prec to @rprec for real and added @sprec for strings.
; v2.6 (12-11-99) added multiplcation option as requested by Jeremy Lange of
; Maser (Toms River); also added numeric text filter '(1 . "*#*")
; v15.00 (04-07-00) for R15
; (12-17-00) added multiple picks for Picklayer option
; v15.01 (09-05-02) added support for Inserts with Attributes
; v15.02 (01-09-03) revised to update attributes.
; v15.03 (02-24-04) revised to try and handle K&K's large number.
; v17.00 (03-03-09) revised to handle Mtext
John F. Uhden
Thanks all! I wish I can learn some LISP, but I wish I have time for that. 😞
Now that is so shortsighted! As a rule, any time you spend on learning to code in Visual Lisp to solve small or big problems in your work is earned back in multiples.
Didn't you know? Myopic people never have enough time to see things through. :]
John F. Uhden
Is there any way to make this (or something similar) work on Mleaders with MText? I have routines that will update regular text, mtext, mleaders with attibutes, attributed blocks...but none of them work on an mleader with mtext.
I've got two sites that have a datum change and need to adjust all of the spot elevations by a constant amount.
I can't upload the actual files due to client privileges but here is dwg with the mleader style in question. The goal is to adjust all of the spot shots in the design file by a constant amount, in this case -0.87.
For reference I'm running Civil3D 2019 but these are not Civil 3D projects.
John F. Uhden
John: I tried your lisp but it won't select an mleader for me, just says 0 found.
John F. Uhden
(setq value-to-add(getreal "\n State value to add ")) (VLAX-FOR MULTILEADER MULTILEADER-vl-ss (setq MULTILEADER-string (vla-Get-textString MULTILEADER)) (setq old-value(atoi MULTILEADER-string )) (setq new-value (+ old-value value-to-add)) (setq new-string (rtos new-value 2 2)) (VLA-PUT-TEXTSTRING MULTILEADER new-string) )
Thanks for saving me the research.
The slight difference my EDITNUM has is that it operates on all numeric values within a text string and can handle super large values (Keller & Kirkpatrick had a tax map numbering project that had like 20-place integers/reals). Come to think of it, I think it maintains the precision unless the precision of the additive is greater than the precision of the existing (unless of course if the existing were to 1 place but the sum was to 2 places but with a trailing zero, in which case the 1 place would be honored). I probably made like $1.23 per hour, but they were happy. Anyway, that's infinitely more than any of us makes around this place.
There is no denying the gratitude, but gratitude doesn't pay any of my bills.
John F. Uhden
I checked out my code and it's easy to add MLEADERs. Um, but what is an MLEADER's dxf 0 name? What about its ObjectName?
John F. Uhden
Thanks John, I do appreciate you taking the time to look into this.
The ObjectName is AcDbMLeader isn't it? As far as the DXF 0, I don't see that listed in the group codes for Mleaders. DXF 172 is content type, and 290 is listed as hasMtext. But, I really don't know what I'm looking at beyond some basic lisp writing lol.
I gave Adesk feedback, Adesk had to fix MLEADER and use MULTILEADER in the DXF / LISP help.
AutoDesk help pages url:
http://help.autodesk.com/view/ACD/2020/ENU/
Productnames ACD/ACDLT/AMECHPP/ARCHDESK/CIV3D/...
Productversion 2015/2016/2017/2018/2019/2020/...
Productlanguage ENU/DEU/FRA/... (you can change the language also on the help page, in the upper right corner)
Samples
Programming section http://help.autodesk.com/view/OARX/2020/ENU/
MLEADER MULTILEADER - DXF
Sebastian
John F. Uhden
Can't find what you're looking for? Ask the community or share your knowledge.