Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Hello
I'm working on an HoloLens experience where I want to make some models invisible. Somehow it's not possible to change the visibility attribute of the models and also the forceHidden attribute does not work on the HoloLens...
I also tried it with the opacity all the following commands don't work neither. To check if its principally working I added the command to move the model on the z-axis and this works.
$scope.app.voiceHideSteelwork = function() {
voiceHideSteelwork();
}
function voiceHideSteelwork() {
$scope.setWidgetProp('model-1','z','0');
$scope.setWidgetProp('model-1','opacity','0.5');
$scope.view.wdg['model-1'].opacity = 0.5;
$scope.view.wdg['model-1']['opacity'] = 0.5;
$scope.setWidgetProp('modellItem-1','opacity','0.5');
$scope.view.wdg['modellItem-1'].opacity = 0.5;
$scope.view.wdg['modellItem-1']['opacity'] = 0.5;
}
Can somebody help me to make a model invisible?
Best regards
David
Solved! Go to Solution.
Thanks a lot for the detailed informations and help.
While trying it out I discovered that I was to stupid to write "modelItem" correctly which was the issue.
With commands like $scope.setWidgetProp('modelItem-1','opacity','0.1'); it works fine.
Best regards
David
Hi @BCAG_David ,
in generally on HoloLens setting components as invisible should work – I think so far I remember I did this I the past.
What could be wrong in your case / without having a sample data for your case:
$scope.setWidgetProp('model-1','sequence','');
//or
$scope.setWidgetProp('model-1','sequence',undefined)
$scope.setWidgetProp( target, 'color', "rgba(255,0,0,1.0)")
$scope.setWidgetProp( target, 'opacity', 0.8)
$scope.$applyAsync();
the first line in the code set the rgb color and the alpha channel . The alpha channel has on some platform the same effects as setting transparency - but so far, I remember on the HoloLens is not a good idea to use value is not 1.0. There is better to use the opacity property. As last action we need to force the execution of the settings
$scope.$on('userpick', function(event,target,parent,edata)
{
//-----
if (edata) {
try{
console.log('edata');console.warn(edata);
console.log("JSON.parse(edata)");console.warn(JSON.parse(edata));
var pathid = JSON.parse(edata).occurrence;
$scope.currentSelection = target + "-" + pathid;
// this is the current selection - the selected component occurence
// you can use it for example as shown below
console.log("=>>"+$scope.currentSelection);
tml3dRenderer.setProperties($scope.currentSelection, { hidden:true } );
} catch (ea) {console.error("not twx-model is clicked but still fired")}
}
else {
console.log('userpick evt w/o element data: '+ event.name + " target: " + target + " and parent:" + parent);
} //edata
}) //event on userpick
};
This code should blank a components which is selected on userpick - means when you click on it. You can blank an object without picking on it , when you know where the component is - in which model widget and what is the occurrence path of it -> example - when you have an component with occurrence (this is modelItem widget property) the same as path Id in Creo View = /0/1/3 and the component belongs to the model widget model-2 in this case you can blank it by calling:
:
tml3dRenderer.setProperties('model-2-/0/1/3', { hidden:true } );
Thanks a lot for the detailed informations and help.
While trying it out I discovered that I was to stupid to write "modelItem" correctly which was the issue.
With commands like $scope.setWidgetProp('modelItem-1','opacity','0.1'); it works fine.
Best regards
David