Automatically create body?

About the development of the Part Design module/workbench. PLEASE DO NOT POST HELP REQUESTS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Automatically create body?

Post by ian.rees »

OK, only had a couple brief periods to look at this today, but think I've got it mostly sorted.

One more question though: I need to get a chunk of code to run if the PartDesignGui::TaskDlgFeaturePick() at the end of CmdPartDesignNewSketch::activated() is cancelled, to delete the Body that was created. Can't see an easy way to do that within the current framework, is there something I'm missing? -Ian-
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Automatically create body?

Post by ian.rees »

OK, does the current PR https://github.com/FreeCAD/FreeCAD/pull/667 look alright?

There is some weirdness with Redo, at least on my machine (Qt5.6, OSX) - the axes and planes end up outside the Body, but that happens on master too. Otherwise it seems well behaved so far. -Ian-
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Automatically create body?

Post by DeepSOIC »

I scrolled through the changes, looks good to me.
A small hint. Parts and Bodies have a method "newObject" that combines creation and addition into one operation. But the major transplantation of all calls to App.ActiveDocument.addObject within whole freecad can be expected in not too distant future anyway.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Automatically create body?

Post by wmayer »

ian.rees wrote:There is some weirdness with Redo, at least on my machine (Qt5.6, OSX) - the axes and planes end up outside the Body, but that happens on master too. Otherwise it seems well behaved so far. -Ian-
Create Body > Undo > Redo then then the items are outside. Once you expand the body and origin the items jump back to the correct parent. I can confirm this on Linux and Windows and it might be caused by the modifications for the tree view.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Automatically create body?

Post by DeepSOIC »

wmayer wrote:Create Body > Undo > Redo then then the items are outside. Once you expand the body and origin the items jump back to the correct parent. I can confirm this on Linux and Windows and it might be caused by the modifications for the tree view.
I also observe it in: OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.9933 (Git)
Build type: Release
Branch: master
Hash: 6c3b78e97bbb8653e1189038c99682becef71626
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0

EDIT: but recovering correct layout is much harder

I also experienced similar problem in early days of part-o-magic, when I added stuff to containers from slotCreateObject(). So I would guess it has something to do with lacking viewproviders or something...
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Automatically create body?

Post by wmayer »

Found an interesting bug:
1. New document
2. New sketch
3. Undo
4. Select an item and press OK

The OK & Cancel button disappears but the panel is still there. There is no way to get rid of the panel you must quit FreeCAD.

But this bug was already there and hasn't been introduced by this PR.
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Automatically create body?

Post by ian.rees »

DeepSOIC wrote:I scrolled through the changes, looks good to me.
A small hint. Parts and Bodies have a method "newObject" that combines creation and addition into one operation. But the major transplantation of all calls to App.ActiveDocument.addObject within whole freecad can be expected in not too distant future anyway.
Ahh, thanks for that! Will keep that in mind for next time around. -Ian-
ian.rees
Posts: 696
Joined: Sun Jun 15, 2014 3:28 am
Contact:

Re: Automatically create body?

Post by ian.rees »

wmayer wrote:Found an interesting bug:
1. New document
2. New sketch
3. Undo
4. Select an item and press OK

The OK & Cancel button disappears but the panel is still there. There is no way to get rid of the panel you must quit FreeCAD.

But this bug was already there and hasn't been introduced by this PR.
Interesting. I can try to look at that this evening if you haven't already found a fix.
wmayer
Founder
Posts: 20319
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Automatically create body?

Post by wmayer »

ian.rees wrote:
wmayer wrote:Found an interesting bug:
1. New document
2. New sketch
3. Undo
4. Select an item and press OK

The OK & Cancel button disappears but the panel is still there. There is no way to get rid of the panel you must quit FreeCAD.

But this bug was already there and hasn't been introduced by this PR.
Interesting. I can try to look at that this evening if you haven't already found a fix.
Here is a fix git commit bf54226. The TaskFeaturePick class now also inherits from DocumentObserver and reimplements two methods to close itself on undo when needed.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Automatically create body?

Post by triplus »

Tested the behaviour and without the pop-up the experience is much better.
Post Reply