CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products []
CZ | EN | DE
Login or
  Visitors: 11181
Plex.Earth connects AutoCAD and Google Earth

CAD tip CAD tip # 11404:

Question CAD 
 %  platform  category 
Q - question

Operations with attributes inside a block - fields.

A - answer If you want to perform an operation with attribute values directly inside a given block, you can define this operation either in the block definition or later in the block reference (insertion of the block instance).

You have e.g. a block with 3 attributes and you want the third attribute to contain a text string concatenated (merged) from the current values of the first two attributes. See an example in ConcatAtt.dwg - Block #15079.

To setup the requested operation in the block definition, set the third attribute's value from the fields referencing the objects (values) of the definitions of both source attributes (in Field: Object>Attribute Definition>Value and check Display value for block reference). To evaluate the attribute operation/fields after you insert the block or change its values, the block has to be dynamic - i.e. it must contain any dynamic action, e.g. a position, a visibility state, etc. plus you have to invoke this dynamic action at least once after you insert the block into your DWG drawing - e.g. drag the position node, change the visibility state. See the example, the block Concat (left).

For an operation defined in the block reference, you just use the attribute editor to set a field referencing the same object (the inserted reference) and the values of its first and second attributes. Such definition is evaluated automatically - i.e. e.g. on a regen. See the example, the block ConcatRef (right).

So after you change the value of the source attributes, perform the necessary update action and the block will reflect the changed value in the target attribute.

You can use a similar approach to link/mirror two attributes together - have two different attributes carrying the same value in a single block.

To calculate values through the block definition you can also use a simplified method independent of dynamic blocks, with simple automatic updates on block insertion and on any subsequent DWG Open or Regen operations.

An example - the block TestHiLo (see) with the controlling master attribute "Val0" and with two dependent attributes "Hi" and "Lo". These will be automatically assigned values always incremented and decremented by one off the value set to the master attribute. Just insert the textual form of the calculation expression to their preset (default) values - here specifically:

%<\AcExpr (%<\AcObjProp.16.2 Object(?BlockRefId,1).Val0>%+1)>%


%<\AcExpr (%<\AcObjProp.16.2 Object(?BlockRefId,1).Val0>%-1)>%

100% *  CAD 
27.4.2017    12777×  
Prices - CAD eShop:
applies to: AutoCAD ·

See also:
Tip 13868:XrefStamp - create a dynamic list of xrefs in your DWG drawing.
Tip 13784:Export block coordinates to a table. How to use the DATAEXTRACTION command in AutoCAD LT?
Tip 13599:How to read iProperties from Inventor models and drawings in AutoCAD DWGs?
Tip 13522:LookupXLS - populating DWG texts from Excel spreadsheets.
Tip 13337:How to select blocks by attribute values? (SelByAttr)

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   

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.
Arkance Systems is not responsible for possible problems that may occur as a result of using any of these tips.