orbingol / NURBS-Python

Object-oriented pure Python B-Spline and NURBS library
https://onurraufbingol.com/NURBS-Python/
MIT License
623 stars 154 forks source link

CAD File import for Blender #39

Closed bunterWolf closed 5 years ago

bunterWolf commented 5 years ago

Hi orbingol,

Commercial 3D programs like Cinema 4D and Maya can import, tessellate and render CAD data. Unfortunately Blender does not have this possibility. But I believe that this will be of great importance for this software. That's why I'm trying to figure out how something could be made possible in this direction. Thereby I came across Nurbs Python.

Do you believe your Nurbs Python library could make it possible for Blender to read and tessellate CAD files in order to create high-quality renderings?

Thank you very much for your time Sebastian

orbingol commented 5 years ago

Hi @bunterWolf,

First of all, I am a real fan of Blender :) We use it in our research and also education purposes. However, I am a little bit confused of your question. First of all I think "CAD File" concept is a little bit too general. For instance; OBJ, OFF and STL file formats are already in triangular tessellated format and Blender can read them (I've tried OBJ actually and it worked but it doesn't need to be tessellated for sure). There are also .sat (3D ACIS Modeler), .x_t, .x_b (Parasolid) and file formats specific to AutoDesk products, SolidWorks, OpenCASCADE, etc. which have different pros and cons. I know that ACIS and Parasolid files contain geometry and topology structures but no triangles like OBJ files.

Secondly, there are so many research on tessellation and some of them based on Delaunay triangulation (and its variations) and its dual Voronoi diagrams. If you go deep, you will find a lot more under the field of meshing. I am not an expert on these fields but I came across a lot of papers during my PhD studies. What I know is that Cinema 4D and Maya (and others) use a geometry kernel (CAD engine) which no user has direct access but only from the GUI. The geometry kernel handles most of the magic (e.g. fitting, meshing, healing and errors) and believe me these are not that easy as they look in one simple word :)

Blender comes with rational and non-rational spline shape support by default. As far as I understand, you only need to implement some extra algorithms (or use some external libraries) and importers for your desired CAD file formats. I would be flattered if Blender wants to use NURBS-Python but since I am the only one developing it for the moment, it would be a little bit impossible for me to make it complete as Blender in a short time interval.

Additionally, I have developed a Rhino .3dm importer/exporter for NURBS-Python to overcome some of the issues that I have been facing with CAD exchange. In simple words, if you can export your format in .3dm, it is possible to import it to NURBS-Python.

bunterWolf commented 5 years ago

Thank you very much for your detailed answer. :) I expected something in this direction and I will probably accept that a mesh from a iges or step is not to get. I have to limit myself to obj, fbx and 3ds for further steps.


My thoughts only for you, if you find it interesting in general ;)

I have seen that you are working on an IGES import and there is already an OBJ export. My thought was that you could use Python Nurbs to create a mesh to render from an IGES file.

But the way you describe it... I guess I imagined it to be too easy. :)

I named it openly as a CAD file, because all the file types have advantages and disadvantages. There simply isn't the right file format.

Can Blender already: FBX: materials, Rhino and Fusion 360 but no Solidworks OBJ: materials, only Rhino STL: No good rendering quality, no materials

CAD standards: IGES: Super compatibility, old format with problem with complicated bodies. I don't believe in materials. STEP: Best compatibility, but probably the most complicated. I don't believe in materials. (If this would work, you could adjust the mesh details in Blender how you need them.)

Rhino 3ds: Already contains the mesh, Blender importer is in development Solidworks format: no idea, probably not even open Fusion 360: No idea, probably not even open

STEP or Iges would be the most flexible, but well tessellation... complicated :X

Comprehensive CAD import concept: Unreal Datasmith. But here performance and polycount are of course super important and it is very effortful implemented here. A bit over to top for the beginning :)

orbingol commented 5 years ago

@bunterWolf thank you so much for the links :) They will be good reference for me and the others.

Unfortunately, I don't think I will be able to find time for developing IGES (#31) or X3D (#24) importer/exporter for the next release of NURBS-Python. It is still possible to use external libraries for importing and exporting these formats (like I do for .3dm format); however, there are no shortcut API calls added to the code at the moment. Although importer and exporters are very important, I would like to focus on the algorithms and the visualization part for the next release.

I would be really happy if somebody else could pick these tasks and implement these importers and exporters for NURBS-Python. I don't expect a PR, that might be a little bit too complicated but an add-on module will also be good and I can also advertise these modules on the README file (just let me know about the modules).

bunterWolf commented 5 years ago

I'd like to go deeper, but I'm a designer with some programming skills. The whole mathematics is unfortunately too advanced for me... I expect that the Step topic in Blender will still exist for another 2 years, maybe something has come up by then.

Thank you very much for your time and your tips! :)

805Apollo commented 4 years ago

Hey gentlemen. I know it's been a while since you've been on this thread but I came across it in my research and am hoping you could help a beginner 3D modeling enthusiast. I'm currently teaching myself blender with interest in using it for interior design visualization. But I'm hitting a snag when importing .obj files from dimensions.com

For example, I'll download and import an .obj of a queen mattress...what shows up in the s# viewport are some unconnected vertices with no faces, and the Outliner shows a bunch of groups of ObjNurb.001, ObjNurb.002, etc. and no mesh to be found.

I've attached a screenshot of what I'm seeing. After searching the web for a few hours, I'm still unsure of what to do. If either of you could help me or at least point me in the right direction, I'd be very grateful.

Screen Shot 2020-08-22 at 4 44 40 PM
orbingol commented 4 years ago

@805Apollo thanks for your message, but this issue tracker might not be the correct place to ask Blender questions. Since you asked kindly, I'd like to suggest you a couple of good places to ask Blender questions: