It’s not often that I create a topic in the “Dev” category 🙂
Well, at work, I’m facing a series of issues while working with 3D files coming from CAD softwares.
Actually, the client sent me a .max file, which I had exported to .fbx to be able to work with it in Blender. The data was already pretty dirty in the max files, that’s how I guessed it comes from a CAD software: it doesn’t look like human-made modeling 😀
The problems are numerous: loads of very dirty/split meshes, unwanted data, f*cked up normals, etc.
Instead of cleaning the 2887 (!) objects one by one, I started making a series of python scripts, which I plan to pack in a user-friendly addon, as it will probably come useful for someone else!
I chose to name it CleanMyCAD for now.
so far, I have automation/batch treatment for:
- selecting MESH data only in the scene
- removing double verts
- tri-to-quads mesh “cleaning-ish”
- remove “custom split normals data”
- set a “normals auto smooth angle”
- origin to geometry (well that was an easy one haha)
Which features would you find useful in such an addon?
Who’s up to help me pack this collection of snippets into a user-friendly addon with an UI?
Also, right now, each scripts takes up to 10 minutes to complete, but that’s maybe because of the high number of objects. Anyway, I scripted using only blender python commands (the ones you get when hovering a button), so if anybody’s up to optimise the stuff, I’ll be paying for the beers!
I’ve no clue of what can be useful in a script to clean meshes from CAD softwares, but you can count on me to help you packing it into the UI of a Blender addon if you need it.
I deal with similar problems sometimes.
I often work with 2D drawings from autocad (which I import as DXF) and 3D models of various types in different formats.
The problems the imported objects have seem to differ depending on the origin (CAD program and file format). A few more operations could be:
– Scale all objects with a given factor (CAD models often use mm as unit)
– Remove materials from objects (often each object has a different material)
Blender can handle a large number of vertices, but it has a problem with large number of objects. Some import add-ons have an option to “merge all”. This speeds up things significantly.
I haven’t worked too much with blender add-ons, but I have made a few python scripts to do tedious batch operations, and I have started to clean them up lately and add them to the UI.
Let me know if I can help. I would also be interested in improving my skills on python programming in blender.
@vincentg : Yay, thanks, that would be awesome!
@dans : Thanks for the ideas! I’ll add them to my TODO list 🙂 (regarding the materials, I was actually impressed that I only had a few and well-assigned, when imported the .fbx . I was expecting a whole mess, like when you import SVG graphics and each object has its own material…)
When you talk about python scripts, are they related to what I’m trying to do? If so, I’d love to have a look.
I’ll share my snippets here as well, as soon as I’ve rounded them up.
I often receive fool meshes from engineering CAD softwares as ProE or Solidworks and such an addon could simplify this task a lot.
Actually, as exporting in .STL causes too much vertex to weld, I do prefer exporting any kind of CAD in .STEP (which is quite a standard format for CAD softwares).
After that It can be open in FreeCad, and re-exported in .dae.
Once .dae imported in Blender, I always (must be honnest, nearly always) obtain clean and integer meshes. Sometimes with weird normals, but it’s quite easy to repair.
Your list of actions to perform seems complete. DanS is right about units. In my case (industry devices) it’s always mm in CADs. It shoud be usefull to adapt automatically Scene scale factor of blender to match “real” units.
About vertices and objects, would it be possible to detect “X” degrees of hierarchy to split into objects, and to merge everything above?
Anyway, thanks for the time spent, I just can’t wait to use it!
Sorry for the late reply.. Initially, I’m just planning to clean up some scripts, add a GUI and put it all in one add-on. In that way I just copy my add-on every time I update blender and I won’t have to search through my old blend files to find the scripts.
Some functions might match what you are working on, but In general my scripts are more about handling complex scenes and possibly auto-generating some objects. My models often consist of hundreds of objects which would be a mix of meshes and group instances. My tasks would be more like:
– Check if all objects have a material (select objects without material)
– Batch replace materials
– Check for unused objects / groups
– Check if scale has been applied to all objects (to avoid stretched materials)
I have attached a simple script that removes duplicate materials. When appending objects from other files I often end up with multiple copies of the same materials (e.g. “steel”, “steel.001”, “steel.002” and so on). This scripts will replace all materials that end with “.nnn” with the material that has the same name without the number (if it exists).
I have attached two files. In the first one, this function is registered as an operator. This means that when you press space in the 3D view and type “Remove Duplicate Materials” the operator shows up.
In the second file, I have added code for the GUI. In the 3D-view tool-bar there will be a tab called “My Add-on” with a button to call the operator.
Attachments:You must be logged in to view attached files.
Oh, Sorry Dan, I didn’t see your post! Will investigate your script soon 🙂
Finally took the time to build a basic UI for my addon project 🙂
So here you can find a v0.1 of the script 🙂
There are tooltips explaining the functions.
At Bcon16 I had a chat with a few people working in CAD and interested in this as well.
One of them actually has a kickass addon that he made for the company he works for.
He sent it to me and there’s a shitload of good ideas, so you can expect a lot of additional features!
You must be logged in to reply to this topic.