Author Topic: Number of solids and groups  (Read 301 times)

Dr PR

  • Hero Member
  • *****
  • Posts: 5398
Number of solids and groups
« on: December 04, 2016, 09:35:16 AM »
In the "Help/Drawing Info" dialog it would be nice if the current "Max Solid ID" and "Max Group ID" were shown. If solids and groups were packed before opening the dialog the current "Number of Groups" and "Number of Solids" could be shown. This would be useful information.

We have macros to show this information, but they are VERY slow! The last time I ran the macro for number of solids I aborted the macro after about 45 minutes. I don't know if it crashed because it hasn't been updated to the newest maximum ID value, or if it just takes hours to run in large drawings. In any case the max solids and max groups macros are useless in large drawings.

It would be easy to display this information in the "Drawing Info" dialog since the program keeps track of the maximum group and solid IDs.

Phil
DesignCAD user since 1987

Lar

  • Hero Member
  • *****
  • Posts: 2484
Re: Number of solids and groups
« Reply #1 on: December 04, 2016, 06:22:58 PM »
The last time I ran the macro for number of solids I aborted the macro after about 45 minutes.
Wow! My files are nowhere as large as yours (no more than 25 MB) but my max id's display instantly.

Lar

Dr PR

  • Hero Member
  • *****
  • Posts: 5398
Re: Number of solids and groups
« Reply #2 on: December 04, 2016, 08:14:18 PM »
A 270 Mbyte file contains about half a million entities. I have some files with up to 1.5 million entities. For obvious reasons doing anything with these files takes a lot longer than with 10 to 20 Mbyte files.

It takes about 25 minutes to create the first shaded image with the 270 Mbyte file. After that it shades again in about 3-5 seconds.

In these drawings there are many more solids than groups. When I save a file the "packing groups" message appears for less than a second, but "packing solids" takes many seconds. This is with the compiled program code.

Macros are an interpreted language. So for each iteration of a loop the program must read the code, translate it word by word, and then call the appropriate machine code routines. This is in addition to processing the loop iterations and other housekeeping. The program must execute a significant number of instructions just to figure out what routines to call, so it takes a LOT longer than the compiled program code.

The group/solid count macros cause the program to execute hundreds of instructions for each entity in the drawing. That becomes hundreds of millions of instructions for large files, and that takes time. They just aren't practical for large drawings.

Phil
DesignCAD user since 1987

Lar

  • Hero Member
  • *****
  • Posts: 2484
Re: Number of solids and groups
« Reply #3 on: December 05, 2016, 06:50:09 AM »
<<the following was done on a non-intel (ie, not so fast) laptop>>

The "highest used" and "lowest unused" group id's are sys numbers (1141, 1142) so they should report immediately, as in this macro:
Code: [Select]
'Group Index-Highest, sys(1141), and Lowest, sys(1142)_30 Oct 09.d3m    by Lar

precision 0
message "             -[v19 plus]-",chr$(13),"Highest used group index (read-only) =",Sys(1141),chr$(13)," ...Lowest un-used group index (read-only) =",Sys(1142)

I took a 25+ MB drawing and duplicated everything 4 times (now 126, 656 100, 941 unbloated, almost 400,000 entities, maybe 40 jpg images, if that makes a difference... and lots of linked symbols, now that I think about it).

I have another macro that reports the max group id. It opens a text window and you can see it counting the groups. I think it was written by DT before we had the sys numbers above. It took 27 secs to count to 4832 in my enlarged file. This was after the file was saved-as, so the groups were already packed, if that makes a difference (when saving-as, the file took more than 10 min to pack the group id's... I wasn't looking when it packed the solids but it didn't seem to take much time)

I ran the macro below and it reported the highest solid id in 13 secs. Phil, when you have time, could you try it on one of your large drawings to see how long it takes. While its running it may appear to be doing nothing, until the end where it displays a message of the highest solid id. Before the end the only way you can tell it's running is if you have the 'stop macro' command in a toolbox. The icon is a black square (like 'stop' on a video player) and as long as a macro is running the icon is not grayed out  click the Tools menu you will see the 'Stop Macro' icon (a solid black square) not grayed out. You can leave the menu open and when the macro ends the menu will go away as well as the message opens. I can't remember if I ever posted this macro on the forum but I'm thinking this isn't the macro you use, Phil.
Code: [Select]
'Solid Max Index.d3m   by Lar, 25nov14
'Find max solid id in a drawing...

precision 0

'start count for solids...
max_sol=0

'iterate through all entities
for i=1 to sys(9)
entity i
'if the entity's solid id is bigger than max_sol then max_sol becomes the value of the solid id...
if sys(95)>max_sol then max_sol=sys(95)
next

message "Max Solid ID=",max_sol


Lar
« Last Edit: December 05, 2016, 09:25:02 AM by Lar »

Dr PR

  • Hero Member
  • *****
  • Posts: 5398
Re: Number of solids and groups
« Reply #4 on: December 05, 2016, 11:04:06 AM »
Lar,

Thanks.

I used a current 232 Mbyte drawing with 539,098 entities (4,353,964 points) to test the macros.

The high/low Group ID macro executed in less than a second. Highest Group Index = 846

The solid max index macro ran for about 4 seconds. Max Solid ID = 13,447

****

I don't know why the older macros I tried failed.

Phil
DesignCAD user since 1987

Lar

  • Hero Member
  • *****
  • Posts: 2484
Re: Number of solids and groups
« Reply #5 on: December 05, 2016, 11:55:32 AM »
The solid max index macro ran for about 4 seconds.
Wow!

The power button got messed up on my normal laptop so I'm using a very slow one. On my enlarged file the solid id macro took 19 secs. I remembered there would be lots of linked symbols so I exploded them all, resulting in about 200,000 more entities. The macro then took 45 secs.

Lar