This may be a long email. First, I want to praise CadQuery for performing a specific task very well. That task is the ability to program a part and then save to STEP file (especially), all without the use of any GUI. In other words parts can be generated in a very automated or batch-processed mode, without any human intervention. In computer animation build scripts, for example, the rendering of individual frames is usually preceded by generation of all parts involved as individual STL files.
That being said, I rather like the default drawing style of the cq-editor, which employs a stencil outline and a nice phong shading for smooth color transitions, with a touch of spectral lighting. No complaints there.
And so, I am flirting with the idea of creating entire assembly video animations using this style of drawing, which has the outline drawing together with the shaded color drawing. This style of drawing, you could say, is a cross between a patent-application-style outline drawing and a plain vanilla non-photo-realistic polygon-filled drawing. At the very least, I would like to ability to create these sorts of image snapshots individually, for use in other ways (besides creation of 3D computer animation assembly videos).
Therefore the question I want to ask here is, which sort of rendering tool would be recommended to give this style of drawing, from an input STEP file (because the boundary representation is of course needed for generating the proper stencil outline as depicted above).
I flirted with the idea of using CadQuery and/or cq-editor to generate these sorts of drawings. First I tried the SVG exporter from CadQuery:
cq.exporters.export( part,
"./diff_tube.svg",
opt = {
"width": 960,
"height": 540,
"marginLeft": 50,
"marginTop": 30,
"projectionDir": (100, 100, 100),
"showAxes": False,
"showHidden": False,
"focus": 40 # Unfortunately causes coarse polygonal approximations.
}
)
However while the SVG exporter would be great for patent application drawings, it does not fit my need; lacking, for example, is the ability to color the interior, and with perspective projection the circles are no longer ellipses (or at least the curve computations become much more involving) and so the strategy employed by CadQuery SVG exporter seems to be to approximate curves/arcs with a coarse number of straight line segments, as can be seen above. No complaints there really, because I realize that CadQuery would do great at creating patent style engineering drawings which usually employ orthonormal projection.
Now if we "screen capture" something directly from cq-editor, the results are also quite interesting.
The above screenshot was taken with the default orthonormal viewing projection. As we can see there is a bit of a z-buffering issue with the outline. However, if we instead choose perspective projection (which is something I'm always going to rely on for my intents and purposes) then we get something that looks more like this:
The outline z-buffering anomaly has disappeared and more surprisingly the approximation for the curve/arc which was a coarse polygon when generated in SVG form now seems to be perfectly "smooth".
So, instead of searching for a tool outside the scope of CadQuery tools which will give me exactly the type of drawing directly above, with that same level of excellent quality, why not render to PNG directly from cq-editor, I ask.
Well, with that idea there are still a few missing puzzle pieces. First, I would need to remove the red/green/blue coordinate axes (unless I devise a trick such as shifting the object far away from origin). Also I am looking for a programmatic way of "snapping" these screenshots to disc. For example I need the ability to specify camera angle and camera distance, camera position, all from some sort of script. By comparison, OpenSCAD has a nice command-line interface which can be studied on UNIX systems by issuing the "man openscad" command.
openscad --imgsize=$RAW_IMAGE_WIDTH,$RAW_IMAGE_HEIGHT \ --preview \
--projection="perspective" \
--colorscheme="Tomorrow Night" \
--camera=$TRX,$TRY,$TRZ,$ROTX,$ROTY,$ROTZ,$DIST \
-D't='$T \
-D'rev_factor='$REV_FACTOR \
-D'mode="'${DETAIL_MODE}'"' \
-D'4wd_rear_diff_stl_base_dir="'${STL_BUILD_DIR}'"' \
-o "${GENERATED_IMAGE}" \
"${SCAD_INPUT_FILE}"
I have bold-faced the options that I consider to be extremely useful in the OpenSCAD command-line interface. Is anything like this feasible in cq-editor? My goal is to find some tool, not necessarily CadQuery or cq-editor, which will generate the types of outline hybrid drawings pictured above, but with the sort of fine-grained control that is offered via the OpenSCAD command-line options. I am looking for free tools that don't cost money. Thanks for your support and opinions.
I realize that CadQuery and friends are not intended to be the Swiss Army Knife for all these sorts of things, but since it already almost does something correctly, would it not make sense to have it complete it fully. Yes I know, CadQuery is not intended as a rendering tool.