Re: pystl

2016-08-17 Thread Peter Otten
Poul Riis wrote:

> I tried the following:
> 
> from pystl import PySTL
> with PySTL('stl_test.stl') as stl:
> stl.add_triangle((0,0,0),(1,0,0),(0,1,0))
> 
> I got the following error message:
> 
> Traceback (most recent call last):
>   File
>   
"C:/Users/pr/AppData/Local/Programs/Python/Python35-32/Lib/idlelib/pystl_module_test_1.py",
>   line 3, in 
> with PySTL('stl_test.stl') as stl:
>   File
>   "c:\users\pr\appdata\local\continuum\anaconda3\lib\site-
packages\pystl\pystl.py",
>   line 62, in __enter__
> self.write_stl_header()
>   File
>   "c:\users\pr\appdata\local\continuum\anaconda3\lib\site-
packages\pystl\pystl.py",
>   line 75, in write_stl_header
> self.f.write(struct.pack("80s", header_str))
> struct.error: argument for 's' must be a bytes object

You can fix this particular error by replacing the line

header_str = ''

with 

header_str = b''

in the write_stl_header() function which then becomes:

def write_stl_header(self):
if self.is_bin:
header_str = b''
self.f.write(struct.pack("80s", header_str))
self.write_num_triangles_bin()
else:
self.f.write('solid ' + self.model_name + '\n' )

As this kind of error indicates that the module is primarily used/tested in 
Python 2 there may be other similar problems.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pystl

2016-08-17 Thread Steven D'Aprano
On Wednesday 17 August 2016 18:56, Poul Riis wrote:

> I tried the following:
> 
> from pystl import PySTL
> with PySTL('stl_test.stl') as stl:
> stl.add_triangle((0,0,0),(1,0,0),(0,1,0))
> 
> I got the following error message:


Ah, bad news I am afraid. That looks like a bug in pystl.

I don't think there is anything you can do about it except:

- make sure you have the most recent version of pystl;
- make sure that it supports the version of Python you are using;
- if so, report it as a bug to the pystl project.

> 
> Traceback (most recent call last):
>   File
>   
"C:/Users/pr/AppData/Local/Programs/Python/Python35-32/Lib/idlelib/pystl_module_test_1.py",
>   line 3, in 
> with PySTL('stl_test.stl') as stl:
>   File
>   "c:\users\pr\appdata\local\continuum\anaconda3\lib\site-
packages\pystl\pystl.py",
>   line 62, in __enter__
> self.write_stl_header()
>   File
>   "c:\users\pr\appdata\local\continuum\anaconda3\lib\site-
packages\pystl\pystl.py",
>   line 75, in write_stl_header
> self.f.write(struct.pack("80s", header_str))
> struct.error: argument for 's' must be a bytes object



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pystl

2016-08-17 Thread Poul Riis
I tried the following:

from pystl import PySTL
with PySTL('stl_test.stl') as stl:
stl.add_triangle((0,0,0),(1,0,0),(0,1,0))

I got the following error message:

Traceback (most recent call last):
  File 
"C:/Users/pr/AppData/Local/Programs/Python/Python35-32/Lib/idlelib/pystl_module_test_1.py",
 line 3, in 
with PySTL('stl_test.stl') as stl:
  File 
"c:\users\pr\appdata\local\continuum\anaconda3\lib\site-packages\pystl\pystl.py",
 line 62, in __enter__
self.write_stl_header()
  File 
"c:\users\pr\appdata\local\continuum\anaconda3\lib\site-packages\pystl\pystl.py",
 line 75, in write_stl_header
self.f.write(struct.pack("80s", header_str))
struct.error: argument for 's' must be a bytes object



Poul Riis





Den onsdag den 17. august 2016 kl. 08.49.29 UTC+2 skrev Steven D'Aprano:
> On Wednesday 17 August 2016 16:36, Poul Riis wrote:
> 
> > Can someone deliver a minimal, fully working example with the pystl module,
> > https://pypi.python.org/pypi/pystl/
> > 
> > The only example code mentioned is the following:
> > 
> > with PySTL(‘stl_test.stl’) as stl:
> > stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )
> > 
> > 
> > but no matter what 'import'-statement I try I cannot make it work.
> 
> Don't make us guess. What have you tried, and what happens when you do? Cut 
> and 
> paste the *actual* code you try, and the *actual* results.
> 
> http://mattgemmell.com/what-have-you-tried/
> 
> http://www.sscce.org/
> 
> 
> > I have installed the module and a program containing only the following line
> > 
> > from pystl import PySTL
> > 
> > runs without any error message.
> 
> Great. Then try this:
> 
> from pystl import PySTL
> with PySTL(‘stl_test.stl’) as stl:
> stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )
> 
> 
> 
> If it doesn't work, what does it do?
> 
> 
> 
> -- 
> Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: pystl

2016-08-17 Thread Steven D'Aprano
On Wednesday 17 August 2016 16:36, Poul Riis wrote:

> Can someone deliver a minimal, fully working example with the pystl module,
> https://pypi.python.org/pypi/pystl/
> 
> The only example code mentioned is the following:
> 
> with PySTL(‘stl_test.stl’) as stl:
> stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )
> 
> 
> but no matter what 'import'-statement I try I cannot make it work.

Don't make us guess. What have you tried, and what happens when you do? Cut and 
paste the *actual* code you try, and the *actual* results.

http://mattgemmell.com/what-have-you-tried/

http://www.sscce.org/


> I have installed the module and a program containing only the following line
> 
> from pystl import PySTL
> 
> runs without any error message.

Great. Then try this:

from pystl import PySTL
with PySTL(‘stl_test.stl’) as stl:
stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )



If it doesn't work, what does it do?



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


pystl

2016-08-17 Thread Poul Riis
Can someone deliver a minimal, fully working example with the pystl module,
https://pypi.python.org/pypi/pystl/

The only example code mentioned is the following:

with PySTL(‘stl_test.stl’) as stl:
stl.add_triangle( (0.0, 0.0, 0.5), (0.0, 1.0, 0.0), (1.0, 1.0, 0.5) )


but no matter what 'import'-statement I try I cannot make it work.



I have installed the module and a program containing only the following line

from pystl import PySTL

runs without any error message.


Poul Riis
-- 
https://mail.python.org/mailman/listinfo/python-list