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?
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.
KarelCAD Application Support Specialist
I think you might be onto something, but a couple questions:
- 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.
- 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!
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 (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 ?