Dynamic Blocks

Reply
Valued Contributor
savaytse66
Posts: 65
Registered: ‎09-11-2007
Message 1 of 6 (348 Views)

Using Attributes in Formulas

348 Views, 5 Replies
12-09-2012 04:31 AM

I am trying to create an attribute that displays the product of an Area of an object in the block and the value of a different attribute. For instance, here is what makes up the dynamic block:

 

1 rectangle (with width and height parameters and stretch actions)
1 Attribute called "ForcePerSQIN" - the value of this is entered separately for every instance of the block by the user
1 Attribute called "Total Force"

 

In the "Total Force" attribute, I want to create a field that contains a formula to multiply the area of the rectangle (which I am able to obtain with no problems using the Area property of the rectangle object type) by the value of the "ForcePerSQIN" attribute, which is user-defined. The problem I have is that it appears as if the value of this attribute is treated as text and thus cannot be used in the calculation; I get ######.

Is there a way to make the "ForcePerSQIN" parameter treat the user-defined value as a number instead of text so that it can be used in the calculation? Or is there a better way to accomplish my ultimate goal?

Active Contributor
kentw
Posts: 32
Registered: ‎05-14-2012
Message 2 of 6 (336 Views)

Re: Using Attributes in Formulas

12-09-2012 11:06 PM in reply to: savaytse66

You can't reallly use attributes in formulas in the Parameter Manager.  Since you are talking about a simple rectangle, the procedure below can be followed

 

1.  Don't use parameter sets.  Use a combination of Dimensional Constraints and Geometric Constraints

2.  Use the dimensional constraints in the formula to calculate the area, or just go straight for the Force value.

 

In the example below the ForcePerSQMetre value can be controlled in the properties of the block.

 

10-12-2012 17-11-38.jpg

_________________________________________________________________

KarelCAD Application Support Specialist
Mentor
truss_85
Posts: 173
Registered: ‎02-13-2011
Message 3 of 6 (330 Views)

Re: Using Attributes in Formulas

12-09-2012 11:49 PM in reply to: savaytse66

I agree kentw attributes can not use in parameter manager. But this is not allaowed us to solve the problem take look attached drawing I think it is exact solution. I use field option. Take a look, if you need further information please ask.

Valued Contributor
savaytse66
Posts: 65
Registered: ‎09-11-2007
Message 4 of 6 (323 Views)

Re: Using Attributes in Formulas

12-10-2012 03:32 AM in reply to: truss_85

I think you might be onto something, but a couple questions:

 

  1. In your TOTAL_FORCE attribute, where is the calculation being done (FORCE_PER_AREA * AREA)?  When I open the "Edit Attribute Definition" dialog, I expected to see a field to edit in the default value, but I do not.  This might be the only difference in the way wou did yours vs the way I did mine.
  2. When I first tested your block, I was convinced it was broken.  After making a change and hitting REgen, the area would update, but the TOTAL_FORCE would not.  However, I found that hitting REgen a second time worked.  I wonder why a double REgen is needed...?

Thanks for the assistance!

Mentor
truss_85
Posts: 173
Registered: ‎02-13-2011
Message 5 of 6 (320 Views)

Re: Using Attributes in Formulas

12-10-2012 04:17 AM in reply to: savaytse66

answers to your question 1:

 

If you want to get an attribute value it must be outside of the block for field describtion. You can add field inside a block in this case polyline area, but when we discuss about attribute it must be assign outside the block in model space.

There should be a second difference between yours and mine; I think it is formula in field for example in this case we product (FORCE_PER_AREA * AREA) bu how? We must modify field code by hand unfortunately.

I have two field code to product:

 

%<\AcObjProp Object(%<\_ObjId 8796083895216>%).TextString>%      ------------>first
%<\AcObjProp Object(%<\_ObjId 8796083895296>%).TextString>%      ------------>second

 

the result code

%<\AcExpr (first*second)>%

 

%<\AcExpr (write formula of field here)>% it indicates formula to fields.

 

answers to your question 2:

 

All fields must be regen to update check field update settings.

2 regen needed because in the first AREA attribute take polyline area and TOTAL_FORCE attribute take AREA attrinbutes value but it has not change yet, second needed to update TOTAL_FORCE attribute with changed AREA attribute and it is done.

 

 

Please do not be hesitate any question in your mind ?

 

*Pro
Libbya
Posts: 1,109
Registered: ‎05-02-2007
Message 6 of 6 (52 Views)

Re: Using Attributes in Formulas

07-30-2014 08:08 PM in reply to: truss_85

Quote: "If you want to get an attribute value it must be outside of the block for field describtion. You can add field inside a block in this case polyline area, but when we discuss about attribute it must be assign outside the block in model space."

 

Nope.  Here the file is again with the formula field asigned referencing the FORCE_PER_AREA attribute value * area of rectangle.  Insert a new occurrence of the block and you will see it is all set up as the default and works fine.  Only one regen is needed to update both values. 

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.