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: 33
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: 33
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: 1014
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: 1014
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: 33
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.