Skip to main content
1-Visitor
November 2, 2021
Question

Part transforms of a same part no from two different PVZ's are changing

  • November 2, 2021
  • 1 reply
  • 2534 views

I am changing the source for model widget through select widget, and I am using 'userpick' function to get partID and highlight or hide different parts of the assembly. But the source PVZ files share few similar part numbers, and when I highlight those particular parts in one source file e.g. PVZ1 and switch to another file say PVZ2, from the select menu, the highlighted parts are staying in it's position from previous PVZ1 file. Whereas they suppose to be in some other location in PVZ2.

 

Is there any way to reset the transform data of the parts to default before loading the different source files in model widget?

1 reply

21-Topaz I
November 2, 2021

Hi @US_9557391 ,

issue seems to be a little bit strange. Please, let me explain:

- when you set from original source PVZ1 to PVZ2 and  then you will  click on the model with the userpick  method - in this case the received data is used to construct a selection e.g. :

 ......
//search all model widget in the current/ active/displayed view
angular.forEach($element.find('twx-dt-model'), function(value, key) {
 console.log("2 forEach: key="+key.toString() +" -- value="+value); 
angular.element(value).scope().$on('userpick',function(event,target,parent,edata) {
 //for each model widget will set a userpick listener 
 try{
 console.log('edata');console.warn(edata);
	 console.log("JSON.parse(edata)");console.warn(JSON.parse(edata)); 
 	 	var pathid = JSON.parse(edata).occurrence;
 //construct a selection handle like model-1-\0\1\4
 // where model-1 is the name of the model widget
 // \0\1\4 is the occurrrence path of the selected component
	 $scope.currentSelection = target + "-" + pathid;
// this is the current selection - the selected component occurence
// you can use it e.g. to blank component or set the color
 console.log("Current Selection=>>"+$scope.currentSelection);
 } catch (ea) {console.error("not twx-model is clicked but still fired")}
}) // end of the userpick definition
}) // end of the for each loop

 

In this case when we select on a particular part/component  in the modelwidget we will have a selection. In this case we need to check what is  the occurrence part of this selection? Does it belongs  to the PVZ1 or it belongs to PVZ2? you can select a part/component which is only contained by PVZ2 (PVZ1 does not have this component) to see. My expectation in this case is that you will get a real selection from PVZ2? Because what you see is what you get. It should be...

The further question is how did you request the location data? Possibly you did connect to the wrong data (means to the wrong json file which is loaded for this model) ... because you need for each model with a specific bom  -    an extra json file which actually is created when  adding  the pvz to the Studio upload folder - and when also the check box ("Allow the Experience access to CAD metadata") is selected

Here I want to refer to :

https://community.ptc.com/t5/Vuforia-Studio-and-Chalk-Tech/Incorporate-CAD-Metadata-Into-an-Experience-version-8-5-13-and/ta-p/693341

http://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2Fcad_metadata_api.html

http://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2Fmetadata%2FMetadata_201_userpick_event.html%23wwID0ET1IT

http://support.ptc.com/help/vuforia/studio/en/#page/Studio_Help_Center%2Fmetadata%2FMetadata_201_Highlight_Parts.html%23wwID0E62LT

The links above should show some aspects of the handling of meta data.

So again- we need here clarify  : Is the selected data (the selection like model-1-/0/1/4) correct?  Means it belongs to the correct model /PVZ

  • If not- then how did you define your user pick function? and how did you set the new pvz file to the source of the modelwidget. Possibly you need to update ... something like:
let modelName='model-1'
let pvz='test_kasten_new1'
 
$scope.$applyAsync(()=>{$scope.setWidgetProp(modelName, 'src', '');}); 
$timeout(function () {
 $scope.$applyAsync(()=>{$scope.setWidgetProp(modelName, 'src', 'app/resources/Uploaded/'+pvz +'.pvz');}); 
 
 },50);
 $timeout(function () {
 $scope.$applyAsync(()=>{$scope.setWidgetProp(modelName, 'sequence', '');});
 
 },150);

 $scope.$applyAsync();
....
  •  If yes - here you need to check. If you added the model to the folder with metadata- so that for the PVZ file what is set to src of the model widget we have also a corresponding json file.
  • Another point is to check how did you access to the json file data?  what is the API call where you did get the properties for the correct part /component ?
1-Visitor
November 2, 2021

Hello Roland,

Thank you for the prompt and detailed response. Let me explain how I am doing few things you asked about-

 

1) I am using the PTC.Metadata.fromId(targetName).then((metadata) => { API for the userpick method.

2) I have loaded the PVZ files with Metadata (proper JSON files) while uploading them to resources folder.

3) I am using the exact same line of code

$scope.currentSelection = target + "-" + pathid; 

to pick the metadata from PVZ file.

The problem lies with the "pathid" I guess, when I highlight any part with userpick method the value of that particular part (e.g. model-1-\0\0\28)is getting captured as you mentioned in first part of your response. But when I change the source of the model-1 widget, the part with same id (\0\0\28) get's automatically highlighted and appear in the same location of the previous PVZ files location of that part. I am not using timeout function to remove the highlight. I have created function called  "reset" and attached it to one button widget in UI.

4) I have created application parameter to create and access the array of the PVZ files from the app/resources/Uploaded/ folder. through the select widget list.

 

I am new to Vuforia and I am not programmer, this is my first project in Vuforia, I am using all the resources from the Help documentation to learn and create this experience. So please bare with me if at all I am asking silly questions.

 

The possible solution what I can think of could be - 

1. Clear the data from the userpick method while switching the Model-1 resource.

2. Resetting the highlight for all the parts at once rather than doing it for one part at a time with '$scope.hilite([$scope.currentselection].false)'. But I don't know how to achieve this with whatever little knowledge I got in Java scripting.

 

I would appreciate your help on this.

And thank you for the information you provided, It will help me in the building better AR experiences in future.

 

 

21-Topaz I
November 3, 2021

Hi @US_9557391 ,

Ok, thanks for your feedback. I was not aware about such behavior and will try frist to reproduce it .Some workflow like this:

- a modelwidget  in a project where are different pvz loaded in the upload project folder

-and then via , button - with javascript change between different pvz so will set them as src to the modelWidget 

-testing then the selection behavior and what is the occurrence path etc. 

-trying to get properties via the meta data api.

Please , let me know if I forget some point which is needed to be considered.

One thing - Are there any modelItems defined which points to components of the modelWidget?