Materials List in submitModel

Discussion in 'Shapeways API' started by GeoBling, Nov 21, 2011.

  1. GeoBling
    GeoBling New Member
    While it doesn't appear on the API documentation site, the Web Service Description indicates that for the data type SWModel used for the submitModel function, there is a parameter "materials":

    Code:
    <xsd:element name="materials" type="xsd:array" nillable="1"/>
    I tried using the materials parameter for a PHP batch upload script I am using to upload tens of models in one operation. The script works fine when not using the materials field. I have a small set of test models that pass the test when uploaded through the API. As soon as I specify the materials parameter, however, I start getting this error email:

    It is unclear to me why this error appears. The model uploads and validates just fine when not specifying materials. Maybe the materials parameter is not working correctly?

    I realize that this is an undocumented feature and therefore it would be fair to say that I cannot possibly expect it to work. But since the parameter is already there in code and because others have asked for it here in the forums, I figured I'd flag this up. It would be extremely helpful to me (and probably others) if you could make the materials parameter work. If I could specify the available materials for the model through the API, it would save me hours of repetitive clicking in the web interface.
     
  2. mctrivia
    mctrivia New Member
    you need to use the material name. it must be an exact match also. It is a silly setup but oh well.
     
  3. GeoBling
    GeoBling New Member
    With that hint I get it to work for a single material by specifying it as a string like so:
    Code:
    'materials' => 'Silver'
    But what if I need to specify multiple materials? I tried all of these without any success:
    Code:
    'materials' => array('Silver','Sandstone')
    Code:
    'materials' => 'Silver,Sandstone'
    Code:
    'materials' => 'Silver;Sandstone'
    Code:
    'materials' => 'Silver&Sandstone'
    Am I missing something?

    And while I'm at it: I expected the "tags" to show up as "keywords" under the model but they don't. Any trick for these?
     
    Last edited: Nov 23, 2011
  4. mctrivia
    mctrivia New Member
    beleive sandstone is called
    "Full Color Sandstone"

    I know WSF is "White, Strong & Flexible" caps must be exact.

    try
    Code:
    'materials' => array('Silver','Full Color Sandstone')
    That is the correct formating at least
     
    Last edited: Nov 28, 2011
  5. GeoBling
    GeoBling New Member
    Thanks mctrivia! So while I was trying this I must have been using a bad set of material names, stupid me!

    In the meantime we also found a way to work around this: I generated a whole bunch of Javascript to automatically fire the requests to the Shapeways server that would normally be generated by manually filling out the materials form for each model and saving it. Here is a sample:

    Code:
    jQuery.post("/index.php?uri=/udesign/model/saveMaterials","model_id=12345678&default_material_id=53&
    markup%5B1%5D=&materials_available%5B%5D=1&
    markup%5B4%5D=&materials_available%5B%5D=4&
    markup%5B5%5D=&materials_available%5B%5D=5&
    markup%5B6%5D=2&materials_enabled%5B%5D=6&materials_available%5B%5D=6&
    markup%5B7%5D=&materials_available%5B%5D=7&
    markup%5B23%5D=&materials_available%5B%5D=23&
    markup%5B25%5D=2&materials_enabled%5B%5D=25&materials_available%5B%5D=25&
    markup%5B26%5D=&materials_available%5B%5D=26&
    markup%5B27%5D=&materials_available%5B%5D=27&
    markup%5B28%5D=&materials_available%5B%5D=28&
    markup%5B30%5D=&materials_available%5B%5D=30&
    markup%5B31%5D=&materials_available%5B%5D=31&
    markup%5B35%5D=&materials_available%5B%5D=35&
    markup%5B36%5D=&materials_available%5B%5D=36&
    markup%5B37%5D=&materials_available%5B%5D=37&
    markup%5B38%5D=&materials_available%5B%5D=38&
    markup%5B39%5D=&materials_available%5B%5D=39&
    markup%5B45%5D=2&materials_enabled%5B%5D=45&materials_available%5B%5D=45&
    markup%5B53%5D=12&materials_available%5B%5D=53&
    markup%5B54%5D=2&materials_enabled%5B%5D=54&materials_available%5B%5D=54&
    markup%5B58%5D=2&materials_enabled%5B%5D=58&materials_available%5B%5D=58&
    markup%5B59%5D=12&materials_enabled%5B%5D=59&materials_available%5B%5D=59&
    markup%5B60%5D=&materials_available%5B%5D=60&
    markup%5B61%5D=&materials_available%5B%5D=61&
    markup%5B62%5D=&materials_available%5B%5D=62&
    markup%5B63%5D=&materials_available%5B%5D=63", function(data) {console.log(data);}); 
    You can enter this into your browser's console (press Ctrl-Shift-I in Chrome), be sure to be logged in to Shapeways or otherwise it won't work. You can get the material IDs by having a careful look at the "Edit Model" page's sourcecode. A similar trick works for batch changing the tags, but I somehow lost the source code I used for that.