You can have it round the value of only attributes with a certain tag, if that's always the same. Here's a routine that finds the attribute with a particular tag in selected blocks [though it does something different with it, but you should be able to adjust it]:
http://discussion.autodesk.com/forums/thread.jspa?messageID=6275258?
If the tag name of the attribute you want to round is *not* always the same, you could step through the attributes and check whether their content is numerical with decimal places, and only round it if it is.
If the content of an attribute is in a variable called 'value', then:
If it starts with any *non-numerical* character, which presumably the description would,
(atoi value)
will return 0. So
(zerop (atoi value))
will return T for non-numerical text [description] -- don't round that.
For *numerical* text, one thing you could do is to check whether the length of the string is the same after you've converted it to an integer and back to text:
(= (strlen value) (strlen (itoa (atoi value))))
will return T if the value represents an integer [point number], and nil if it has decimal places [elevation] -- round it only in the latter case.
Or, to combine:
{code}
(if
(and
(/= (atoi value) 0)
(/= (strlen value) (strlen (itoa (atoi value))))
); end and
(....apply rounding routine to value....)
); end if
{code}
though if an elevation might ever be 0.0000000000 exactly, that wouldn't round it, so you'd need to refine the check.
--
Kent Cooper
ArchD wrote...
I have a block with three attributes, point number, elevation, description, elevation with 10 decimal places. Could this code be made so that it reads the attributes, and finds any number longer than the hundredths, or tenths, then round them?....
Edited by: Kent1Cooper on May 24, 2010 3:14 PM
[simplified integer check code line slightly; added combined check]
Kent Cooper, AIA