mayo icon indicating copy to clipboard operation
mayo copied to clipboard

Export each part as separate STL and STEP file from console

Open semixor opened this issue 11 months ago • 11 comments

Hello, is it possible to export each part of CAD (STEP) file as a separate STL and also STEP file from console ? also wondering if it's possible to export faces of each part as STL ?

Frankly speaking, I'm doing this with FreeCAD but it's very slow on big assemblies, tested Mayo and it's blazing fast, would be nice if you guys can help on this.

Thank you.

semixor avatar Mar 25 '24 21:03 semixor

Hello @semixor For your purpose I think the most flexible solution would be scripting support This has to be implemented and then scripting in Mayo would allow you to visit assemblies by JS(JavaScript) code and do whatever is required(eg export parts to STL files in your case)

Mayo should also support executing a scripting file from command line and exit

What do you think of that solution?

HuguesDelorme avatar Apr 04 '24 08:04 HuguesDelorme

Hello @HuguesDelorme, Absolutely ! This is the best solution ! Also would be nice to have some control over it, like ability to export the wires(edges) for later visualization in ThreeJS for example etc.

Looking forward when you will be able to implement it, many thanks, can't wait !

semixor avatar Apr 04 '24 08:04 semixor

Hello @HuguesDelorme , any status update on this ?

semixor avatar May 02 '24 08:05 semixor

Hello @semixor I started to work on scripting support in the feature/scripting branch For now it's providing basic DOM-like access to Mayo data, here is an testing example script:

console.debug("Mayo version: " + application.versionString);
console.debug("Document count: " + application.documentCount);
for (let i = 0; i < application.documentCount; i++) {
    let doc = application.documentAt(i); // Access i-th document
    console.debug("Document: " + doc.name);
    console.debug("    filePath: " + doc.filePath);
    console.debug("    entityCount: " + doc.entityCount);
}

if (application.documentCount > 0) {
    let doc = application.documentAt(0); // Access 1st document
    doc.traverseModelTree(
        nodeId => {
            console.debug(
                "treeNodeId: " + nodeId
                + " name: " + doc.treeNodeName(nodeId)
                + " parentId: " + doc.treeNodeParent(nodeId)
                + " tag: " + doc.treeNodeTag(nodeId)
            );
        }
    );
}

The next important things to be supported are:

  • access to BRep shapes and their underlying geometry
  • reader/writer per file format

For writer objects it's not easy to support what you ask "ability to export faces of a part and wires(edges)" because the smallest thing that can be exported is a "node" in the model tree. A model tree node in Mayo being an assembly, instance or part. Maybe the solution is to make writer objects support exporting of TDF_Label directly. So if you want to export a shape(face, wire, ...) then the scripting API should allow to add a label for that shape(XDE) and pass the label to the writer.

HuguesDelorme avatar May 02 '24 08:05 HuguesDelorme

Hi @HuguesDelorme this is very nice, looking forward to be able to work with it, great job, thank you !

semixor avatar May 06 '24 10:05 semixor

Hi @HuguesDelorme when I will be able to test this beautiful work :) ? Thanks !

semixor avatar May 14 '24 19:05 semixor

@semixor I've been working on different topics on Mayo these last weeks, I should have focused on a single one... Going to work on JS scripting again, looks like a very valuable feature for the user Will let you know about significant work pushed on the feature/scripting branch

HuguesDelorme avatar May 17 '24 10:05 HuguesDelorme

Hi @HuguesDelorme , Thank you so much for the update !

semixor avatar May 17 '24 10:05 semixor

Hi @HuguesDelorme, I see there is some active development happening for this feature, that's awesome ! Please let me know when you have first working version to test, thank you so much ! Best Regards !

semixor avatar Jun 06 '24 14:06 semixor

@semixor Access to BRep shapes are now supported by scripting There's almost 100% support for surface geometry access(plane, cylinder, bspline, ...) Next step is to cover also curve geometry from BRep edge The step after is supporting reader/writer objects

HuguesDelorme avatar Jun 06 '24 17:06 HuguesDelorme

@HuguesDelorme wow that's a lot of work being done from your side, thank you.

semixor avatar Jun 06 '24 18:06 semixor