Disconnected objects in 0.17 Python script

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Disconnected objects in 0.17 Python script

Post by grandcross »

I'm generating a part that looks like this:
TomerMacro1.PNG
TomerMacro1.PNG (60.58 KiB) Viewed 2576 times
This is a usable object, but all the parts are disconnected. To export to an .STL I have to select all and export the result. I thought the problem was that I was building several pieces independently and then connecting them, so I reduced the macro to produce just one corner of the tower, as shown here:
TomerMacro2.PNG
TomerMacro2.PNG (18.64 KiB) Viewed 2576 times
The body tree looks like this however:
TomerMacro3.PNG
TomerMacro3.PNG (9.65 KiB) Viewed 2576 times
So, what am I doing wrong? I've looked at every example script I can find and tried many things but the results are always the same. I'm missing something pretty basic.

As I said, I can use what I have, but at this point this is a learning exercise for me.
Attachments
LES_Tower.py
(9.18 KiB) Downloaded 54 times
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Disconnected objects in 0.17 Python script

Post by grandcross »

Whoops! Forgot the system info...

OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10611 (Git)
Build type: Release
Branch: debugging
Hash: 44a9ecd25f27ec3efe52c9de9c95ef2b3e19dd17
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0

I'm currently working from a repository build that I update semi-regularly. So this has gone through a couple of software build iterations.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Disconnected objects in 0.17 Python script

Post by DeepSOIC »

Hi!
Body doesn't fuse stuff together. Moreover, Body is supposed to accept only PartDesign stuff. Use Part Fusion instead.

You may also be interested in Part-o-magic ShapeGroup, which can fuse objects.
User avatar
easyw-fc
Veteran
Posts: 3630
Joined: Thu Jul 09, 2015 9:34 am

Re: Disconnected objects in 0.17 Python script

Post by easyw-fc »

grandcross wrote:So, what am I doing wrong?
nothing... just ATM Part pf Part Design (App::Part) doesn't support to make a simple copy of the App:Part structure like in Part simple copy
here you can find a related discussion
https://forum.freecadweb.org/viewtopic. ... 98#p160304
https://forum.freecadweb.org/viewtopic. ... 20#p160416
I've done a ticket
https://www.freecadweb.org/tracker/view.php?id=2905
Still unfortunately there is no one assigned to this issue
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Disconnected objects in 0.17 Python script

Post by grandcross »

Thanks guys.

You've both missed what I'm asking for and hit it exactly :D

So, Part doesn't work with PartDesign. I was missing that bit but I don't really want to know how to force them to fit together. I can get what I want from what I have now. What I'm really looking for is how I should be doing this with PartDesign. I assume it's possible, but at this point I'm not seeing how.

Are there any good examples available of doing this with more than a simple box?
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Disconnected objects in 0.17 Python script

Post by DeepSOIC »

grandcross wrote:What I'm really looking for is how I should be doing this with PartDesign.
Then you have to create PartDesign features from script, essentially copy-parting most of the stuff that is printed to console when you create it through GUI. Which isn't very practical IMO. Why exactly do you have to do it with involving PartDesign?
User avatar
NormandC
Veteran
Posts: 18587
Joined: Sat Feb 06, 2010 9:52 pm
Location: Québec, Canada

Re: Disconnected objects in 0.17 Python script

Post by NormandC »

Honestly, it would be very hard to create this model using a pure PartDesign workflow, and not very efficient.

A PartDesign Body can only contain one single, contiguous solid. But each leg and strut is its own solid, so this would require as many separate Bodies. Then you would have to create PartDesign Booleans to fuse all the Bodies into one.

Also, considering the symmetrical nature of this model, it would make sense to use of Part Mirror and Draft Array tools.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Disconnected objects in 0.17 Python script

Post by grandcross »

DeepSOIC wrote:Why exactly do you have to do it with involving PartDesign?
I don't. At this point I have something that gives me the results I need. This is just so I know how for future projects.

In particular, for this structure knowing the locations of the end points for each of the struts involves calculations since everything is at an angle. I could do all this on paper, and transfer that to the design through the GUI, but really that is what scripting is for. I anticipate doing similar projects in the future, as well as sharing this with friends who may reuse it so I'd like it to be as clean, simple, and complete as possible.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Disconnected objects in 0.17 Python script

Post by grandcross »

NormandC wrote:Honestly, it would be very hard to create this model using a pure PartDesign workflow, and not very efficient.

A PartDesign Body can only contain one single, contiguous solid. But each leg and strut is its own solid, so this would require as many separate Bodies. Then you would have to create PartDesign Booleans to fuse all the Bodies into one.

Also, considering the symmetrical nature of this model, it would make sense to use of Part Mirror and Draft Array tools.
I'm going to have to ponder this for a little bit, but ultimately this may be the answer I was after. Thanks.
User avatar
grandcross
Posts: 350
Joined: Sun Oct 11, 2015 3:08 pm
Contact:

Re: Disconnected objects in 0.17 Python script

Post by grandcross »

As I'm thinking this through, this is more and more a serious limitation.

I can create my part using the Part methodology. But what about when I need to combine it with pieces composed using Part Design? For example, this piece will be stand alone because of its size. Ultimately it will be combined with other pieces to make a larger model. Here's an example using earlier versions as an assembly:
CM_LSM_Assembly.PNG
CM_LSM_Assembly.PNG (24.44 KiB) Viewed 2466 times
Now, in my case this works. Because of the size limitations of my printer, I have to do these as separate pieces. But what if I were making a smaller version? The lower capsule portion I'm building in Part Design because there are a lot of details I'm adding (not shown in this version). If I create my tower using the Part flow, and then try to add a piece using Part design, the two remain separate.
LES_Box.PNG
LES_Box.PNG (47.56 KiB) Viewed 2466 times
LES_Box_Tree.PNG
LES_Box_Tree.PNG (6.11 KiB) Viewed 2466 times
Trying to combine them is impossible. They are two separate and distinct entities, even though they're part of the same model.

(Before you ask, you also don't seem to be able to export using the assembly. I tried. This was the result. It's always possible I was doing something completely wrong, but...)
CM_LSM_Assembly_export.PNG
CM_LSM_Assembly_export.PNG (37.61 KiB) Viewed 2466 times
So, what is the intended workflow for this? Is there one?
Post Reply