Surface::Filling API?

Need help, or want to share a macro? Post here!
User avatar
Chris_G
Posts: 1204
Joined: Tue Dec 31, 2013 4:10 pm
Location: France
Contact:

Re: Surface::Filling API?

Postby Chris_G » Tue Oct 16, 2018 8:10 pm

tomkcook wrote:
Tue Oct 16, 2018 6:52 pm
Right. I'm really sorry if I'm asking a very stupid, newbie question: If I've created those edges with

Part.makeCompound([x.toShape() for x in a_list_of_BSplineCurves])

, what are the names and where do I find them out?
I think you can do something like this (not tested):

Code: Select all

com = Part.makeCompound([x.toShape() for x in a_list_of_BSplineCurves])
com_obj = ActiveDocument.addObject('Part::Feature', 'boundary_edges')
com_obj.Shape = com
FreeCAD.ActiveDocument.recompute()
edge_names  = ["Edge%d"%(n+1) for n in range(len(com.Edges))]
filling_object.BoundaryEdges = (com_obj, edge_names)
tomkcook
Posts: 54
Joined: Wed Jul 20, 2016 3:39 pm

Re: Surface::Filling API?

Postby tomkcook » Fri Jun 14, 2019 5:04 pm

This worked. Thank you.

Has there been any update on this since October? Any progress on a `Surface::Filling` API?

If not, what's involved in creating one? Can you point me towards an example? Or some documentation? I'm a reasonably competent C, C++ & Python programmer and I'm already building FreeCAD from source, but have very little background in the FreeCAD source code.
User avatar
wandererfan
Posts: 3483
Joined: Tue Nov 06, 2012 5:42 pm

Re: Surface::Filling API?

Postby wandererfan » Sat Jun 15, 2019 12:55 pm

tomkcook wrote:
Fri Jun 14, 2019 5:04 pm
If not, what's involved in creating one? Can you point me towards an example? Or some documentation? I'm a reasonably competent C, C++ & Python programmer and I'm already building FreeCAD from source, but have very little background in the FreeCAD source code.
This sounds like it would fit in .../Mod/Part/App/AppPartPy.cpp or maybe in one of the TopoShape related xxxxxPyImp.cpp files.

The basic structure of a program to expose functionality to Python is something like this:

- get the Py object parameters and convert them to c++ variables using PyArg_ParseTuple(),
- use various c++ routines from OpenCascade and/or FreeCAD to produce the desired result,
- convert the c++ result into Py object using routines like PyLong_AsLong(), Py::asObject(), etc,
- return the Py object.

Most of the c++ modules have an AppModulePy.cpp that you can borrow code from.

wf
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: Surface::Filling API?

Postby Kunda1 » Sat Jun 15, 2019 6:42 pm

wandererfan wrote:
Sat Jun 15, 2019 12:55 pm
The basic structure of a program to expose functionality to Python is something like this:

- get the Py object parameters and convert them to c++ variables using PyArg_ParseTuple(),
- use various c++ routines from OpenCascade and/or FreeCAD to produce the desired result,
- convert the c++ result into Py object using routines like PyLong_AsLong(), Py::asObject(), etc,
- return the Py object.

Most of the c++ modules have an AppModulePy.cpp that you can borrow code from.
Is this mentioned in the wiki anywhere ? If so, where? If not then where should it be?
#documentation
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
wandererfan
Posts: 3483
Joined: Tue Nov 06, 2012 5:42 pm

Re: Surface::Filling API?

Postby wandererfan » Sun Jun 16, 2019 2:54 pm

Kunda1 wrote:
Sat Jun 15, 2019 6:42 pm
Is this mentioned in the wiki anywhere ? If so, where? If not then where should it be?
#documentation
[/quote]

No idea. I happened to be working on exposing some c++ functions to Python when I read the OP.

Maybe it should go here? The_FreeCAD_source_code. More likely it should be in a child of that page.
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: Surface::Filling API?

Postby Kunda1 » Sun Jun 16, 2019 7:07 pm

Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
wandererfan
Posts: 3483
Joined: Tue Nov 06, 2012 5:42 pm

Re: Surface::Filling API?

Postby wandererfan » Wed Jun 19, 2019 1:25 pm

Kunda1 wrote:
Sun Jun 16, 2019 7:07 pm
Started a stub at https://www.freecadweb.org/wiki/Exposin ... _to_Python
Expanded the stub a bit, but didn't do any fancy formatting.
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: Surface::Filling API?

Postby Kunda1 » Wed Jun 19, 2019 1:56 pm

wandererfan wrote:
Wed Jun 19, 2019 1:25 pm
Expanded the stub a bit, but didn't do any fancy formatting.
:+1: ;)
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
Kunda1
Posts: 6440
Joined: Thu Jan 05, 2017 9:03 pm

Re: Surface::Filling API?

Postby Kunda1 » Wed Jun 19, 2019 2:13 pm

wandererfan wrote:
Wed Jun 19, 2019 1:25 pm
Expanded the stub a bit, but didn't do any fancy formatting.
Added fancy formatting 8-)
https://www.freecadweb.org/wiki/Exposin ... _to_Python
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
tomkcook
Posts: 54
Joined: Wed Jul 20, 2016 3:39 pm

Re: Surface::Filling API?

Postby tomkcook » Thu Jun 27, 2019 12:35 pm

wandererfan wrote:
Sat Jun 15, 2019 12:55 pm
tomkcook wrote:
Fri Jun 14, 2019 5:04 pm
If not, what's involved in creating one? Can you point me towards an example? Or some documentation? I'm a reasonably competent C, C++ & Python programmer and I'm already building FreeCAD from source, but have very little background in the FreeCAD source code.
This sounds like it would fit in .../Mod/Part/App/AppPartPy.cpp or maybe in one of the TopoShape related xxxxxPyImp.cpp files.
I've written a C++ function that essentially exposes `BRepFill_Filling`, creating a surface from a bunch of boundary and constraint curves. It's pretty noddy and only really does what I want, while a more complete implementation would add some other options. The only real advantage it has over `Surface::Filling` is that it doesn't require the curves to be part of another document object before they're used to create the surface, simplifying code that uses it fairly considerably.

Would you be interested in a pull request with this in?