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

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    5136×  
Prices - CAD eShop:
applies to: AutoCAD ·

See also:
Tip 12685:ReLinkField - re-link fields to source objects.
Tip 12616:Att2elev - move block to elevation specified by its attribute.
Tip 12172:How to show or hide an object in all visibility states?
Tip 11898:Automatic schedule - number of blocks in a drawing.
Tip 11780:How to rename layouts by a specific attribute of the title block?

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   

Use Google Earth images in your AutoCAD projects with the Plex.Earth Tools 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.