Hello devs and users,
I want to share with you something specific that I made for my graduation and which may be useful to someone.
So what to begin with… 9 or so months ago and I was pretty sure that FreeCAD is more than enough for me to complete my mechatronics engineering project, fulfilling my goal to graduate using entirely OSS tools. I may have been way too optimistic, because about month and a half later, after all the drawing and calculations were done, I realized that the TechDraw module is not suited for complicated drawings, and most importantly, lacks any support for multibody assemblies and parametric model changes.
Needless to say, that was a catastrophe. With only a month or so left until my graduation and no sane way to get the drawings out of FreeCAD, I started to panic. (Actualy no sane way to do it in any other software, except to start from the ground up. FreeCAD appears to be working with the BREP blazingly fast, even compared to commercial software and my models were already overcomplicated.)
…
So after a painful recap, I had a new goal - to postopne my graduation and code something into FreeCAD so I can get my drawings done solely with OSS tools.
After an extensive forum research, I came to the conclusion that there is some great advance in terms of architectural drawings and single-body drawings (and I made use of the latter), but almost zero is done about multi-body mechanical drawings, assemblies and such.
And because of my huge previous SolidWorks experience and influence, I wanted to have some very specific features while able to sacrifice some other for the “next stages”.
I made a quick list of required tools in the early summer days, wrote it on a sticky note and stuck it to my laptop until everything was mostly done. Ended up using a set of python scripts and macros.
This is what I have implemented as absolutely needed for the toolset:
First of all, I find the TechDraw workflow kinda backwards - the 2D lines (which are absolutely correct!) are generated immediately after you create a drawing, voiding any useful 3D or parametric information, and only after that you can annotate the different parts. The huge flaw I see here is that you have to wait for ages until the whole geometry is flattened, but you end up using only a small part of it and if you have to change the geometry later, you’re back to zero. This is a tedious task for a single body, but for multiple bodies, fasteners and all their relations, it’s pure masochism.
My approach, parallel to what SolidWorks does, was to create the whole drawing in the CSG stage with relations to the CSG models and then export the 2D drawing with all the annotations, effectively splitting the implementation in two - The visual parametric representation and the code that generates the final drawing. So any model changes are recalculated immediately on the drawing, leaving the hours of waiting for the final export for the very end.
Secondly, I wanted to have a 3D lookaround of the drawing, exactly like in SolidWorks, because there are always some very hard to pick lines and dimensioning them is hell without a proper selection.
I sticked to the 3D Inventor View for that part, keeping the whole drawing plane coincident to the X-Y 3D plane. And because the whole drawing is volumetric, selection and orientation are really easy. Ultimately, there should be some core change where the rotation would be normally locked, but now that’s up to the user.
Thirdly, TechDraw treats the drawings inherently as a single body simply because when you section them, there is only one kind of hatch for the whole section, I guess due to lack of functionality. Truly a no-go for the mechanical engineer.
My approach here was to associate a different hatch with every unique solid, that’s able to survive a recomputation or a major change of the assembly. And I ‘mostly’ succeeded, at least not worse than SolidWorks I think.
Fourth, something that was bugging me, was that acording to the ISO drafting standards, all annotations should read from the bottom and right part of the page, but in FreeCAD the labels are oriented mostly at random.
While implementing the (very) basic dimensioning, took that into account.
Fifth, again according to basic drafting standards, some solids such as fasteners, balls, non-hollow shafts etc. should not be cut in a section view, that is, to serve as a visual clue of what is being looked at and to prevent drawing clutter.
I was able to implement a very sane selective exclusion mechanism, again based on solid uniqueness, so not everything is cut and hatched.
SIxth, I wanted everything to be as interactive and parametric as possible, meaning achievable solely through the user interface and dynamically recomputed when there are CSG changes back in the tree.
Seventh, When exporting the drawing (and probably during creation through another core change), there should be different line thicknessess, according to their different purpose, or at least things should be further editable.
Currently, all annotations can be exported with custom line thicknesses, independent of body line thickness.
Lastly, I was so pressed for time that I avoided any code which requires compilation, effectively implementing the whole toolset in python, though I would like to change that for its many limitations.
Still there are tons of functionality left, that I managed to fix with inkscape for the real project, but should be straitforward to add from now on.
To name just a few things missing:
[] partial sections
[] balloon annotations [1]
[] automatic thread symbols, centermarks and centerlines, based on underlying 3D structure
[] solid groups in the BOM
[] zoomed-in sections
[] toggling between a complete section and a section-plane only.
[*] dimension lines lying on top of the geometry, instead on the X-Y plane.
At the end, I want to point out some really buggy things that I encountered, which were huge stoppers.
The biggest FreeCAD pitfall to date, considering future multibody development, for me, is that there are no solid names/numbers/hashes. I know that’s part of the Open Cascade engine, but I presume that solid names were simply omitted in FreeCAD. So there’s a general lack of a mechanism to identify different compounded solids down the tree. I am using hashes based on faces for that purpose, but that’s a no-go.
[1] Another peculiarity, the initial idea was (and still is) to export the 2-D annotations as faces (svg with solid fill color and so), that is, the letters and numbers should not be converted to wires. But for almost half of the alphabet and even more (letters B, Ф, $, e to name a few, I think of them as “interlooped” letters), the built-in FreeCAD exporter dies horribly with an “Edges not ordered” error and refuses to export faces. Alternatively, in FreeCAD 0.20 this is mostly fixed at the expense of tremendous overhead, taking 2-3 hours to export 1000-2000 simple faces.
The last problem reflects in the way the whole SVG export is done, there should be some implementational flaw (use of std::vector somewhere/everywhere ?!?) because with increasing geometry complexity, the export time increases almost exponentially!
I also wanna mention again my previous thread https://devtalk.freecad.org/t/3d-view-edges-drawn-through-faces/63379/1 because this core issue really affects the drawing’s appearance.
And now for a simple demonstration.
A showcase of the creation of a multibody drawing. Credit for the model goes to Nelson Stoldt @ GrabCAD, I downloaded a random 3D model from the Internet for the purpose of the demonstration.
https://www.dailymotion.com/video/k6A2dyyBsPrc4JyQgtG
And this is my final assembly drawing, part of my thesis (defended in october), and made entirely using Python, FreeCAD and inkscape: ^^
https://pdfhost.io/v/U3Iyb~Rf8_Drawing_flat_anno_2
If you’re interested in what I’ve done, I’ll gladly share the set of scripts that make it possible. If not… wel, somebody please delete this wall of text. ![]()
In a perfect world, I see this workflow merged into the TechDraw workbench, which already has a huge and well-working drafting toolset.
Writing this as a truly OSS engineer ![]()
Edit 0: The raw source
scripts_alpha.zip