Question: Replace identical meshes with block instances

I have this tree and there are thousands of leaves. Each leaf is a simple quad. If I create a block instance out of one them, is there a way to somehow select the others and replace them with block instances ?

Would this reduce the file size from 145Mb ? Is it worth it ?

Depending how many leaves there are, if the file size because of them is 145MB then probably a lot; I would guess even if you succeed with replacing them with blocks, Rhino will get a huge performance hit due to a number of individual objects (blocks)… (replacing identical meshes with block could be probably scripted but also depends how the mesh is built)

Is your goal reducing the file size or performance?

A few things to try:

  1. join all the leaves into one mesh (if not done already - the file size could get a bit smaller)

  2. after joning, try ReduceMesh on the leaves, sometimes even with 75% reduction you may not see much difference…

  3. you can try to make the tree a block and externalize it (export to a separate file) and then insert as linked - this will get rid of the heavy tree geometry from the main file.

hth,

–jarek

Yup. I think you are right.
Overall not worth the time and effort. I’ll either use a tree generator, or do the scene in Blender; use their particle system to grow the leaves procedurally.

For such cases I’d have the leaves all placed and textured, and when done I’d select all leaves (nothing else), use _ExtractRenderMesh, delete all original leaves, select all leave meshes and _Join them all into one disjoint mesh. There, only one object!

@nathanletwory Any way to select only these guys (leaves) but not all the twigs ? The leaves are simple quads, but I see they vary slightly in size and rotation. (If all tree is welded into one blob it goes down to 28Mb)

If you have the same material assigned to the leaves you could right-click on the material in the Materials panel, then use Select Object(s).

@nathanletwory No, I mean right now the leaves are glued to the tree. Assigning a leaf material will make the trunk and branches look like a leaf.

I thought your leaves were all seperate mesh objects?

If I explode it yes, but then how do I select only leaves but not twigs ?
Would be nice if the original OBJ had the leaves in a separate group. It didn’t.

The leave meshes (when exploded) are all meshes with 4 vertices?

Yup.

Explode your mesh, then run:

import scriptcontext as sc
import Rhino


Rhino.RhinoApp.RunScript("_SelNone", False)
meshobjects = [ob for ob in sc.doc.Objects if isinstance(ob, Rhino.DocObjects.MeshObject)]

for meshobject in meshobjects:
    m = meshobject.Geometry
    if m.Vertices.Count == 4:
        meshobject.Select(True)
1 Like

@nathanletwory 98,000 leaves successfully separated from 2500 twigs and branches. Thank you Sir !
(File reduced from 145Mb to 30Mb)

1 Like