Curved Shapes Workbench

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
User avatar
christi
Posts: 87
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Curved Shapes Workbench

Postby christi » Tue Jun 11, 2019 6:17 pm

Hi all,

I would like to share my new workbench "Curved Shapes".
It contains a tool to create a 3D shape from multiple curves in the XY- XZ- and/or YZ- plane.
I have created it to make it simple for me to design model aircrafts.

Image

Here is some documentation: https://github.com/chbergmann/CurvedShapesWorkbench
User avatar
christi
Posts: 87
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Curved Shapes Workbench

Postby christi » Tue Jun 11, 2019 6:21 pm

There is one open issue:
When I save a project with a CurvedArray item to a .FCstd file, I get an error <class 'TypeError'>: Object of type FeaturePython is not JSON serializable
When I load the saved project, the objects are there, but it is not possible to edit a CurvedArray item.
Any ideas how to solve this ?
User avatar
Chris_G
Posts: 1470
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Curved Shapes Workbench

Postby Chris_G » Tue Jun 11, 2019 8:07 pm

I didn't have a deep look, but it may come from here :
https://github.com/chbergmann/CurvedSha ... ray.py#L41
You are storing a pointer to the FeaturePython object.
That looks easier, but since it is not a standard python type, JSON is not able to save / restore it.
You can implement your own save / restore mechanism in setState() / getState().
But I think a better way is to transfer it to your custom Proxy methods :
All the special methods of a Proxy object (execute(), onChanged(), onBeforeChange(), onDocumentRestored()) get the FeaturePython object as first argument, so you can probably transfer this reference to your other custom methods, without having to save a reference in self.obj.
User avatar
Chris_G
Posts: 1470
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Curved Shapes Workbench

Postby Chris_G » Tue Jun 11, 2019 9:11 pm

Here :

Code: Select all

def execute(self, prop):
execute() is one of the special methods of a FeaturePython Proxy object.
It is, for example, called on document recomputes.
FreeCAD calls it with its FeaturePython parent object as first argument.
I don't think it is a good idea to override it that way.
As it is now, your FeaturePython object only reacts to Property changes, not to external recomputes ... because only your onChanged() will call it with a property name as argument.
User avatar
christi
Posts: 87
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Curved Shapes Workbench

Postby christi » Fri Jun 14, 2019 8:19 pm

Chris_G, thanks a lot. That helped me to fix it. Saving and Loading is no possible without errors.
User avatar
christi
Posts: 87
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Curved Shapes Workbench

Postby christi » Sun Jun 30, 2019 8:06 am

I have created two new tools:

Curved Segment interpolates between two 2D shapes and resizes in the bounds of hullcurves:
Image
Image

Interpolated middle interpolates a 2D shape into the middle between two 2D curves. The base shapes can be connected to a shape with a sharp corner.
Image
Image

Here is the wiki page for the workbench:
https://github.com/chbergmann/CurvedShapesWorkbench
User avatar
GlouGlou
Posts: 2518
Joined: Sun Apr 05, 2015 9:02 am
Location: La Rochelle, France

Re: Curved Shapes Workbench

Postby GlouGlou » Mon Jul 01, 2019 6:30 pm

Your workbench is not working here :roll:

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.17171 (Git)
Build type: Release
Branch: master
Hash: d19470a9711ea604f3ca6c93e46afadf64d5bb87
Python version: 3.6.8
Qt version: 5.12.1
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: French/France (fr_FR)
Attachments
Capture.JPG
Capture.JPG (11.71 KiB) Viewed 4155 times
User avatar
christi
Posts: 87
Joined: Wed Oct 24, 2018 7:03 am
Location: Karlsruhe, Germany
Contact:

Re: Curved Shapes Workbench

Postby christi » Mon Jul 01, 2019 7:32 pm

oops. invalid import. I fixed it.
GlouGlou, try again please.
TheMarkster
Posts: 2024
Joined: Thu Apr 05, 2018 1:53 am

Re: Curved Shapes Workbench

Postby TheMarkster » Thu Jul 04, 2019 4:38 am

Nice work with this.
My FreeCAD video series on youtube: https://www.youtube.com/c/mwganson
User avatar
microelly2
Posts: 4690
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Curved Shapes Workbench

Postby microelly2 » Thu Jul 04, 2019 6:12 am

thank you for sharing this.