@Yuvaraju.Dhananjay wrote:
....
this is really good. but it's not working in my drawing. Could you please go through the drawing which I have attached now.
....
The code is only for the conversion of the character content of a string. [The same is true for @_gile's suggestion]. To apply that change to a Text [or Mtext or Attribute or Dimension with override...] object of which such a string constitutes the contents, you need to wrap it in some more code, to pull out the contents string, modify it with the (nft) function, and impose the modified version back into the string content of the object. This works for me on the Text objects in your drawing:
(vla-put-TextString (setq obj (vlax-ename->vla-object (car (entsel "\nSelect Text to round to nearest foot: ")))) (nft (vla-get-TextString obj)))
If you need to apply the same to other kinds of things, such as Mtext if it might contain any internal formatting, or any kind of text-containing object if the contents might include more than just the distance part, or an Attribute for which different code would be needed to pull its contents out, then more work is needed.
It could also be made to work on multiple selected objects all at once, and even to handle the different possible object types each in their own way, if needed.
You may need to do:
(vl-load-com)
first. It can also be done without that, using (subst)/(entmod) methods and entity data, if you prefer.
Kent Cooper, AIA