CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 2072 

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).

ACAD2007ACAD2005ACAD2004LTMapADT
100% *  CAD 
22.3.2004    37790x  
Comments   Tell a friend

See also:
Tip 9619:How to get rid of "----" in empty fields?
Tip 8951:Multicolor dimension texts in AutoCAD.
Tip 8852:Publish interactive 3D models on the web with Autodesk 360.
Tip 7844:How to round a field to the nearest 5 units.
Tip 7318:Activating AutoCAD license on-the-fly.


Back   All CAD Tips All CAD tips&tricks

Where can I find the Bend table in Inventor? « | » Automatic level indicator for AutoCAD.

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   



Featuring:
DwgTextTranslator translates a series of drawings from one language to another using MS Access.
Download a fully functional trial version.


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