A new Part tool is being born... JoinFeatures! [in master!]

Need help, or want to share a macro? Post here!
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

A new Part tool is being born... JoinFeatures! [in master!]

Postby DeepSOIC » Tue May 26, 2015 9:46 pm

Hi!
I got tired juggling booleans in some common situation, so I've come up with a little scripted object that should help.
Now, I'm only posting a teaser picture, as the tool is just too raw to be published :oops:

Given two intersecting pipes as input, it produces this: (sliced to reveal internals afterwards)
embed-tool-demo.png
embed-tool-demo.png (62.7 KiB) Viewed 2444 times
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: A new Part tool is being born...

Postby DeepSOIC » Wed May 27, 2015 2:38 pm

Another teaser...
JoinFeatures_teaser2_annot.png
JoinFeatures_teaser2_annot.png (41.66 KiB) Viewed 2398 times
The tool morphed into three tools:
* connect
* embed
* cutout
The tools seem to be extremely useful for modeling pipework, but they might come in handy in other situations.
Comprehensive description is a todo...

Alpha version of the tools:
JoinFeatures.zip
(3.82 KiB) Downloaded 81 times
Extract this into \Mod\Part, replacing InitGui.py in the process.
Then, add a new toolbar in Part wb, adding the three new commands from Python list of commands.

The tools lack icons (PartDesign Gear icon is used for now).
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: A new Part tool is being born... JoinFeatures!

Postby DeepSOIC » Sat May 30, 2015 10:59 pm

I just found some time to put together a little explanation of the tools.
Here it goes.

The tools I made are, as I named them: Connect, Embed and Cutout. The purpose of the tools is shown on the picture:
JoinFeatures.png
JoinFeatures.png (61.56 KiB) Viewed 2329 times
All the features are parametric.

I always show pipes, because it is what the tools were designed for, but they may be used for other stuff. So, here is an explanation of how Embed works.

Embed
Embed-process.png
Embed-process.png (80.56 KiB) Viewed 2329 times
The most interesting stage is 2. A compound, created by cutting, is filtered: the piece that has the highest volume is kept, all the small pieces are thrown away.

Cutout is stages 1 and 2 of Embed.

Connect is a symmetric variant of Embed, and it is quite a bit more complex:
1. Cutout Object1 with Object2
2. Cutout Object2 with Object1
3. Fuse results of 1, 2, and Common (intersection) of Object1 and Object2
Connect is quite ridiculously slow, because of 5 Boolean operations are done in a row. I think, it can be made as fast as one Boolean operation, but that requires close interaction with OCC, probably doable only with C++ (now, the tools are in Python).

I want to ask you, if it is worth preparing the tools to be merged into main FreeCAD, or if I should package them into a macro. What do you think?
abdullah
Posts: 3253
Joined: Sun May 04, 2014 3:16 pm

Re: A new Part tool is being born... JoinFeatures!

Postby abdullah » Sun May 31, 2015 8:05 am

It looks very nice!! Hope to see it in master soon...

Answering your question, for me this is master material.
danielfalck
Posts: 395
Joined: Fri Oct 07, 2011 8:58 pm
Location: Beaverton,Oregon, USA
Contact:

Re: A new Part tool is being born... JoinFeatures!

Postby danielfalck » Sun May 31, 2015 1:41 pm

Great feature. I would like to see this tool merged into master too.
User avatar
bejant
Posts: 6061
Joined: Thu Jul 11, 2013 3:06 pm

Re: A new Part tool is being born... JoinFeatures!

Postby bejant » Sun May 31, 2015 6:08 pm

DeepSOIC wrote:I want to ask you, if it is worth preparing the tools to be merged into main FreeCAD, or if I should package them into a macro. What do you think?
Something else to consider is that if it is a macro, it is probably not maintained unless you maintain it. And so I'd like to see it in master as well!
ickby
Posts: 2940
Joined: Wed Oct 05, 2011 7:36 am

Re: A new Part tool is being born... JoinFeatures!

Postby ickby » Sun May 31, 2015 6:12 pm

Probably best to make one tool out of it with the join type as option. It is a rather specific tool and hence having 3 icons in the toolbar seems too much.
User avatar
PrzemoF
Posts: 2753
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: A new Part tool is being born... JoinFeatures!

Postby PrzemoF » Sun May 31, 2015 6:53 pm

Looks impressive! I can't wait to test it!

P.S. How did you make that cross section?
User avatar
DeepSOIC
Posts: 7479
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: A new Part tool is being born... JoinFeatures!

Postby DeepSOIC » Sun May 31, 2015 7:47 pm

Wow, thanks guys! I'll prepare it in the meantime.
ickby wrote:Probably best to make one tool out of it with the join type as option. It is a rather specific tool and hence having 3 icons in the toolbar seems too much.
I am in doubt on this. The tools share the code, essentially, but I have no idea, how to make a collective icon. While making icons for specific cases is quite easy. I think a dropdown tool (like polygons in Sketcher) is a good idea.
PrzemoF wrote:P.S. How did you make that cross section?
There are quite a number of sections in this thread already :lol:
Considering you are talking of the very first one, it is an overlay of a cut-in-half object and the uncut object, where the uncut object was made transparent. I'm afraid I didn't save the file.
Others are either simply cut in half with a big box, or they are incomplete (180-degree) revolutions
User avatar
PrzemoF
Posts: 2753
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: A new Part tool is being born... JoinFeatures!

Postby PrzemoF » Sun May 31, 2015 7:58 pm

DeepSOIC wrote:
PrzemoF wrote:P.S. How did you make that cross section?
There are quite a number of sections in this thread already :lol:
Considering you are talking of the very first one, it is an overlay of a cut-in-half object and the uncut object, where the uncut object was made transparent. I'm afraid I didn't save the file.
Others are either simply cut in half with a big box, or they are incomplete (180-degree) revolutions
OK, thanks! I thought that there is a cross section tool that I don't know.