Dynamic query of designs

To be able to display query Sculpteo designs in JavaScript, the following script should be included in the <head> section of your page:

<script src="//www.sculpteo.com/js/sculpteo.widget.js" type="text/javascript"></script>

Then the ‘sculpteo.design’ function enables querying designs in a convienent manner. It takes three arguments, a ‘selector’, a ‘onsuccess’ callback and a ‘onerror’ callback.

The selector is a string and defines the query. If it starts with ‘#’ it selects a single design whose UUID is the following string. If it starts with ‘.’ it selects a design list whose UUID is the following string. Otherwise, it searches the public designs for with information (name, description, keywords, …) matching the query string.

The onsucess callback is called with a list of resulting designs as first argument. This list may be empty if no design matches the selector. Otherwise, each element of the list describes a design, via a Javascript Object containing the following properties:

bind(String event, function onevent(…))

Listen to event, arguments of callback function are event-dependent

click(function onevent(…))

equivalent to bind(“click”, onevent)

unbind(String event)

Stop listening to event

description

a description of the design

designer

user id of the designer

name

the name of the design

src

viewer information on the design

thumbnail_frontview

a thumbnail image of the design seen from the front

uuid

the unique identifier of the design

get_price(options, onsuccess, onerror)

a function to get the price on this design, depending on material, quantity, scale (see Obtaining the 3D printing price of a design for the list of parameters supported in the options dictionary, and a description of the response)

thumbnail(options)

create and return a thumbnail DOM element on this design (see Embedded thumbnail for the list of supported options)

viewer(options)

create and return a viewer DOM element on this design (see Embedded 3D viewer for the list of supported options)

Example

// show the name of the design whose UUID is 'FFn2bGoP'
sculpteo.design('#FFn2bGoP', function(design_list) { alert(design_list[0].name); }, alert)

// append to the body of the document thumbnails of designs matching the 'robot' search query
sculpteo.design('robot', function(design_list) { for (i in design_list) { document.body.appendChild(design_list[i].thumbnail()) } }, alert)
Prev: Overlay box with Sculpteo content Next: Querying information

» webapi documentation » Embedding Sculpteo Web Components » Dynamic query of designs

Last update: 1970-01-01 01:00 (CET)