Dynamic Blocks

Reply
Valued Contributor
Posts: 65
Registered: ‎09-11-2007
Message 1 of 5 (256 Views)

Using Attributes in Formulas

256 Views, 4 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
Posts: 32
Registered: ‎05-14-2012
Message 2 of 5 (244 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 5 (238 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
Posts: 65
Registered: ‎09-11-2007
Message 4 of 5 (231 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 5 (228 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 ?

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community