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

Creating a simple formula with fields in attributes

18 REPLIES 18
Reply
Message 1 of 19
Anonymous
18942 Views, 18 Replies

Creating a simple formula with fields in attributes

Hi there,

 

I'd appreciate if anyone can help me on this.

 

I'm trying to create a block with 3 attributes say, A, B, C for argument's sake. When introduce this block in my model space of the drawing I would like to be able to change values A & B as a number and for attribute C a formaula = A-B. I've searched on youtube and I've seen a video and tried to follow it religiously, but I can't get it to work. The number in this case will be a level, so formatting would hopefully be 00.000.

 

Thanks in advance

18 REPLIES 18
Message 2 of 19
Anonymous
in reply to: Anonymous

Here is a similar tread http://forums.autodesk.com/t5/autocad-2013-2014-2015/using-fields-in-attributes-cutting-up-data/m-p/...
I have tried with diesel and fields.
I'm not that good in diesel and I couldn't get the attribute values from A and B.
Depending on what you are doing you could take a look at the verticals like Architecture.

Message 3 of 19
Anonymous
in reply to: Anonymous

I was going to use it to work out depth to invert on manholes references. i.e  If A were to be the cover level. B is the Invert level, I wanted to be able to calculate C the depth to invert automatically from the attributes. Something similar to the video below, but without the attribute showing the workings out.

 

https://www.youtube.com/watch?v=msWBQZ5E0d4

Message 4 of 19
steven-g
in reply to: Anonymous

In the attachement is a working example, the video you saw shows it well, but does't explain it. In order for a field to read another field in the same block you first need to perform a dynamic action on that block (any dynamic action) it doesn't actually have to do anything. The explanation is long winded but look at the example, if you create the formula correctly, then it should work.

In the example the block on the left is a newly inserted block and changing the values of attributes "ONE" or "TWO" changes those valuesin the block, but has no effect on "THREE" the block on the right will change (after a regen). Click on the left block and change it's visibility state, and then it will start working. You only need to change the visibility state once as this activates the fields in that block (it actually turns it into an annonymous block - short winded explanation).

It's also a good idea to change the properties of attribute "THREE" to preset so that you are not prompted for a value when you insert the block or you might accidently overwrite the fields. If you still get stuck then post a copy of your block.

 

Message 5 of 19
Anonymous
in reply to: steven-g

Simple and easy. Excellent! 🙂
Message 6 of 19
Anonymous
in reply to: steven-g

Thanks for this, this has explaned it better. The problem with this is, if there were many instances of this block in the same drawing you'd have change every single visibilty state of each block then do a regen to get to work properlly. Is there a way to globally trigger the fields? I've tried update fields but that does'nt appear to work. What i might do is insert the block with default values for attribute 1 & 2 then inset a field in attribute 3 manually in the model space of the drawing, then just copy the block around the model space.
Message 7 of 19
steven-g
in reply to: Anonymous

Unfortunately thats just how this works, without performing a dynamic action to change the block, the formula in the field is still looking at the block definition for it's input, as soon as a dynamic action has taken place then the formula refers to the attributes within itself, the good news is it only needs doing once, and if you then coppy that block around the drawing or for that matter into different drawings, then each instance will behave as you want, there is no need to worry about the dynamic action again. I just ran a quick test and placing an active block onto the toolpalette, looks as though when the block is inserted into another drawing that the field works straight off.

Message 8 of 19
Anonymous
in reply to: steven-g

Hi

 

Perhaps you would be able to tell me if it is possible to modify text values (append/remove) from the source block to the second block. I have placed my query on the forum earlier.

 

Please see

 

https://forums.autodesk.com/t5/autocad-forum/add-more-text-to-linked-block-attribute/td-p/7254967

 

regards

 

Paul

Message 9 of 19
Anonymous
in reply to: steven-g

I spent several hours trying to make it works without success. Depending how you create the block and attribut, the formula sometime works, sometime not. It has a unpredictable behavior. The best I've got was to make it works one or two times only and than get this symbol "#".

Message 10 of 19
steven-g
in reply to: Anonymous

Could you post the block, someone can try and find out what is going on.

Message 11 of 19
Anonymous
in reply to: steven-g

Here is the file. I want to actually use the first four fileds to fill automatically the fifth one called "serial number". Note that the serial number is shown intentionally very small in the circle.

 

Thanks for your help!

 

Louis Turgeon

Message 12 of 19
steven-g
in reply to: Anonymous

I must admit to having a hard time changing your block to work, but things like having a prompt in the attribute being used to collect the information doesn't help, and at I guess it looks like some attributes have been created outside the block and then brought in, because they reference as a block in the object field, and a really odd behaviour of the "NUMÉRO-SÉRIE" attribute is it shows the VALUE inside the block editor where I would normally expect to see the TAG. Rather than trying to figure all that out and trying to fix it in your block, I have created an example of a block where it is setup with 4 input attributes one of them invisible, and these are combined into the container attribute to show after the visibility state is altered and a regen done on the drawing.

 

To recap, in order for this trick to work the attribute used to reference other attribute values needs to have the prompt value empty, be position locked and set to preset so that the fields aren't overwritten. And then a dynamic action needs to be performed on the block followed by a regen in order for the block value to update. This dynamic action only needs to be done once in the life of the block and once a block is activated then it can be copied, and copies work.

 

Message 13 of 19
Anonymous
in reply to: steven-g

Thank you very much for your time Steven. I'll try it and get you back with the result.

 

Louis Turgeon

Message 14 of 19
brendon
in reply to: Anonymous

Hi guys,

 

I am having a very similar problem and can't get the text to apply the value.

Spent a fair bit of time fiddling now and I feel like I am going in circles.

 

I have the field expression inside the attribute linking to another attribute that I can edit

 

Thank you,

 

Brendon

 

 

Message 15 of 19
Libbya
in reply to: brendon

You cannot have the attribute set to Constant = Yes.  It cannot update that way.  Here's a screencast:

Message 16 of 19
brendon
in reply to: Libbya

That is fantastic, its always one little tick box that takes ages to find.

 

Is their a way of stopping that TAG from appearing in the attributor editor.

So that it is very difficult to manually overide.

 

Thank you,

 

Brendon

Message 17 of 19
Libbya
in reply to: brendon

You can place the att containing the field on a locked layer.  I think that would be a workable solution in your block.  It can cause odd text justification issues but in this case I think it would work ok.  

Message 18 of 19
brendon
in reply to: Libbya

Thanks Libbya,

 

I just tried this. If I put one of the att values on a locked layer, the block seems to freeze out all the attributes, not just those on that locked layers.

When I manage the attributes, those that are on a locked layer have the L in the mode column.

 

I can reference a second block with the input values but this would be a bit of a work around.

 

Have I missed something?

 

 

 

Message 19 of 19
alexandresynth
in reply to: steven-g

Thank you very much for teaching us. I figured out by myself that autocad was reading the standard value of the attribute but not the new ones that we add, but i didnt realized how to fix it, i did how u told me and it worked.

 

Now i have just a small problem, i am doing a type of project that i need to show the positive or negative valur of the number. If the formula in the attribute gives me a negative value autocad shows me the - symbol, but if the value is positive it does now show. How can i fix it?

1.png

2.png

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

Post to forums  

”Boost

 

”Tips

 

”Services