News:

Please note new Forum URL: forum.designcad.com

Main Menu
DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

Group and solids count

Started by Dr PR, October 04, 2010, 10:32:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Dr PR

It would be nice if the "Help/Drawing Info" dialog would tell how many groups and solids are in a drawing. Maximum group and solid IDs would also be useful.

We have the "group count" and "solid count" macros, but they execute very slowly. In a 40 mbyte drawing I am working on that has about 12,000 solids, the "solid count" macro takes about 90 minutes to execute. The new "Pack Solid IDs" function appears to execute almost instantaneously in the same drawing. The "group count" macro also takes quite a while to execute in large drawings with thousands of groups.
DesignCAD user since 1987

bdeck

#1
Hi Dr PR,

Here's a macro that might work faster, so long as the dim index is not too high. Ive tested it on a <1GB machine with array dimension = 90,000. (or 180,000 in a single array)  

It is possible for the solid index and the group index to be higher than the total number of entities in the drawing. The macro allows for that possibility while minimizing the array dimensions.

If the arrays are still too big you can split the macro to do groups and solids separately or use the "Pack Solid IDs" function first.

Or the macro can be rewritten to do multiple passes using smaller arrays.


(tested on version 17.2)

Regards
BD


'sgc.d3m    Macro to count solids and groups   bdeck 10/10

n=sys(9)

for i=1 to n                                ' find max indices of solids and groups
GETATTR i, t , s, l, gp, r, gn, b, sol
if sol>solmax then solmax=sol
if gp>gpmax then gpmax=gp
if (i mod 1000) = 0 then print i, "   finding max indices"
next i

print "max solid index =",solmax,"    Max group index =",gpmax, "    hit any key to continue, ESC to end"
anykey k
if k=27 then end

dim sx(solmax+1),gx(gpmax+1)           ' create arrays to hold group and solid status

for i=1 to n                                       ' populate arrays
GETATTR i, t , s, l, gp, r, gn, b, sol
sx(sol)=1
gx(gp)=1
if (i mod 1000) = 0 then print i, "   counting solids and groups"
next i

sols=solmax
gps=gpmax

for i=1 to solmax                          ' look for voids
if sx(i)=0 then sols=sols-1
if (i mod 1000) =0 then print "sorting solids", i
next i

for i=1 to gpmax                            ' look for voids
if gx(i)=0 then gps=gps-1
if (i mod 1000) =0 then print "sorting groups", i
next i

print "total solids =",sols,"    total groups =",gps, "hit any key to end"

anykey








Dr PR

bdeck,

Thanks. It is fast. I'll test it on some large drawings.
DesignCAD user since 1987