RoboDK Forum
Error using mesh.Mesh.from_file (not found), Errno2 Error- Printable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: Error using mesh.Mesh.from_file (not found), Errno2 Error (/Thread-Error-using-mesh-Mesh-from-file-not-found-Errno2-Error)



Error using mesh.Mesh.from_file (not found), Errno2 Error-Olendo-04-05-2022

Hello everyone!


I have defined a code called "Gefährdungserkennung". I use a main program that manipulates the trajectory of a robot to make a pick-and-place task safer. This main program contains a subroutine called "Gefährdungserkennung".


The problem is that I need to load .stl files into the subroutine. This does not work.

I tried using "mesh.Mesh.from_file('filename.stl') to load my .stl into the subroutine.

The error is:


"File "c:\Users\...", line 22, in Gefährdungserkennung.
torso = mesh.Mesh.from_file('filename.stl')
File "C:\RoboDK\Python37\lib\site-packages\stl\stl.py", line 376, in from_file
with open(filename, 'rb') as fh:
FileNotFoundError: [Errno 2] No such file or directory: 'filename.stl'.


The spelling of the filename is correct and the location of the filename is in the same folder as the .py program. Numpy-stl was installed successfully.


你知道为什么和我不工作吗sh.Mesh.from_file? Or any alternatives?
I would be very pleased to receive an answer.


With kind regards

Ole


The code of the subroutine is copied and pasted as .txt below in the attachment.


RE: Error using mesh.Mesh.from_file (not found), Errno2 Error-Olendo-04-05-2022

Here is the code of the subroutine as .txt below in the attachment.


RE: Error using mesh.Mesh.from_file (not found), Errno2 Error-Sam-04-07-2022

Hello!

There are a few things you can check.
  • Ensure your working directory is at the file level: os.getcwd()
  • Ensure you have read access: os.access('filename.stl', os.R_OK)



RE: Error using mesh.Mesh.from_file (not found), Errno2 Error-Olendo-04-11-2022

Hello Sam,

first of all, thank you very much for your quick response! I accidentally found out what caused the error. The problem was that if I use the following copied path: torso = mesh.Mesh.from_file('C:/Users/username/Desktop/Projects/RoboDK/filename.stl') with a capital C at the beginning ('C:/..) like i did, the Errno2 error appears. If I use ('c:/User...) with a lowercase c at the beginning, it works! My bad.

best regards from Germany

Ole


RE: Error using mesh.Mesh.from_file (not found), Errno2 Error-Sam-04-11-2022

Glad to know you resolved this issue!