FreeCAD Sverchok & Subd To Nurbs

Interesting initiative. Blender lacks FreeCAD’s BIM features, and FreeCAD lacks Blender’s navigation and usability.
Have you contacted Yorik on this topic? If i recall right, he once also noted the possibility of such integration.

4 Likes

Yes the combo freeCAD “tesselate” to blender “mesh_from_pydata” seems to be already designed for this “live” connection.
But before contact Yorik about this maybe I would have something more structured on blender side.
I need some help on development mainly about these topic:

1 “node_tree” programming.
2 “math” to improve subd-nurbs conversion

3 Likes

Perhaps a more descriptive introduction to what exactly are you aiming and what you have accomplished already? It is not very clear from your first post. ‘Tesselate’, ‘subd’ and ‘mesh from py data’ terms don’t mean a lot to most people here, maybe some more low-level description?
Also - are there some images in larger resolution? I can’t seem to find a way to enlarge the ones you posted, to see some details.
Otherwise a nice idea, the information that this could be possible has been around for a couple of years now.

1 Like

I wrote a better script for “node_lite” to import all freecad parts from a file into sverchok viewer,
to update just save the project in freecad and update sverchok network

"""
in dummy v
out verts v
out faces s
out objs o
"""
import bpy,sys
#INSERT YOUR FREECAD PROJECT PATH
FREECADPATH = 'C:\\....\\bin'
sys.path.append(FREECADPATH)
import FreeCAD as F

try:
    #INSERT YOUR FREECAD PROJECT FILE PATH
    F.open("C:\\....\\WRITE_TEST.FCStd")
except:
    pass

F.setActiveDocument("WRITE_TEST")
verts=[]
faces=[]

for obj in F.ActiveDocument.Objects:
    if obj.Module in ('Part','PartDesign'):    
        mesh_data=obj.Shape.tessellate(0.01)
        verts.append( mesh_data[0] )
        faces.append( mesh_data[1] )
        F.ActiveDocument.recompute()

F.closeDocument("WRITE_TEST")

6 Likes

Hi.
Yorik said me some years ago, he will be glad to manage FreeCAD API from some node system.
Maybe interaction can be provided with sverchok even.
By the way, there are Sverchok extra tools that got nurbs/splines/vectorfields basics nodes:


Please, use it if needed. Install separately and extend with addon menu (installing dependency libraries with one click).

https://github.com/portnov/sverchok-extra/issues/1 - examples here


4 Likes

I put a years of research to design a workflow to produce complex NURBS-compatible organic mesh models.
Almost all results we has got trying to convert mesh to NURBS failed.
Here are results of our tests.
https://www.turbosquid.com/3d-models/quads-t-b-model-1225310

Can you try to convert it with your method, please?
SWAN_NB_TEST_blend.zip (1.1 MB)

1 Like

I converted a piece because the entire mesh was going to bottleneck both blender and freecad, i closed the surface to convert it in a solid. How you can see the method is quite raw in fact there is no perfect continuity between the patches, maybe It has to be fixed with some operation on curve degree.
I need some help to improve the code, it’s not a easy task.

At the moment this workflow state of art is in Fusion with T-spline, I used also the power translator in modo… I think we need to have something like in Blender, because the mesh are great but in production CAD object are best suited to obtain information and generate tech drawings, also having a bridge from Blender to FreeCAD could be the door for the “production” side, at moment I use blender in 50% of my work and other I use commercial software for CAD stuff… With a boost freecad could be a real option in CAD environment

here the step from freecad:
step_test.zip (3.7 MB)

4 Likes

I don’t know if you guys are aware of this initiative, i only found out about it recently. It is a group of enthusiasts trying to bring BIM (IFC) features to Blender, perhaps some coordination could come in handy:

Also, a Blender - BIM addon, currently in development:

https://blenderbim.org/

3 Likes

Hey here the swan converted to solid nurbs the first is an IGES and the other a step file made with Moi3D the conversion was made in two different ways the IGES with my tips and tricks here https://blenderartists.org/t/from-blender-subdivision-to-n-u-r-b-s-iges-for-free

IGES only 7mb https://mega.nz/file/B8l1hBjJ#m2XmC_hYQjA_npe5lygtHZRaCN51tZOjZM9T0JzJq3w
Step Solid but huge over 170mb
https://mega.nz/file/kw8lGZ7C#8ijriNJA6CzoCK27cygcSjXumQps2L68DrbDVMXK7Mw
here the file for FreeCAD https://mega.nz/file/N0khTZRY#hcTaXVHa8bZ1a70wut03N0V4Fz9UQ_J-S7flUpZzt-8

4 Likes

For sure, NURBS have pretty much strong mathematical engine, and scripting abstraction layer have a bottleneck by definition, but it is awesome, that method is working!
I can’t imagine how you achieved such resuls with scripting, didn’t thought that it is possible, amazing work!

