Part-o-magic: Active Part/Body reinvented

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Part-o-magic: Active Part/Body reinvented

Post by DeepSOIC »

================================
THIS IS AN OLD THREAD ABOUT PART-O-MAGIC THAT SHOULD DIE. PLEASE POST TO A NEW THREAD, OR TO
https://forum.freecadweb.org/viewtopic.php?t=20698
================================

Hi!
I have mocked up a Py script of automated management of object visibility, selectability and addition with heavy interaction with active Part and active Body.
https://github.com/DeepSOIC/Part-o-magic

Install:
Install as a workbench. That is, in Path/To/FreeCAD/Mod, create a directory named Part-o-matic, and put the three .py files of the repository into there. Restart FreeCAD.

Features:
* Nested Part containers creation (from PartDesign wb)
* automatic addition of all new objects (from all workbenches) to active Part
* automatic visibility: when activating a Part/Body, all objects outside are hidden; origin of active part/body is automatically shown. To show the whole document, deactivate part/body.
* automatic selectability: objects not directly in active part are not selectable in 3d view (but not hidden automatically). This prevents accidental cross-container links. Bodies are automatically switched to Tip display mode when not active, so their final shape is selectable.

Limitations/ known bugs:
* objects sometimes appear not being added to active Part. Force recompute should deal with it.
* when document is saved and there is an active object, visibility magic will be broken a little bit on re-opening. So, before saving - deactivate all active parts! (almost fixed)
* will be confused by Groups (probably; untested)
* sketches contained in nested Parts with non-zero placements behave incorrectly when editing. (FreeCAD problem, not Part-o-magic's)

I think this can be considered a goal, or a teaser, for PartDesign/FreeCAD Next development. I would love to hear some opinions. Nonetheless, Part-o-magic can potentially be used for making actual projects!
Last edited by DeepSOIC on Wed Jan 08, 2020 4:51 pm, edited 1 time in total.
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Part-o-magic: Active Part/Body reinvented

Post by cox »

A small hiccup during install, cloned your gist into /Mod and had to rename initGui.py to InitGui.py for FreeCAD to recognize the add-on.

OS: "Arch Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7613 (Git)
Build type: Unknown
Branch: master
Hash: 4d8f338b8d1de52e0a41abbdec88b87c7e13b0c2
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1
Need help? Feel free to ask, but please read the guidelines first
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Part-o-magic: Active Part/Body reinvented

Post by cox »

This is very nice, DeepSOIC big improvement in the usability department. :D :D
DeepSOIC wrote:objects are sometimes not added to active Part. Actually, they always are, but FreeCAD doesn't update the nesting properly. Force recompute should deal with it.
I do not seem to be able to add any objetct to a part, whenever i pick additive object it gets putt in the active body, can not seem to deactivate active body.

I can also not seem to be able to nest Parts, creating a new part puts it on top of tree, and dragging a part over an existing part does show red icon for not allowed.

Having two bodies in one part, I can not manage to get visibility on both bodies at the same time.
DeepSOIC wrote:very raw. may be very buggy.
Well I think you are correct, guess it is a bit early for bug hunting season.
Give me a shout, when you want more bug reporting!

OS: "Arch Linux"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7613 (Git)
Build type: Unknown
Branch: master
Hash: 4d8f338b8d1de52e0a41abbdec88b87c7e13b0c2
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.1
Need help? Feel free to ask, but please read the guidelines first
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part-o-magic: Active Part/Body reinvented

Post by DeepSOIC »

cox wrote:A small hiccup during install, cloned your gist into /Mod and had to rename initGui.py to InitGui.py for FreeCAD to recognize the add-on.
Will fix...., thanks for reporting.
cox wrote:I do not seem to be able to add any objetct to a part, whenever i pick additive object it gets putt in the active body, can not seem to deactivate active body.I can also not seem to be able to nest Parts, creating a new part puts it on top of tree
So, probably all these problems are caused by the inability of the thing to deactivate a body. It is simply impossible, and as I said, bugfix is in pull request.
You may get some of the Part nesting to work if you don't add any PartDesign Bodies. But I advise wait for the merge (or build it :P ). For me, it works quite well as of now.
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Part-o-magic: Active Part/Body reinvented

Post by cox »

DeepSOIC wrote:But I advise wait for the merge
FYI: Looks like the travis build of your pull request has timed out an failed.
Attachments
Screenshot_20160521_120101.png
Screenshot_20160521_120101.png (10.15 KiB) Viewed 7300 times
Need help? Feel free to ask, but please read the guidelines first
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part-o-magic: Active Part/Body reinvented

Post by DeepSOIC »

cox wrote:FYI: Looks like the travis build of your pull request has timed out an failed.
I've seen it. It's second time in a row :? But it was almost there, so I guess that can be interpreted as "built fine, but not unit-tested".
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part-o-magic: Active Part/Body reinvented

Post by DeepSOIC »

Demo project!
motor test project v2.png
motor test project v2.png (226.74 KiB) Viewed 7290 times
motor test project v2_ported10665 (2).FCStd
(138.46 KiB) Downloaded 140 times
EDIT: ported project to extension era of containers

Made with almost pure PartDesign. There are a few stand-alone sketches, and one Draft Clone. I had to use Py console once, to get ShapeBinder005 outside of body.
Uses almost no expressions (there is only one). All alignment done using geometry links to shapebinders of master sketches. This is my typical workflow (use of master sketches), that now comes to a whole new level.

Made with:
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7633 (Git)
Build type: Debug
Branch: NewBodyFixes + Part-o-magic rev.7 installed
Hash: 739509aadc5f155bcc3c44bc9b324929c6163e35
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.1

Some things I noted during making of this demo project:
1. It'd be nice to be able to place shapebinders outside of bodies.
2. Datum planes often end up having zero size (makes them look like a line). That is annoying.
3. In Sketcher, if I add a symmetry constraint, all other constraint symbols become invisible. I don't think it is related to nested Parts, I'll try to reproduce it in a simple test project.
4. I really really missed the Boolean Common operation in some bodies (core of the rotor is a good example). That makes me want to experiment with adding Part objects to bodies.
Last edited by DeepSOIC on Wed Nov 29, 2017 6:20 pm, edited 1 time in total.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part-o-magic: Active Part/Body reinvented

Post by DeepSOIC »

Exploded view. Made by simply editing placements of some parts and bodies.
motor test project v2 exploded.png
motor test project v2 exploded.png (91.64 KiB) Viewed 7284 times
Note. This GREATLY benefits from what is currently considered a fundamental bug: placements of containers are not considered in geometry links. Maybe it should be left as-is??
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Part-o-magic: Active Part/Body reinvented

Post by DeepSOIC »

DeepSOIC wrote:4. I really really missed the Boolean Common operation in some bodies (core of the rotor is a good example). That makes me want to experiment with adding Part objects to bodies.
Did experiments on adding Part stuff to bodies. I can force the body to parent a Part feature, but the problem is that Body fails to recompute if I set its Tip to point to a Part feature. And that makes it pointless to use Body, because without Tip and display mode support, Body is no better than Part.

Hacking it is probably a matter of changing a few lines of C++ code, but that will lock me in to my own branch again.. So I don't know...
EDIT: I'm hacking it as an experiment. But I think I will bother making a Part::BodyBase functional instead and add a command for it in Part workbench.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Part-o-magic: Active Part/Body reinvented

Post by triplus »

Sounds interesting. As i don't yet use development release i will test the module at some point in the future.
Post Reply