Hi all. I do face a challenge as I do have some huge files that consist in a lot of repeating objects and I do need to reduce their file size as much as possible. I do found and tested that if I do replace the repeating geometries with blocks I can reduce drastically the filesize. I do created a Grasshopper definition that it is sorting the identical geometries by filename and volume, I do created a block for each geometry but I can’t find a way on how i can create the planes and make the block to align into the same position as the target geometries. The geometries can have all kinds of rotations and orientations in space, but they do have the same name and volume.
The difference between files it is quite substantial, in a small sample I was able to reduce the filesize from 51MB to 12MB. I do needed to use the SaveSmall option to be able to reduce the real size to be able to post the file here.
The red parts are the geometries from which I do want to create a block definition and the green parts are the geometries that I do want to replace with instances of the corresponding blocks.
Step 1 - Analyse your object and define a plane that could be identically identify on other copied objects of your model.
Assuming they have been created in the same way, that logic should work the same with all identical objects
For example, I search the largest face of the object and evaluate it to find a base plane.
Step 2 - Analyse with that exact same logic all identical objects that you have and insert the block newly created on the found plane.
That should insert an occurency of the block definition at the exact same place as the original brep. Just need to clean objects that are not blocks at the end.
I do thought initially to the same logic. The only issue is that using this approach can result in bad orientation of the blocks. What if I do have multiple faces having the same area? How I can be sure that the blocks will be always correctly oriented to the correspond geometry?
I do think that just calculating a plane it is not enough to ensure the desired result.
For sure you have to ensure of that.
Maybe you could orient your plane in the direction of the longest curve or find the logic that will suit best to your need depending on the geometry you’re working on.
By coupling various geometrical analysis (volume of a brep, area of a face, direction of an edge …), we usually find a good combination that works well…