I heard about initiative by Zomparelli (Blender for Computational Design and Architectural design), but not sure that it is the same. Nice to see they are using OpenIFCShell, I supported it a bit.

Well, that was completely unexpected!
A very interesting method, never heard about such programs (we also never got easyweight STEP files)
Thank you for this beautiful discovery)

1 Like

I’ve got a question - is it possible to convert objects not to subdivided NURBS, but to not subdivided solid with your approach?
It could expand freeform Architectural design in FreeCAD by using Blender.

BLENDER MESH TO FREECAD SOLID
Maybe I misunderstand the question, could be something like that?
In freecad you can import a stl file and convert it in a solid, here a sverchok/freecad way to do it in live mode… the output seems a correct solid ( I tried a boolean to test it)

Sverchok setup:

SCRIPT NODE CODE TO LOAD A BLENDER MESH INTO A FREECAD PROJECT

"""
in verts v
in faces s
"""
#out verts v
#out faces s
#out objs o

import bpy,sys
##################INSERT YOUR FREECAD PROJECT PATH
FREECADPATH = 'C:\\...\\bin'
sys.path.append(FREECADPATH)
import FreeCAD as F

try:
    ################################INSERT YOUR FREECAD PROJECT FILE PATH
    F.open("C:\\...\\WRITE_TEST.FCStd")
except:
    pass

import Mesh

F.setActiveDocument("WRITE_TEST")

fc_root = F.getDocument("WRITE_TEST")
obj_names = set( [ i.Name for i in fc_root.Objects])

if not "Mesh" in obj_names:

    mesh = Mesh.Mesh()

    meshdata=[]

    faces=faces[0]
    verts=verts[0]

    for f in faces:
        v1,v2,v3 = f[0],f[1],f[2]
        meshdata.append(verts[v1])
        meshdata.append(verts[v2])
        meshdata.append(verts[v3])
        
    MeshObject = Mesh.Mesh(meshdata)
    Mesh.show(MeshObject)

    import Part
    F.getDocument("WRITE_TEST").addObject("Part::Feature","Mesh001")
    __shape__=Part.Shape()
    __shape__.makeShapeFromMesh(F.getDocument("WRITE_TEST").getObject("Mesh").Mesh.Topology,0.100000)
    F.getDocument("WRITE_TEST").getObject("Mesh001").Shape=__shape__
    F.getDocument("WRITE_TEST").getObject("Mesh001").purgeTouched()
    del __shape__
    __s__=F.ActiveDocument.Mesh001.Shape
    __s__=Part.Solid(__s__)
    __o__=F.ActiveDocument.addObject("Part::Feature","Mesh001_solid")
    __o__.Label="Mesh001 (Solid)"
    __o__.Shape=__s__
    del __s__, __o__

    F.ActiveDocument.recompute()
    F.getDocument("WRITE_TEST").save()

F.closeDocument("WRITE_TEST")


4 Likes

Yes!
Wow, so that works as an awesome bridge now, that could be useful so in architectural modeling.
Thank you for demonstration)

3 Likes

Fantastic initiative! I really look forward to seeing this progress.

I am one of the developers of the BlenderBIM Add-on, and I have contributed a bit to the BIM features on FreeCAD, we are now collaborating on more features and organising how to share code. It is indeed the same one that Zomparelli mentioned.

1 Like

MAGIC!
I tried geomdl in sverchok extra, QUADS TO NURBS!
I see there is also a NURBS to JSON, this could be useful to convert it in freecad part…

6 Likes

OMG- does this mean you can convert sub-D Mesh to nurbs-patches now? inside Blender???
Thats so exiting! Is there any way of getting the Nurbs out of Blender afterwards?
Into some standard Format like iges, step,3dm? or Freecad?
I just tried to get severock extra… got confuesed on how to get the extra libs… is this only possible on linux?
I am on windows… is there a “easy way” of getting this to work?

This is all very interesting! Sometimes there are parts I need to model, where CAD would be ideal, and not have to do standard subD or ZBrush/etc. If we had a way to send blender mesh to CAD or some sorta bridge as you guys are saying, that could be very powerful.

Little update!
I made a mock-up of a possible sverchok freecad network:


I think it’s doable and it make possible to non programmer to start use freecad in blender.

Just 8 nodes to start, then we could think about boolean operation,FEM simulation ecc

CODE QUEST:
At moment I’m studying the sverchok node programming and It would take a long time before I will able to produce the network like in the ref, if some “sverchok guru” or “real programmer” could be interested to help I would be very happy, also to just give me some hint about node coding.
Let me know, also some feedback on the system I proposed are welcome!

7 Likes

This is Golden work if this can one day work, it will become a dream come true workflow between freecad and blender. God job

3 Likes

From my experience, converting complex meshes to solid can take ages in FreeCAD. Is it faster with this script?
Does it also work on Linux?

1 Like