Field for number of objects in the array

Field for number of objects in the array

Anonymous
Not applicable
4,769 Views
21 Replies
Message 1 of 22

Field for number of objects in the array

Anonymous
Not applicable

Is there a way to count objects of the array of a dynamic block and set a field for it? I have not been able to find it anywhere...I want to count these blue lines and make it to update in the text above. Thank you in advance.

0 Likes
Accepted solutions (1)
4,770 Views
21 Replies
Replies (21)
Message 2 of 22

Libbya
Mentor
Mentor

See attached. 

Message 3 of 22

Anonymous
Not applicable

That's it!  Thank you! Smiley Happy

 

I hope you can explain how you did this because I am trying to make several of these blocks, with different column offset, but I can't get it to work properly. Here are my questions:

 

1. Why is distance3 set to 1.5 and why, when I change it to some other value, it doesn't update anymore when I strech the block.

 

The reason I tried to change it is that when I inserted the block into the other drawing with units set to centimeters distance3 was to small and the field was showing zero value.

 

2.How can I modify a block so that it works properly? Which scale factors do I need to change?

 

3. How do I change the field expression so that I can get it to count right for other column offsets (12.5 , 15 , 20 , 25 cm ). I dont qiute understand what is the rule.

 

I hope that I am not bothering you with too many questions.

0 Likes
Message 4 of 22

Libbya
Mentor
Mentor

I noticed that in your initial file, the units are centimeters but you have a Factor of 10.  I had not seen that before, but I believe that creates a discrepancy between the block definition and model space by that factor of 10.  

 

When I initially modified the block, I made distance3 15 units and stretched at a distance modifier of 0.1.  I used the distance modifier of 0.1 to compensate for the column offset of 10.  I made distance3 15 units in order for it to round properly and increase by 1 for each additional object.  That worked properly in the block editor Test Block window, but did not display the correct values in model space.  I adjusted the block values to compensate.  If you remove the 10 factor from your units, the block can be modified accordingly.  

 

If you want to do the same for a different column offset, you should adjust the stretch distance modifier to 1/[column offset] and adjust the parameter length to [(number of initial objects)X(column offset)-(column offset/2)].

Message 5 of 22

Anonymous
Not applicable

Hi,

 

Thanks Dubravka for the topic and Libbya for the lesson.

 

Libbya,

 

To understand what you did, and to practice the lesson, I made a simple one myself similar to the original.

 

The formulas you mentioned don't return the right value in attached, unless we divide [(number of initial objects)X(column offset)-(column offset/2)] by the value of column offset. As a result, "column offset" will be out of formula.

 

I made another one for a column offset of an odd number (7) and block is working.

 

I think I am missing something here!

 

Can you have a look on my attachment and see what I am saying is right.

 

For original block you fixed, the formula returns:

[(number of initial objects)X(column offset)-(column offset/2)] = 2*10 - 10/2 = 20 - 5 = 15

 

but you set it equal to 1.5 so you divided the return by 10, which was column offset again.

 

Am I right?

 

 

Message 6 of 22

Libbya
Mentor
Mentor
Accepted solution

You're correct, I overcomplicated it.  No need to have column offset in the formula for the linear parameter distance that supplies the field value.  The distance for the linear parameter value should just be [(number of initial objects)-0.5].  The reason for subtracting the 0.5 is so that the value of a partially stretched interval is rounded down even if it is past the halfway point to the next arrayed object.  The field should be set to decimal with a precision of 0.  The distance modifier for the stretch action should be 1/(column offset).

 

I looked at the OP's initial file again and the discrepancy in scale is due to the fact that the units in block editor are cm and the units in model space are mm.  Here's the original file attached again with the units fixed.

 

 

Message 7 of 22

Anonymous
Not applicable

Well done. Thumbs up 🙂

0 Likes
Message 8 of 22

Anonymous
Not applicable

I made all the blocks and everything is working great! Thank you both for looking into my problem Smiley Happy Have a nice day!

Message 9 of 22

JoistDetailer
Contributor
Contributor

I'm looking at something similar and was interested in this solution.  However, why won't the attribute update without forcing a manual regen?  Is there a way to resolve that?  Frankly, I don't get the point of not having autocad display the correct information within a drawing, but I digress...

 

