Count block occurences

Pioneer
Pioneer

is there any way to count with a variable how many times a block appears on a drawing ?

13 REPLIES

Re: Count block occurences

Esteemed Contributor
Esteemed Contributor

There is no variable in the Variable Table that counts them.  There is a Block Table that you can place that will count and label the blocks and their occurences for you.  Not sure if that will work for your needs.  If it doesn't, then you are probably looking at some automation code.


Thanks,
Ken

Production: ST9 MP10
Testing: ST10 MP1

Re: Count block occurences

Phenom
Phenom

I am unable to see Solid Edge adding such variable but a custom macro can help add/update such a variable,  though it will need to be run manually to show the correct value every time.

 

Re: Count block occurences

Phenom
Phenom

I agree with Ken; perhaps we were answering in real time.

  

I was able to quickly cook up the attached macro that simply lists the count of each block in a draft document.

A basic test on the sample seddasc.dft in the Training folder shows the counts are matching with those in the Block Table (though not sure why the order differs, neither appears to be sorted).

 

 

2016_July_18_01.png

 

Source code is available if you need.

Further, adding each count as a variable would be a piece of cake.

   

~Tushar Suradkar

fb.pngSolid Edge Users Facebook Group

 

 

Re: Count block occurences

Pioneer
Pioneer
can the infos in the table be exposed as variables in any way ?

Re: Count block occurences

Phenom
Phenom

Hi,

 

I don't think that you can use it as a variable, but you can use it as a Reference text.

 

Here is an example:

 

BR,

Imics
http://solidedgest.wordpress.com/

Re: Count block occurences

Pioneer
Pioneer
perfect ... exactly what I needed ... thank you

Re: Count block occurences

Pioneer
Pioneer

actually just tested it out and it turns out not to be of that much help ... the table doesn't auto-update afer placing a new block I have to add the block to the table manually and the property text is also random so I can't use it in a template to always count a certain block that will be placed repeatedly on a drawing

Re: Count block occurences

Pioneer
Pioneer

is there any other element that I can easely count with a variable or property text ? 

 

the drawing I make have 2 symbols on the an SC and a CC that are conditions placed on different dimensions.

these need to be counted and the numer writen down in the border.

 

I could work with pictures texts or anything else that can be counted and will updated withoud needing to count manually 

Re: Count block occurences

Phenom
Phenom

The attached macro will create and/or update variables for each block with its count as value in the format:

BlockName_Count

 

The macro will not work automatically when you create/delete block references, It needs to be run every time to update the variables.

 

Variable will not be created for blocks whose names are invalid variable names. For e.g. a block name can contain spaces but a variable name cannot, so this block will not have a variable created by the macro.

 

2016_July_25_01.png

 

The variables are pre-exposed.

 

Feel free to ask for any modification or enhancements to the macro or its source code.

 

If the macro is working for and you find it useful, mark the post as accepted solution.

 

~Tushar