Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

Translate the entire conversation x

How to assign values from ThingWorx data table to Vuforia Studio widget

Aditya1702
16-Pearl

How to assign values from ThingWorx data table to Vuforia Studio widget

Hi Everyone,

 

I have a service in ThingWorx which returns an infotable, I want to assign the values from the infotable to widgets in Vuforia Studio.

 

Eg:

I am executing an inspection procedure in Vuforia Studio which has multiple number of steps. Each step has multiple checkpoints (3D Label Widget) in Vuforia Studio.

 

So for eg Step 1 has two checkpoints (3D Label Widget) at different position so I want to assign the position attributes of these 3D label widget through infotable.

 

After I inspect Step1 and click on next button Step2 checkpoints should be visible. 

Step2 suppose has 3 checkpoints at different locations so, they should be visible and their widget values should be set through an infotable and so on.

 

So in general if I click and move to Step2 Vuforia Studio should pick values from infotable and set to the number of checkpoints (3D Label Widget) that a particular step has and set their visibility to true..

 

Thanks in Advance.

 

Regards,

Aditya Gupta

2 REPLIES 2

Hi @Aditya1702 ,

acctually when you have a TWX service that return an infotable then you can use a widget like repeat Widget or dataGrid widget  where you can link via UI binding and set the used values that is the default way - so that you will see depedning on your configuriaton in UI the InfoTable as table in 2D Elements shwowing the configruation fields

So that is the default way to use services which returns an Info Table.

To your applicaiton case I believe you require another approach. For me that sounds like a project where you need to split to atom problem and report which of them as single quesiton. That is what I think ... 

What means inspect step on... we are in Vuforia Studio and that is not by default (like a Expert capture module) 

 

So belive you have an infotable containing rows which means each row a step. Or what contains the clolumns and the rows? That is imporatant to know for the further considirations.

So let say you have each row correspoinding to a step

and which column correspoinding to to a label postion.

So you go to the step 2 and read the second row of the table and set simple the viewpoints via the viewpoint data.

The view point data e.g. for 16 points could looks like that:

//// here the waitpoint data for 16 Waypoints
//######################################
$scope.app.waypointsdata=[{"position":{"x":-0.5,"y":0.5,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":"0.2","wayfinderDisplayBoundary":"0.2","label":"Waypoint 1"},{"position":{"x":0.0608,"y":0.4892,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":"0.2","wayfinderDisplayBoundary":"0.2","label":"Waypoint 2"},{"position":{"x":0.5117,"y":0.6721,"z":-0.3123},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":"0.2","wayfinderDisplayBoundary":"0.2","label":"Waypoint 3"},{"position":{"x":-0.1058,"y":0.6174,"z":0.1117},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":"0.2","wayfinderDisplayBoundary":"0.2","label":"Waypoint 4"},{"position":{"x":-0.1467,"y":0.1608,"z":0.1022},"gaze":{"x":-5.781425897883269e-17,"y":0.47208925070547064,"z":0.8815507582484104},"up":{"x":0,"y":1,"z":0},"eventRadius":"0.2","wayfinderDisplayBoundary":"0.2","label":"Waypoint 5"},{"position":{"x":0,"y":0,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 6"},{"position":{"x":1.0684,"y":0,"z":0.2729},"gaze":{"x":0,"y":-0.9999999847691291,"z":-0.00017453292431324208},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 7"},{"position":{"x":0,"y":0,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 8"},{"position":{"x":0,"y":0,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 9"},{"position":{"x":0,"y":0,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 10"},{"position":{"x":0.5752,"y":0,"z":0.6409},"gaze":{"x":0,"y":-0.9999999847691291,"z":-0.00017453292431324208},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 11"},{"position":{"x":0,"y":0,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 12"},{"position":{"x":0.4452,"y":0,"z":0.3125},"gaze":{"x":0,"y":-0.9999999847691291,"z":-0.00017453292431324208},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 13"},{"position":{"x":-0.071,"y":0,"z":0.9664},"gaze":{"x":0,"y":-0.9999999847691291,"z":-0.00017453292431324208},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 14"},{"position":{"x":-0.1722,"y":0,"z":1.1677},"gaze":{"x":0,"y":-0.9999999847691291,"z":-0.00017453292431324208},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 15"},{"position":{"x":0,"y":0,"z":0},"gaze":{"x":0,"y":0,"z":-1},"up":{"x":0,"y":1,"z":0},"eventRadius":0.25,"wayfinderDisplayBoundary":"1","label":"Waypoint 16"}];
//######################################

that is an example of static data which could be changed by. eg. action:

for(let count=0; count <  $scope.app.waypointsdata.length;count++)
   $scope.app.waypointsdata[count].position.z -=0.5 ; //increments all z with -0.5
  
  $timeout(()=>{
 $scope.setWidgetProp('wayfinder-1' ,'waypointsData',$scope.app.waypointsdata); //assignee for update the datat to widget
    $scope.$applyAsync(); //update the widget
  },300)

changing the data and setting it to waywidget will update the widget according to the new values in the data- that is the way

So to the other question who to receive you data from TWx service which returns an info table

- regitster the server to the Expternal data -also the properties of the service should allow access in Studio (please see  https://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2FGrantUserPermissions.htm and https://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2FAnonymousAccess.html%23)

- then call the server - here example for the TWX statandard service  GetActiveUsers which returns an infoTable:

// this funciton will call the service data 
$scope.testTwxService=function(){
   var TWXmodelID = 'CurrentSessionInfo';
   var serviceName = 'GetActiveUsers';
    var data = {};
   twx.app.fn.triggerDataService(TWXmodelID, serviceName, data);
};
// here we receive the data whe service call is completed
$scope.$root.$on('GetActiveUsers-complete', function(event, args) { 
  console.log("GetActiveUsers-complete event");
  console.log("name="+event.name)
let retObjData=  args.data;
console.log("obj---> returned")
console.warn(retObjData);//print the object in the console
$scope.retObjData=retObjData;
})
//at the end it will save the data in $scope.retObjData

so when we see the service :

2025-01-23_14-04-00.jpg

 

will return a info table what we can see then in studio as objec like that:

 

2025-01-23_14-06-16.jpg

accessing the returned fields required first to print the table and to staty the structure and then via the JSON array object syntax to acces the desried field what you want to have.

 

 

 

kesingh
12-Amethyst
(To:Aditya1702)



Hello Aditya,

 

It looks like Roland has answered your question. For the benefit of other community members who may have the same inquiry, please consider marking his response as the Accepted Solution.

 

If this response did not address your question, please provide an update on your current status so we can continue to assist you.

 

Thank you for using the PTC Community!

 

 

Announcements
Top Tags