Community
Dynamic Blocks Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using Attributes in Formulas

5 REPLIES 5
Reply
Message 1 of 6
savaytse66
1634 Views, 5 Replies

Using Attributes in Formulas

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?

5 REPLIES 5
Message 2 of 6
kentw
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
Message 3 of 6
truss_85
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.

Message 4 of 6
savaytse66
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!

Message 5 of 6
truss_85
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 ?

 

Message 6 of 6
Libbya
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. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost

 

”Tips

 

”Services