Solved! Go to solution

Count block occurences

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


Re: Count block occurences

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.


Production: ST9 MP7
Testing: ST10

Re: Count block occurences

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

[ Edited ]

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).





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

can the infos in the table be exposed as variables in any way ?
Accepted by topic author NorbertS
‎07-22-2016 10:07 AM

Re: Count block occurences



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:




Re: Count block occurences

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

Re: Count block occurences

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

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

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



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.




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.