Article - CS370585

In Creo View WebGL Toolkit example "web-application-example", after adding some components by StructureEdit.InsertBranches() and then removing some of them, selecting some newly added nodes in the tree doesn't select the correct model in graphical window.

Modified: 30-Jun-2022   


Applies To

  • Creo View 8.1
  • Creo View WebGL Toolkit

Description

  • In Creo View WebGL Toolkit example web-application-example, after adding some components by StructureEdit.InsertBranches() and then removing some of them, selecting some newly added nodes in the tree in Structure tab doesn't select the correct model in graphical window.
  • The tree and view data are inconsistent when components are deleted by StructureEdit.RemoveComps().
  • $scope.ibDlgInsert() is modified as shown below:
$scope.ibDlgInsert = function() {
	if ($scope.structEdit.ibUrl == "")
		return;
	$scope.hideDialog();

	var se = $scope.session.GetStructureEdit();
	if (se) {
		let it = $scope.selection.nodes.values();
		let idpath = it.next().value;
		if (!idpath) return;
		let node = $scope.idpathMap[idpath];
		if (node) {
			$scope.SetCurrentModel(node.data.modelId);
			if ($scope.model) {
				var strippedIdpath = $scope.StripModelIdFromIdPath(node.data.idpath);

				if (strippedIdpath == ':') {
					// root node
					console.log('You cannot merge into root node.');
				} else {
					var IdNameFileVector = Module.IdNameFileVector.Create();
					IdNameFileVector.InsertIdNameFile(strippedIdpath, $scope.structEdit.ibName == '' ? "option2" : $scope.structEdit.ibName, $scope.structEdit.ibUrl);

					se.InsertBranches(IdNameFileVector, true, true, true, function (success) {
						if (success) {
							console.log('Successfully merged');
						} else {
							console.log('Failed to merge');
						}
					});
					$scope.ClearNodeSelection();

					if (dbRecentPVS == undefined) return;
					var dataSet = dbRecentPVS.transaction("RecentPVSObjectStore", "readwrite").objectStore("RecentPVSObjectStore").get($scope.structEdit.ibUrl);
					dataSet.onsuccess = function(event) {
						if (event.currentTarget.result === undefined) {
							storeRecentUrl($scope.structEdit.ibUrl);
						}
					};
				}
			}
		}
	}
};
This is a printer-friendly version of Article 370585 and may be out of date. For the latest version click CS370585