PDA

View Full Version : Formatting for Precision in Fields



stilesj
2004-07-20, 07:01 PM
Can anyone tell me how to format for precision in fields? Here is an example:
I have a horizontal line and I want to use a field to display the length of the line (or the angle, for that matter). It has a choice for the units, but those show a pretty high precision, such as 180.000000 for the angle. How can I get it to just say 180.
Really, I'd like to use this for displaying the area of a polyline in SF, but I will want it to be whole numbers, without the decimal or fraction.
Any ideas?

I appreciate it!

mjfarrell
2004-07-20, 07:11 PM
I'm going to go look...
first do your units, or LUPREC
have any impact on the returned values?

stilesj
2004-07-20, 07:17 PM
Yes, they do...that appears to be where the field is getting the information. If I change the precision of the units and regen, the field updates to those units.

We like to keep our precision high so that errors in drafting are more obvious. But I want the fields to be less precise for this application...rounding to the nearest whole number. It seems a shame if you can't override this for the fields like you can for dimensions.

If nothing else, I suppose we could change the units for that one drawing that displays all our square footages...but that would not be ideal.
Thanks for looking into it, Michael!

mjfarrell
2004-07-20, 07:25 PM
Yes, it seems that if you set your units
and then when you chose Object as the field
and then the Object you want it to read the data
from, you can chose curent units for it to display
using those settings.
Shame the formatting option isn't a little clearer,
it looks to be the data in the string after ( /f u3%d)
only that portion appears to be uneditable by the user.

stilesj
2004-07-20, 07:30 PM
Thanks very much, Michael, but even with selecting current units while the precision is low, it will go high again if you change the units and then regen. Besides which I need the architectural format for area. Unless some custom editing can be done with diesel (I'll try playing with that some), or autodesk comes out with some quick add-on that allows overriding the precision, the units will have to be set to a low precision on the drawing for keeps.

mjfarrell
2004-07-20, 07:35 PM
Perhaps while 'working' in the file the units would be set very high.
Then prior to plotting set then low and regen, this shouldn't impact
your dimensions as that is controlled via the DIMSTYLE.
I think you can concatonate the value returned by a Deisel expression.
I'm still back there poking at them to see If they twitch.

mjfarrell
2004-07-20, 07:52 PM
OK the sysvar FIELDEVAL will help with the
units regeneration issues to some degree.
Also there is a cryptic line in the help file related to
formating the field and units dislayed.
Even though you can not edit the field expression
shown in the lower disply window, it can help the user
see how fields are constructed.
This leads me to believe that one could replace the object ID
within a generic filed expression that was configured to display
that objects properties as the user requires despite
the units setting in a file.
I think this would need to be done in VBA or LISP
as you would need to evaluate the objects ID and object type
programatically and then select the correctly formatted mtext(field)
to place for that object, probably aquireing and passing the objects
rotation to the mtext expression such that the lable is properly
oriented.

stilesj
2004-07-21, 12:02 PM
Thanks, Michael, I'll look into those suggestions!

stilesj
2004-07-21, 01:23 PM
All right...it continues!

I just found a paper I had printed off before with some good information in this direction...at this point I have no idea where I printed it from, but here's what it's got:
Control codes are used in the fields for detailed options. You can edit these and just paste the whole field code into MTEXT to get the desired result. One example they give is like this:

%<\AcObjProp Object(%<\_ObjId 2130038592>%).Area \f "%.0f">%
which gives the area to 0 decimal places, regardless of the LUPREC setting.

However, it's still not in square feet so I started playing with the codes that do, but haven't gotten anywhere yet. Here's the code I start with based on our current units settings and object:

%<\AcObjProp Object(%<\_ObjId 2130038592>%).Area \f "%lu2%ct4%qf1 SQ. FT.">%

I'll play with it some more this afternoon, but I have to run to a meeting now and thought I'd throw it out there as an FYI and if you want to play with it.
Enjoy! I'll let you/everyone know if I find the answer.
Thanks!

kwong
2004-08-31, 12:42 PM
Jenna,
The info you printed off was from CadForum Cad Tip # 3676 - what I can't understand is the part about pasting it into MTEXT - how do I use that information? Can you explain it step by step? Thanks
Kin

stilesj
2004-08-31, 01:50 PM
Sure, just type out the code in Notepad, or copy/paste it from the field dialog into Notepad. Then edit it in Notepad how you want it. Then copy/paste right into AutoCAD (I think you can do it straight in, or start the mtext command and paste it into the editing window). AutoCAD automatically converts that code into a field. Unfortunately, it converts it so well that the only way you can custom edit it again is to redo it in Notepad. I wish AutoCAD would allow some custom editing in that fields dialog, with a better explanation of all the control codes...it seems to be almost there...maybe it'll be like the tool palette extension in 2004.

mjfarrell
2004-08-31, 01:54 PM
Jenna, glad to see that my hint, came to be a
proper solution (within the limits of Fields)