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!
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

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

Post by ickby »

Hello DeepSOIC,

looks very good. I still need to add that I highly recommend not to use the Part objeckt hacking that much, this will definitely change in functionality and code wise in the future. It is just too early to build user stuff out of this.
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 »

ickby wrote:looks very good.
Thanks!
ickby wrote:It is just too early to build user stuff out of this.
I'm about to start doing it. The pull request I mentioned was born exactly because I want to start using the new FreeCAD, and the fixes are essentially the show-stopper bugs for me (well, the sketcher one, and container deactivation).

While making this, I essentially made an API prototype for container traversal, you might want to take a look.
https://github.com/DeepSOIC/Part-o-magi ... phTools.py

Also, a few opinions were born.
1) there should be only one active container, not two as it is now (now we have two separate fields, active Part and active Body). Having two only adds complications when nesting is considered. I have essentially replaced the two with one in Part-o-magic, see getActiveContainer and setActiveContainer routines.
2) I think we need the active container in a more accessible place, like ActiveDocument.
3) Containers should provide an overload of addObject(type, name), that should act just like Document.addObject(), except throw an error if the object cannot be created in the container (say, we can't create a Part Feature in PartDesign Body). Then do a massive search-and-replace around FreeCAD to redirect to ActiveContainer.
... more to come
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

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

Post by ickby »

Next.week i have some more time to get into this again and have a look at your code. i like and appreciate your efforts, i am only a bit nervous that we rush into something that falls apart when thinking longer about it like last time. Back then we put much work into it only to throw it all away. I think we should also study jriegels code to see what he was up to with his changes to the documenta object handling.

The first priority is to unify the container code between part body and whatever wants to be a container, see the thread about coordinate system handling. I started this and have a good idea in howto achieve that.
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 »

ickby wrote:see the thread about coordinate system handling.
This one? viewtopic.php?f=20&t=10878
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

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

Post by ickby »

DeepSOIC wrote:
ickby wrote:see the thread about coordinate system handling.
This one? viewtopic.php?f=20&t=10878
No this one viewtopic.php?f=10&t=15490
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 »

No this one viewtopic.php?f=10&t=15490
Post composed before noticing this reply, but here it is anyway :P

In that thread, I noticed jriegel wrote:
jriegel wrote:... If you look for the consolidated world/document position you have to find the path in the graph to the top of the document and multiply all placements. Since we talk about graphs, it can have several solution (used more then once). ...
So, this means, the situation where two containers have one feature at once is allowed. Which is very very confusing to me.

My graph tools, which I used in Part-o-magic, assume that multiple belonging is not allowed. That is, container ownership of objects forms a tree, not graph.

If we are going for a graph:
* it is impossible to determine the container chain given just the object.
* given just two objects, it is generally impossible to figure out their relative placements.
This means to me that links should be extended in this case to include the "full path" to the object. In a very similar manner to file system. Then we can also have relative paths. And then direct links can only be resolved if both objects are within the same container...

As for Part-o-magic:
* it's an experiment. I expect it to be thrown away.
* It allows to conveniently create a container tree, which is also a valid graph.
* It's merely a GUI tool. It can be thrown away at any moment without any impact on projects created with it.
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 »

ickby wrote:
DeepSOIC wrote:This one? viewtopic.php?f=20&t=10878
No this one viewtopic.php?f=10&t=15490
Am I right to assume that if I keep placements of Parts and Bodies zero, I should be all right?
blacey
Posts: 370
Joined: Tue Dec 08, 2015 11:28 pm

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

Post by blacey »

DeepSOIC wrote:Demo project!
motor test project v2.pngmotor test project v2.FCStd

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.
@DeepSOIC, love the part-o-metic experience improvements for navigating a compound-part model like yours. Thanks for taking the time to provide a demo model that clearly demonstrates the value of part-o-matic.

That said, I'm by no means a FreeCAD expert, or CAD expert for that matter, but I spent some time delving into @DeepSOIC's demo model and it seems to exude a nice blend FreeCAD gestalt/prowess/savviness and modeling best-practices. Would it make sense to turn this into a tutorial? Maybe it could serve as a basis for "the 0.17" show-case/demo/tutorial. Just a thought of what else can be done to foster FreeCAD community growth/advancement.

Code: Select all

OS: Mac OS X
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.7633 (Git)
Build type: Release
Branch: (detached from 739509a)
Hash: 739509aadc5f155bcc3c44bc9b324929c6163e35
Python version: 2.7.11
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.8.0.oce-0.17
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

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

Post by ickby »

The graph/reusing comes from the fact that in assemblies you have a single art at multiple places, e.g. one wheel model used four times in a car. If I remember correctly many file formats also use this structure of reusing one model at multiple places for assemblies, Step and Jt for example. This is why in the end we need to support this, and it definitely is highly valuable (of course also complicated)

JRiegel implemented this already, don't know how good it works up to now: https://github.com/jriegel/FreeCAD/commits/dev-occ-jt
This branch also contains a Jt reader for testing it. We should not omit this but base the Part/Body structure on this.
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 »

blacey wrote:it seems to exude a nice blend FreeCAD gestalt/prowess/savviness and modeling best-practices. Would it make sense to turn this into a tutorial?
Actually I've been wanting to make a tutorial on how to work around the weakness of links (lack of topo naming) with help of new features of PartDesign Next. However, the resurrection of topo naming development efforts makes me less motivated to write the tutorial.

And since PartDesign, and all that container stuff may be massively changed soon, it feels a bit pointless to write a tutorial that may suddenly become obsolete. But I'll think about it :roll:
Post Reply