Now Through Sunday Night. Black Friday Deals & Free Shipping! See the deals.
Home » Developers » Shapeways API » trying to upload stl model with python
Search Search  
Show: Today's Messages    Show Polls    Message Navigator
trying to upload stl model with python [message #30701] Tue, 12 July 2011 13:39 UTC Go to next message
avatar wzesk  is currently offline wzesk
Messages: 2
Registered: August 2009
Go to all my models
Junior Member
Below is my attempt. Does anyone have an example of how to format a .stl into an array[byte]?

   
 def submit(self):
        if self.session_id:
            model = self.assembly.SWModel()
            model.title = "test"
            model.desc = "test"
            model.modeltype = "STL"
            model.file = (base64.b64encode(open("test.stl").read()))
            model.filename = "test"
            model.tags = "test"
            model.has_color = 0
            model.scale = 1.0
            model.markup = 1.0
            loaded = self.shapelink.submitModel(self.session_id,model,"", self.application_id)
            return loaded

[Updated on: Tue, 12 July 2011 13:41 UTC]

Re: trying to upload stl model with python [message #30825 is a reply to message #30701 ] Wed, 13 July 2011 22:44 UTC Go to previous messageGo to next message
avatar wzesk  is currently offline wzesk
Messages: 2
Registered: August 2009
Go to all my models
Junior Member
got it working.

Here is the solution I used :
model.file = tuple(bytearray((open("test.stl").read()),"base64"))
Re: trying to upload stl model with python [message #35545 is a reply to message #30701 ] Fri, 30 September 2011 20:09 UTC Go to previous message
avatar lancepickens  is currently offline lancepickens
Messages: 1
Registered: January 2011
Go to my shop
Junior Member
you need to specify 'rb' in your open method to specify to treat the file as binary.

 
   
Previous Topic:Drop Shipping Can we get?
Next Topic:Other APIs planned?

Logo

Hello.

We're sorry to inform you that we no longer support this browser and can't confirm that everything will work as expected. For the best Shapeways experience, please use one of the following browsers:

Click anywhere outside this window to continue.