Anyway, I'm looking for a way to allow a user to interact with my dynamic block by either dragging the "array" grip OR changing the "property" that is the number if "objects" being shown in the property palette.

 

The only think keeping me from complete success (by using an an additional length parameter that is a "scaled" length of the overall block length) is the drawing units.  We use "architectural" units, so if the block contains 15 pieces of 3'-0" wide panels (45'-0" overall length), the "number of panels" shows up as 1'-3"...

0 Likes
Message 10 of 22

Libbya
Mentor
Mentor

Depending on the FIELDEVAL system variable setting, fields will update on several events such as open, close, save, plot, regen, etc...  There is NO WAY to get a field to update without one of those triggering events.  Simply changing a parameter value will not ever cause a field to update.  

 

I've never really cared as  I have FIELDEVAL set to the max so all fields will update before plotting and if I want to update immediately then RE [ENTER] is really easy to do.  

 

If that is really important to you then there are workarounds possible (e.g. using a block properties table) which I probably would have demonstrated in a screencast if you had attached your block.  Alas. 

0 Likes
Message 11 of 22

kamil_pajakH724R
Explorer
Explorer

Hi, I'm revisiting an old thread because I can't seem to figure it out. Could someone explain this to me step by step?

0 Likes
Message 12 of 22

CGBenner
Community Manager
Community Manager

@kamil_pajakH724R 

Hello and welcome!  Can you share some more detail on exactly what you are trying to accomplish, since this is such an old thread and the software has probably changed a lot.  Can you also share what version you are using of AutoCAD?

Did you find a post helpful? Then feel free to give likes to these posts!
Did your question get successfully answered? Then just click on the 'Accept solution' button.  Thanks and Enjoy!


Chris Benner
Community Manager

0 Likes
Message 13 of 22

kamil_pajakH724R
Explorer
Explorer

I've created a block that acts as a shelf. I'm adding subsequent shelf modules using an array. I'd like to automatically display text with the number of subsequent modules. AutoCAD version 2024.

Message 14 of 22

MMcCall402
Mentor
Mentor

Set the value of the attribute to be a Field that uses a formula to calculate the number of shelf units by dividing the value of linear parameter used for the array, Distance1, by the length of one shelf unit.

 

MMcCall402_0-1758650824608.png

 

Mark Mccall 
CAD Mangler


EESignature


VHB - Vanasse Hangen Brustlin, Inc.


Linkedin

0 Likes
Message 15 of 22

kamil_pajakH724R
Explorer
Explorer

I don't understand, I'm doing something wrong. When I add a field, after confirming it, it disappears when I reopen it. It's different for you. I've attached a video.

 

0 Likes
Message 16 of 22

kamil_pajakH724R
Explorer
Explorer

Perhaps some properties? I noticed that your unit factor is 0.001, while mine is 1. The same goes for Scale X, Y, and Z – mine are all 1, while yours are 1000. The most puzzling thing is the disappearing inserted field, which can't be edited later.

 

0 Likes
Message 17 of 22

MMcCall402
Mentor
Mentor

Use the BlockPlaceholder for the value of Distance1 in the formula.

 

Also, be sure to run ATTSYNC when you edit the attributes within the block editor to resync the inserted block with the revised block definition.  (I sometimes even insert a brand new one just to make sure there isn't some mismatched flaw)

 

 

MMcCall402_0-1758664458041.png

 

Mark Mccall 
CAD Mangler


EESignature


VHB - Vanasse Hangen Brustlin, Inc.


Linkedin

0 Likes
Message 18 of 22

kamil_pajakH724R
Explorer
Explorer

Am I doing it right now? I'm using attsync and inserting a new block. It only shows hashtags.

 

0 Likes
Message 19 of 22

kamil_pajakH724R
Explorer
Explorer

Could you record your screen while you do this?

0 Likes
Message 20 of 22

Brock_Olly
Collaborator
Collaborator

Instead of blockplaceholder, try Object > green button, select the distance parameter.
use that in the formula field, you should immediately see the actual value instead of ####.

Brock_Olly_0-1758699555539.png

Brock_Olly_1-1758699602780.png

 

 

0 Likes