Import Entities into ThingWorx Composer
Things in ThingWorx Composer are digital representations of physical objects, assets, products, systems, people, or processes that have properties and business logic. In this case, the shoppingThing that you’ll create will represent a digital online parts store. It can then be imported into ThingWorx Composer and then later used inside Vuforia Studio.
1. Make sure you have the
metaShoppingEntities.twx file from
GitHub.
3. Open the shoppingThing once it’s imported into your ThingWorx instance.
4. The General Information tab includes general information about the Thing. In this case, the Name, Description, Tags, and ThingTemplate for the Thing are included. Tags are used to group or categorize ThingWorx entities and Thing Templates are used to create a new Thing based on a common base and functionality.
5. Open the Services tab under Entity Information. Services are functions that a Thing can perform. In this case, the getPriceAvailability service is associated with the shoppingThing Thing. The getPriceAvailability service takes an input part number for a selected part and outputs a set of values associated with an object that has the same part number used to represent each part in the quadcopter model.
a. You’ll see a text string named pid under Inputs. This text string is associated with the part number of a part on the quadcopter in your Vuforia Studio experience.
b. In the Outputs section, there is a variable named result. This variable is an infotable, which is a data table of values stored in ThingWorx.
c. The Script section contains the code that will be triggered when the service is run. In this case, the script starts by creating an empty infotable named quote. An array called products is then created, which contains objects for each of the parts that include their part number (pid) and price as strings, and a Boolean called availability, which tells you if a part is available or not. An object called newEntry is created which will store the availability, price, and part number of the selected part. A for loop is added to the script to run through the products array, match the input pid to the pid property of one of the parts in the products array, and then update the newEntry object with the availability and price of the part. The information in the newEntry object is then added as a new row in the quote table, which is output as the result variable back into Vuforia Studio.
| The prices are different from the ones that you added to the model in Creo Illustrate. |
6. Open the Run Time tab under Permissions, and make sure the accounts for your ThingWorx and Vuforia Studio instances have full access permissions for shoppingThing. This enables the service to be called in Vuforia Studio.