sgenoud / replicad

The library to build browser based 3D models with code.
https://replicad.xyz
MIT License
323 stars 38 forks source link

Set a name for parts / the default scale in the output file #137

Closed maelp closed 3 months ago

maelp commented 5 months ago

I think that OpenCascade allows you to set the scale of the file (eg. meters or milimeters), when exporting to STEP / STL, is there a way to set that from replicad?

Also wondering if there's a way to go through all the parts and give them colors / names ?

maelp commented 5 months ago

BTW what's the proper way to access the Opencascade.js underlying implementation from Replicad, and the meshes? I'm not sure exactly how the wrapper is built and how I can call Opencascade.js functions if needed?

sgenoud commented 5 months ago

I think that OpenCascade allows you to set the scale of the file (eg. meters or milimeters), when exporting to STEP / STL, is there a way to set that from replicad?

No, I have not exposed them now (but I don't see any reason on the top of my head not to).

Also wondering if there's a way to go through all the parts and give them colors / names ?

You can give the parts within the workbench some names and colors, but this is not done at the opencascade layer (and will not be shown in the STEP file). Not sure how I would expose that though.

BTW what's the proper way to access the Opencascade.js underlying implementation from Replicad, and the meshes? I'm not sure exactly how the wrapper is built and how I can call Opencascade.js functions if needed?

The getOC function returns the opencascade object that you can use directly.

sgenoud commented 3 months ago

I have added a new method to export to STEP that supports colors, names (and units).

You can use it directly within the workbench with the STEP assembly options. With this model for instance.

Capture d’écran 2024-03-19 à 15 06 35

You can see in the code how it is being used (i.e. you need to provide a array of {shape: Shape, color: string, name: string} to configure the assembly.

maelp commented 3 months ago

Very cool!! Thanks a lot!