CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 5697

CAD tip CAD tip # 3676:

Question CAD 
 %  platform  category 
Q - question

Advanced formatting of AutoCAD 2005/2006/2007 fields.

A - answer Control codes in automatic text fields introduced in AutoCAD 2005 (the FIELD command) allow some detailed options which are not available in the standard user interface.

Fortunately, you can enter the field code manually (or by pasting) anywhere in the MText editor, when entering DText or in the DDEDIT dialog. Using this method, you can use some advanced formatting to your field values - see some examples:

  • %<\AcVar osmode \f "%X">%
    - displays OSMODE value as hex code

  • %<\AcDiesel test$(/,5,2) bbb \f "%tc4">%
    - displays DIESEL string expression with uppercase initials

  • %<\AcDiesel $(edtime,$(getvar,tdindwg),$(+,$(*,24,$(fix,$(getvar,tdindwg))),$(edtime,$(getvar,tdindwg),HH)):MM:SS)>%
    - displays total edit time (hh:mm:ss) spent on this drawing

  • %<\AcObjProp Object(%<\_ObjId 2130116872>%).Length \f "%ds33">%
    - uses "!" as decimal separator in object length (ASCII code 33)

  • %<\AcObjProp Object(%<\_ObjId 2130100448>%).Area \f "%.3f">%
    - displays object area to 3 decimal places (independently on LUPREC setting)

  • %<\AcObjProp Object(%<\_ObjId 2130042784>%).Area \f "%lu2%ct4%qf1%PR0 sq.ft.">%
    - displays object area in sq.ft. rounded (to 0 decimal places)

  • %<\AcObjProp Object(%<\_ObjId 2130276472>%).Area \f "%lu2%pr2%ps[area is , sq.m]%ds44%zs8%ct8[1234]%th32">%
    - displays the area rounded to 2 decimal places, with prefix "area is " and suffix " sq.m", decimal separator will be "," thousands will be separated by spaces, trailing zeroes will be suppressed, values will be multiplied by 1234 (A2007)

  • %<\AcObjProp Object(%<\_ObjId 2130112520>%).CustomScale \f "1\"=%lu2%ct1%qf28161'">% - displays viewport scale in the 1"=20' format

  • %<\AcDiesel $(upper,$(edtime, $(getvar, tdcreate),DD. MONTH YYYY))>%
    - displays drawing creation date in uppercase ("16. APRIL 2004")

  • %<\AcObjProp Object(%<\_ObjId 2130022304>%).Coordinates \f "%pt2">%
    - displays Y-coordinate of the selected POINT object

  • %<\AcObjProp Object(%<\_ObjId 2130022304>%).Coordinates \f "%pt4%ct8[0.001]">%
    - displays in [m] the [mm] Z-coordinate of the selected object (divides by 1000)
    - for block attributes: in the BEDIT mode, add a preset attribute a set its value to (Y-coord, A2007):
    %<\AcObjProp.16.2 Object(?BlockRefId,1).InsertionPoint \f "%pt2%.30q0%ct8[0.001]">%

Please note that you can also insert the %<\Ac-codes>% as DTEXT in AutoCAD LT (2005 and higher).

For other ways of flexible automatic labelling and linking object properties see LiveLabel by CAD Studio (also available for AutoCAD 2004 and 2002).

100% *  CAD 
22.3.2004    52866×  

See also:
Tip 13006:Calculated property descriptions (tobogan slide from floor to floor)
Tip 11983:How to use iLogic code to fill username into iProperties?
Tip 11794:Undocumented code in field expression - MText contents without control characters.
Tip 11171:Total number of layouts as a field (Page 3 of 7).
Tip 10889:How to get user's full domain name, phone No., department, e-mail...

Back   All CAD Tips

Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   

Track your time spent working on AutoCAD or Revit jobs - automatically with
CADstudio JobTime More info

Please use these tips at your own risk.
CAD Studio is not responsible for possible problems that may occur as a result of using any of these tips.