Field for number of objects in the array

Field for number of objects in the array

Anonymous
Not applicable
4,818 Views
9 Replies
Message 1 of 10

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,819 Views
9 Replies
Replies (9)
Message 2 of 10

Libbya
Mentor
Mentor

See attached. 

Message 3 of 10

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 10

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 10

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 10

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 10

Anonymous
Not applicable

Well done. Thumbs up 🙂

0 Likes
Message 8 of 10

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 10

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 10

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