Open falldeaf opened 8 years ago
I like the idea, and hopefully we can re-implement this functionality in the browser. I've made some recent changes that will make this easier.
As for the CLI script, I like the proposal that the 'm' flag can be used to select an object. But the script should also output appropriately if no selection is made. Does this mean all objects are combined (union) or files are created for each object?
Great point about the implication of not having an M flag if multiple objects are returned. I think union'ing all objects would cover most use cases.
This may be overkill but to be really comprehensive, maybe the 'M' flag could have a few reserved keywords? (union, all) and also accept a csv of names? -m union (does the default of giving you a union of all objects) -m all (creates multiple .stl files, using numbered file collision in case multiple objects have same name [ignores -o flag]) -m cube,circle (creates .stl files for only the objects listed [ignores -o flag]) -m cube (selects the cube object only [needs -o flag to name file]
Interesting...
Maybe we can follow one of the standard UNIX command lines, like CP. If the target is a file then "union" is implied. If the target is a directory then individual files is implied. And the -m flag serves to select which of the objects to output.
FYI, the whole file system API is available in NODEJS.
SYNOPSIS cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
DESCRIPTION In the first synopsis form, the cp utility copies the contents of the source_file to the target_file. In the second synopsis form, the contents of each named source_file is copied to the destination target_directory. The names of the files themselves are not changed. If cp detects an attempt to copy a file to itself, the copy will fail.
You could provide both union and separate file as follows :
If the return is an array, each element can be separately output using -m 0, -m 1 etc. Without -m the union of all the elements is generated.
For a returned object, -m
z3dev, I have to say, I really like that idea! It accounts for all scenarios without cluttering the -m flag with reserved keywords.
Cool!
I've started a new script. It only processes a single JSCAD file into STL, but reuses the code found in openjscad.js, including running the script and converting to another format. I had to make a few tweeks to OpenJsCad.Processor functions in order to make error and status messages display correctly (HTML vs CLI), etc. The BIG improvement is that include() works perfectly!!!
When the 'render multiple objects' functionality is used: http://joostn.github.io/OpenJsCad/#renderingmultipleobjects
It would be really helpful to be able to output each object as a stand-alone .stl from the command line. Possibly with a flag to designate which one?
For example, given the code:
Accessing each object might happen with a (m)ultiple flag: