FreeCAD Sverchok & Subd To Nurbs

Just unzip the linked freecad version and set the FC Path to its bin folder, the standard release of freecad Is python 36 but Blender is py37 so the addon would not import It unless we dont match the py installation version, the addon simply add the freecad bin folder to sys Path and import from It the freecad module to make nurbs conversion and export the step file…
The linked 37 build Is Just for Windows but maybe you can find something here:
https://forum.freecadweb.org/viewtopic.php?f=4&t=31994&start=40
I Hope at One point we get both blender and freecad at python38 version…

OK thanks, but at this time is an hard thing for me, compiling and make a version for FreeCAD with py37.
Anyway if you think is an useful code for this project there’s is Pascal code for conversion of subdivisions surfaces into IGES that is an included with FreeShip lazarus maybe it useful for further development and inspiring for who understand codes.
Update:
I attach a conversion with FreeShip, with edges crease and nice sharp surfaces converted into IGES.
Blender model with edge crease


FreeShip with edge crease

imported IGES into gCAD3D

and here the same file in Moi3d

3 Likes

Very interesting, I m going to study it. At moment this project it’s just a proof of concept to show that’s possibile get a nice and live workflow between Blender and freecad.

3 Likes

that is really cool work

2 Likes

what about sverchok solids to use for export to FC?

1 Like

FreeCad in Blender!!! This is treasure for me.Many thanks, people. I`m really exited now.
Huge amount of posibilities for new CAD-like tools.

2 Likes

@Rastart great exploration.
Inspired in your investigations I started to bring some FreeCad functionalities to Blender + Sverchok.
By the moment I have coded some nodes based on the Part workbench. You can see the merged Pull Request here https://github.com/nortikin/sverchok/pull/3377
As you will see in the PR Also I have opened Sverchok to handle nodes with external dependencies as FreeCAD. You can check how the implementation of any of the Solid nodes is done and use it in your own nodes (and make a pull request if you wish) :smiley:

7 Likes

Thank you for this. Constructing geometry with Constraints, from the Freecad Sketcher Workbench, would be nice to have in Sverchok. Are there any plans for that?

2 Likes

FANTASTICO!
This is incredible!
I’ll study your implementation soon as possibile and think forward to other features.

Do you mean a sv node to import a freecad sketch?

1 Like

No, I mean only to have the possibility to use constraints in Sverchok for creating (2d) geometry, like in the “Freecad Sketcher Workbench” or in “Solvespace”. I can imagine the use of “constraint-nodes” (parallel, tangent, perpendicular, concentric, coincident, equal length, angle, dimension, horizontal, vertical and so on)

3 Likes

Hello
finally I found the time for freecad R&D )))
Please help me to convert subdiv to solid
I try your script, but have a trouble

Traceback (most recent call last):
  File "/home/bm/.config/blender/2.83/scripts/addons/FC_Subd_to_Nurbs.py", line 86, in invoke
    self.execute(context)
  File "/home/bm/.config/blender/2.83/scripts/addons/FC_Subd_to_Nurbs.py", line 82, in execute
    SUBD_TO_NURBS()
  File "/home/bm/.config/blender/2.83/scripts/addons/FC_Subd_to_Nurbs.py", line 177, in SUBD_TO_NURBS
    triad = [op[0],b,op[1]]
IndexError: list index out of range

location: <unknown location>:-1

In 2.9x script just crash blender

I try sverchok nodes too


But can’t find a way to export to freecad
(exept json, but i don’t know what is it cube.json (415.6 KB) )

Please help)

Hello, at moment I am on vacation, but at return I ll be back to work on this topic, I have to study the work of vicdoval and try to integrate my freecad nodes into It.

For what I can see from your screenshots the seams are correct but It Need only 1 subdlevel on, to be more clear the “seam” patch has to be of 4 faces.

Sorry I am on the smartphone…
Basically you have to seam all the quad mesh edges, subdivide 1 step freeze and export in edit mode… It s Just a “concept” code at moment to experiment with… (Original face in green, then subdivided)

IMG_20200831_181621_448

1 Like

Hello
Glad for your reply!
Try to do this, but no luck

PATCH: 0
[<BMVert(0x7fcb0d914800), index=2>, <BMVert(0x7fcb0d9149f8), index=11>, <BMVert(0x7fcb0d914838), index=3>]
[<BMVert(0x7fcb0d914800), index=2>, <BMVert(0x7fcb0d914950), index=8>, <BMVert(0x7fcb0d914790), index=0>]
[<BMVert(0x7fcb0d914790), index=0>, <BMVert(0x7fcb0d914988), index=9>, <BMVert(0x7fcb0d9147c8), index=1>]
[<BMVert(0x7fcb0d914838), index=3>, <BMVert(0x7fcb0d9149c0), index=10>, <BMVert(0x7fcb0d9147c8), index=1>]
PATCH: 1
[<BMVert(0x7fcb0d914800), index=2>, <BMVert(0x7fcb0d9149f8), index=11>, <BMVert(0x7fcb0d914838), index=3>]
[<BMVert(0x7fcb0d914800), index=2>, <BMVert(0x7fcb0d914a30), index=12>, <BMVert(0x7fcb0d9148e0), index=6>]
[<BMVert(0x7fcb0d9148e0), index=6>, <BMVert(0x7fcb0d914aa0), index=14>, <BMVert(0x7fcb0d914918), index=7>]
[<BMVert(0x7fcb0d914838), index=3>, <BMVert(0x7fcb0d914a68), index=13>, <BMVert(0x7fcb0d914918), index=7>]
PATCH: 2
[<BMVert(0x7fcb0d914870), index=4>, <BMVert(0x7fcb0d914ad8), index=15>, <BMVert(0x7fcb0d9148e0), index=6>]
[<BMVert(0x7fcb0d914870), index=4>, <BMVert(0x7fcb0d914b48), index=17>, <BMVert(0x7fcb0d9148a8), index=5>]
[<BMVert(0x7fcb0d9148a8), index=5>, <BMVert(0x7fcb0d914b10), index=16>, <BMVert(0x7fcb0d914918), index=7>]
[<BMVert(0x7fcb0d9148e0), index=6>, <BMVert(0x7fcb0d914aa0), index=14>, <BMVert(0x7fcb0d914918), index=7>]
PATCH: 3
[<BMVert(0x7fcb0d914870), index=4>, <BMVert(0x7fcb0d914b80), index=18>, <BMVert(0x7fcb0d914790), index=0>]
[<BMVert(0x7fcb0d914870), index=4>, <BMVert(0x7fcb0d914b48), index=17>, <BMVert(0x7fcb0d9148a8), index=5>]
[<BMVert(0x7fcb0d914790), index=0>, <BMVert(0x7fcb0d914988), index=9>, <BMVert(0x7fcb0d9147c8), index=1>]
[<BMVert(0x7fcb0d9148a8), index=5>, <BMVert(0x7fcb0d914bb8), index=19>, <BMVert(0x7fcb0d9147c8), index=1>]
PATCH: 4
[<BMVert(0x7fcb0d914800), index=2>, <BMVert(0x7fcb0d914950), index=8>, <BMVert(0x7fcb0d914790), index=0>]
[<BMVert(0x7fcb0d914800), index=2>, <BMVert(0x7fcb0d914a30), index=12>, <BMVert(0x7fcb0d9148e0), index=6>]
[<BMVert(0x7fcb0d914870), index=4>, <BMVert(0x7fcb0d914b80), index=18>, <BMVert(0x7fcb0d914790), index=0>]
[<BMVert(0x7fcb0d914870), index=4>, <BMVert(0x7fcb0d914ad8), index=15>, <BMVert(0x7fcb0d9148e0), index=6>]
PATCH: 5
[<BMVert(0x7fcb0d914838), index=3>, <BMVert(0x7fcb0d914a68), index=13>, <BMVert(0x7fcb0d914918), index=7>]
[<BMVert(0x7fcb0d914838), index=3>, <BMVert(0x7fcb0d9149c0), index=10>, <BMVert(0x7fcb0d9147c8), index=1>]
[<BMVert(0x7fcb0d9148a8), index=5>, <BMVert(0x7fcb0d914b10), index=16>, <BMVert(0x7fcb0d914918), index=7>]
[<BMVert(0x7fcb0d9148a8), index=5>, <BMVert(0x7fcb0d914bb8), index=19>, <BMVert(0x7fcb0d9147c8), index=1>]
blender: /var/tmp/portage-ondisk/portage/media-gfx/freecad-9999/work/freecad-9999/src/Base/BaseClass.cpp:93: static void Base::BaseClass::initSubclass(Base::Type&, const char*, const char*, Base::Type::instantiationMethod): Assertion `toInit == Base::Type::badType()' failed.
Aborted (core dumped)

blender-2.83 and 2.9 just crash

Hope we get new SV nodes soon!)))

Happy holidays!

Hello.
@Rastart, as far as I understood, the script is doing the following:
For each subdivided patch:

  • for each outer edge of such patch:
    ** interpolate vertices on that patch edge with FreeCAD’s curve
  • call FreeCad function to build a surface from these interpolated boundary curves.

correct?

Then, as far as I see, it does not care about tangents/normals of resulting patches pointing at corresponding directions at places where patches meet? i.e. only C0 continuity is ensured (points are matching at the edges), but not C1 (tangents are not matching)?

Yes, the patches are resolved by boundary Curves, it’s a scaffold code to obtain something you can work on in a cad environment.
The idea would be to manually define the patches (in this case by edge seams) and find a way to generate proper surfaces ( maybe by freecad extension like silk or geomdl in sverchock). Like you pointed the main task Is find a method to ensure tangents between patches.
I used Power translator in modo and I d like to get something like in Blender, also the Tspline in fusion work resolving compound patches on quad mesh… A lot of 3d math to manage…

1 Like

as “pafurijaz” mentioned,
There is a Free Ship modelling tool( FreeShip lazarus) that seems to be able to handle that in a decend way…
maybe there is somthing to learn from their approche?

I just test script on Win10 - it works good
Back to test on linux

bm@GL703VM /usr/lib64/freecad/lib64 $ python
Python 3.7.9 (default, Aug 21 2020, 18:42:38) 
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import FreeCAD as F
>>> from FreeCAD import Part
>>> F.newDocument("freecad_temp")
<Document object at 0x555e9be61620>
>>> F.setActiveDocument('freecad_temp')
>>>

The real and exciting thing about your implementation of sverchok abilities during coversion is that it can help with these kinds of mesh model inconsistencies with blender to freecad

The new sketchup like ability in blender is great but it will not translate well with those ngons if not properly addressed by your sverchok enhancements. So this will be a tremendous movement foward if we could get a seamless translation there.

1 Like

Hi! Finally I started to study Vicdoval implementation.

Here the new fc_project node, features:

  • it takes a freecad project file and output the solids from it
  • it writes a mesh from blender overwriting the given name

I see that is possible to slice the solid list and make operation on it, but It would be nice to add a node to select parts by name, I have to try…
Next I’ll work on a subd to nurbs node.

3 Likes

As far as I understand, the method being used for subdiv->nurbs translation in other (commercial) software is based on the fact that Catmul-Clark subdivision algorithm is similar to de Casteljau’s algorithm for Bezier curves / surfaces evaluation; so the idea should be that instead of applying subdivision algorithm, one can calculate control points of a Bezier (or BSpline? not sure) patch for each face of initial mesh, so that points of that patch would be exactly the same as if you would apply Catmul-Clark with infinite subdivisions. The only question is how to calculate control points properly. I did not see ready-to-use algorithm for that yet, but I did not search for it either…
And I wouldn’t be surprised if such algorithms are already under patents :confused: