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

CAD tip CAD tip # 10239:

Question CAD 
 %  platform  category 
Q - question

Conditional text fields in AutoCAD.

A - answer With a simple DIESEL expression you can created conditional text fields, i.e. AutoCAD drawing texts which change their contents on particular external conditions.

As an example, you can have a dynamic text (e.g. a title block attribute), which displays different contact information depending on the login name of the current user.

The the text field (FIELD) or in a plain Text, enter the following expression (on a single line):

%<\AcDiesel $(if,$(eq,$(getvar,loginname),"Jeff"),"jeff[at]cadstudio.cz",$(if,$(eq,$(getvar,loginname),"John"),"john[at]cadstudio.cz",$(if,$(eq,$(getvar,loginname),"Mary"),"mary[at]cadstudio.cz","cannot detect e-mail address")))>%

Due to the length limit of DIESEL expressions you can also write the tests individually - e.g.:

  
$(if,$(eq,$(getvar,loginname),"John"),"tel. 123456-987")
$(if,$(eq,$(getvar,loginname),"Bob"),"tel. 123456-986")
$(if,$(eq,$(getvar,loginname),"Jenny"),"tel. 123456-985")
$(if,$(eq,$(getvar,loginname),"Stephanie"),"tel. 123456-984")
...

In AutoCAD LT you can use a similar environment variable - USERNAME - $(getenv,username).

ACADLT
100% *  CAD 
15.3.2015    5103×  
Comments   Tell a friend
applies to: AutoCAD · AutoCAD LT ·

See also:
Tip 11565:AttDefault - reset block attributes to default values.
Tip 11404:Operations with attributes inside a block - fields.
Tip 11171:Total number of layouts as a field.
Tip 11160:Dynamic display of layer/block/text style/linetype properties.
Tip 10972:Replace text fields with static texts.


Back   All CAD Tips All CAD tips&tricks

How to make DWG texts readable in a 3D view (align to view)? « | » Arc bridges (gaps) in line intersections.

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:
Increase your productivity with our set of add-on functions for AutoCAD Civil 3D
CADstudio Civil Tools More info


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