-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"to_stl" not creating STL output file #11
Comments
Thanks for trying ccad. I believe your fix is not a good long-term solution, because BRepMesh_IncrementalMesh converts some faces to a mesh of triangulated faces, which could mess up subsequent operations. There's a reason people suffer the math difficulty of BRep instead of processing everything as triangulated faces. I think it would be better to understand why the original shape didn't create an stl file. Does to_stl work on simple shapes like spheres, cylinders, and boxes for you, or does it fail for everything? If it fails for everything, I suspect a compatibility problem. ccad hasn't been enhanced for a while. It only works well up to oce and python occ 0.16.x. It breaks often (the viewer, particularly) with oce and python occ 0.17+ and 0.18+. If it works on simple shapes but fails for your shape, when you view your shape, does it look right -- no improperly facing faces, no breaks at seam lines etc.? to_stl can break on improper shapes. Have you tried playing with the rel_deflection (in relative mode) or the abs_deflection (in abs mode) parameters? Tight bends can break to_stl unless you make the stl mesh fine enough. If all else fails, and the model is not proprietary, you can email or dropbox a .brep representation, and I'll try to duplicate the problem. Thanks, |
Hi Charles, If it matters, you are correct that my viewer does not work. "import ccad.display as cd" throws an exception. "ImportError: cannot import name Visual3d_ViewOrientation" with OCC verion 0.18. I'm sorry I was too lazy to implement the deepcopy suggestion in the first place, but this is what I would recommend. also add "import copy" at the top. The above fix works for me and addresses your concern of converting the original shape to a mesh. Without the above fix, I tried both a box and sphere and neither one made an STL file import ccad.model as cm AND import ccad.model as cm Hope this helps. |
Hi Charlie, I looked at the OCE source and pythonocc 0.18. It seems like OCE's StlAPI_Writer still takes a TopoDS Shape as an input, but your experience shows it clearly wants a Mesh. It may be a Windows 10 only bug, but it could be universall. I'll keep this Issue open, and I'll look at it when I port ccad to use pythonocc 0.18. No promises when that will happen. I would recommend you go to the unittest directory and run test_all: python test_all.py It tests every feature in ccad.model. to_stl might not be the only unexpected ccad.model failure under 0.18. |
Here's the result of the python test_all.py Interestingly, when I run the unittest with my mesh addition logic, a tmp.stl file does appear, whereas when I run it with your original code, no tmp.stl appears. ======================================================================
|
Thanks. It looks like ccad has a few more bugs when using pythonocc 0.18:
More work for the 0.18 compatibility migration. |
On my system (a Windows 10 machine) the "to_stl" did not create an STL file.
(No exceptions thrown, but also no STL created.)
In the function "to_stl" (~line 1914)
I added the new line (~line 1949):
BRepMesh_IncrementalMesh( self.shape, 0.01 )
just above the following line (~line 1949):
w.Write(self.shape, name)
and it now works for me.
(also added: "from OCC.BRepMesh import BRepMesh_IncrementalMesh" at the top of the file)
I'm not sure if a copy or deepcopy might be required to prevent changes to the original "self.shape"
Also, the default value of the mesh parameter "0.01" probably needs some consideration.
The text was updated successfully, but these errors were encountered: