Show and Hide Commands

User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Show and Hide Commands

Post by trueBlue »

Okay thanks!
I just tested your change to function IsolateSelected()
It seems to work by not hiding everything :bananathumb:
With nothing selected it adds an entry in Command history
The only way I could stop that is add:
if (Node.SelectedCount() == 0) return;
to the beginning in the toolbar LMB command


Edit:
Did a search and global fs only being used in maybe 15 scripts, that's doable.
I hope that you are not having to change your CustomCommands scripts
If so, wouldn't be easier just to recreate another FN Set in UUCommands?
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Show and Hide Commands

Post by clintonman »

No buttons need to be changed.
No widgets to change
2 scripts attached so can now move Global Function Set into UUCommands.

Share your Delete when you're done and I'll convert it to 1 undo format.
Attachments
MeshOrigin.RsObj
(125.47 KiB) Downloaded 69 times
WebServer.RsObj
(351.84 KiB) Downloaded 65 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Show and Hide Commands

Post by trueBlue »

clintonman wrote: 12 Aug 2022, 21:33 No buttons need to be changed.
No widgets to change
2 scripts attached so can now move Global Function Set into UUCommands.

Share your Delete when you're done and I'll convert it to 1 undo format.
Move or Copy Global Function Set into UUCommands?

Delete

Code: Select all

// Author - Clinton Reese Wed Aug 10, 2022 12:26 pm
function Execute(params) 
{

	// var cmd = "";
	// cmd += "var selCount = Node.SelectedCount();"
	// cmd += "if (selCount == 0) return;"
	// cmd += "var reWhiteSpace = /^\\s/;"
	// cmd += "var selection = Node.Selection();"
	// cmd += "var selectionArray = selection.split(';');"
	// cmd += "for (var i = 0; i < selCount; i++) {"
	// cmd += "var selClean = selectionArray[i].replace(reWhiteSpace, '');"
	// cmd += "selectionArray[i] = selClean;"
	// cmd += "var nurbsNode = selClean;"
	// cmd += "if (Node.ConExists(selClean, 'Matrix'))"
	// cmd += "nurbsNode = Node.Owner(selClean);"
	// cmd += "if (Node.ConExists(nurbsNode, 'isaCurve')) {"
	// cmd += "selectionArray[i] = nurbsNode;"
	// cmd += "}"
	// cmd += "if (Node.Exists(nurbsNode + '/CP to patch CP')) {"
	// cmd += "selectionArray[i] = nurbsNode;"
	// cmd += "}"
	// cmd += "}"
	// cmd += "for (var key in selectionArray) {"
	// cmd += "Node.Delete(selectionArray[key]);"
	// cmd += "}"
	// cmd += "var PVT_LOCKED = 2;"
	// cmd += "RsStackView.RemovePanelsFromCurrSelection(PVT_LOCKED, 0);"
	// cmd += "Space.Unselect();"
	// RsApp.RunScriptBuffer(cmd);

	var GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");

	var Enhanced = 1;
	var ProtectSpecialNodes = true;
	var DeleteWholeNURBS = true;

	if(Node.Exists("Preferences/Custom preferences/Delete preferences")) {
		Enhanced = Node.Value("Preferences/Custom preferences/Delete preferences", "Enhanced");
		ProtectSpecialNodes = Node.Value("Preferences/Custom preferences/Delete preferences", "ProtectSpecialNodes");
		DeleteWholeNURBS = Node.Value("Preferences/Custom preferences/Delete preferences", "DeleteWholeNURBS");
	}

	if(Enhanced == 0) {
		Node.Delete('');
		return;
	}

	var selCount = Node.SelectedCount();
	if (selCount == 0) return;
	//var reWhiteSpace = /^\\s/;
	var reWhiteSpace = /^\s/;//conversion to string for cmd extra slash, use line above for 1 undo version
	var selection = Node.Selection();
	var selectionArray = selection.split(';');
	var deleteArr = [];
	for (var i = 0; i < selCount; i++) {
		var selClean = selectionArray[i].replace(reWhiteSpace, '');
		selectionArray[i] = selClean;

		if(DeleteWholeNURBS) {
			var nurbsNode = selClean;
			if (Node.ConExists(selClean, 'Matrix'))
				nurbsNode = Node.Owner(selClean);
			if (Node.ConExists(nurbsNode, 'isaCurve')) {
				selectionArray[i] = nurbsNode;
			}
			if (Node.Exists(nurbsNode + '/CP to patch CP')) {
				selectionArray[i] = nurbsNode;
			}
		}

		if(ProtectSpecialNodes == true) {
			if(selectionArray[i] == Space.CurrentScene() + "/Vray") {
				//if(!System.Question("The Vray node is selected. Are you sure you want to Delete it?")) {
				if(!GlobalFS.Question("Vray is required for Offline rendering\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}

			if(selectionArray[i] == Space.CurrentScene() + "/YafaRay4tS") {
				if(!GlobalFS.Question("YafaRay4tS is required for Offline rendering\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}

			if(selectionArray[i] == Space.CurrentScene() + "/PhotoRender") {
				if(!GlobalFS.Question("PhotoRender is required for Offline rendering\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}

			selPathArr = selectionArray[i].split("/");
			if(selPathArr.length < 4) {
				if(!GlobalFS.Question(Node.ShortName(selectionArray[i]) + " may be a required trueSpace System object!\nIf you Delete this file, you may have to\nReset the Default Context\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			} else if("/"+selPathArr[1]+"/"+selPathArr[2] != Space.CurrentScene()) {
				if(!GlobalFS.Question(Node.ShortName(selectionArray[i]) + " may be a required trueSpace System object!\nIf you Delete this file, you may have to\nReset the Default Context\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}
		}


		deleteArr.push(selectionArray[i]);
	}
	//for (var key in selectionArray) {
	//	Node.Delete(selectionArray[key]);
	//}

	var delNode;
	while(delNode = deleteArr.pop()) {
		Node.Delete(delNode);
	}
	var PVT_LOCKED = 2;
	RsStackView.RemovePanelsFromCurrSelection(PVT_LOCKED, 0);
	Space.Unselect(); //make scripts aware of deletion

}
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Show and Hide Commands

Post by clintonman »

trueBlue wrote: 12 Aug 2022, 22:11
clintonman wrote: 12 Aug 2022, 21:33 No buttons need to be changed.
No widgets to change
2 scripts attached so can now move Global Function Set into UUCommands.

Share your Delete when you're done and I'll convert it to 1 undo format.
Move or Copy Global Function Set into UUCommands?

Delete

Code: Select all

// Author - Clinton Reese Wed Aug 10, 2022 12:26 pm
function Execute(params) 
{

	// var cmd = "";
	// cmd += "var selCount = Node.SelectedCount();"
	// cmd += "if (selCount == 0) return;"
	// cmd += "var reWhiteSpace = /^\\s/;"
	// cmd += "var selection = Node.Selection();"
	// cmd += "var selectionArray = selection.split(';');"
	// cmd += "for (var i = 0; i < selCount; i++) {"
	// cmd += "var selClean = selectionArray[i].replace(reWhiteSpace, '');"
	// cmd += "selectionArray[i] = selClean;"
	// cmd += "var nurbsNode = selClean;"
	// cmd += "if (Node.ConExists(selClean, 'Matrix'))"
	// cmd += "nurbsNode = Node.Owner(selClean);"
	// cmd += "if (Node.ConExists(nurbsNode, 'isaCurve')) {"
	// cmd += "selectionArray[i] = nurbsNode;"
	// cmd += "}"
	// cmd += "if (Node.Exists(nurbsNode + '/CP to patch CP')) {"
	// cmd += "selectionArray[i] = nurbsNode;"
	// cmd += "}"
	// cmd += "}"
	// cmd += "for (var key in selectionArray) {"
	// cmd += "Node.Delete(selectionArray[key]);"
	// cmd += "}"
	// cmd += "var PVT_LOCKED = 2;"
	// cmd += "RsStackView.RemovePanelsFromCurrSelection(PVT_LOCKED, 0);"
	// cmd += "Space.Unselect();"
	// RsApp.RunScriptBuffer(cmd);

	var GlobalFS = Node.AccessFnSet("Scripts/CustomCommands/Global Function Set");

	var Enhanced = 1;
	var ProtectSpecialNodes = true;
	var DeleteWholeNURBS = true;

	if(Node.Exists("Preferences/Custom preferences/Delete preferences")) {
		Enhanced = Node.Value("Preferences/Custom preferences/Delete preferences", "Enhanced");
		ProtectSpecialNodes = Node.Value("Preferences/Custom preferences/Delete preferences", "ProtectSpecialNodes");
		DeleteWholeNURBS = Node.Value("Preferences/Custom preferences/Delete preferences", "DeleteWholeNURBS");
	}

	if(Enhanced == 0) {
		Node.Delete('');
		return;
	}

	var selCount = Node.SelectedCount();
	if (selCount == 0) return;
	//var reWhiteSpace = /^\\s/;
	var reWhiteSpace = /^\s/;//conversion to string for cmd extra slash, use line above for 1 undo version
	var selection = Node.Selection();
	var selectionArray = selection.split(';');
	var deleteArr = [];
	for (var i = 0; i < selCount; i++) {
		var selClean = selectionArray[i].replace(reWhiteSpace, '');
		selectionArray[i] = selClean;

		if(DeleteWholeNURBS) {
			var nurbsNode = selClean;
			if (Node.ConExists(selClean, 'Matrix'))
				nurbsNode = Node.Owner(selClean);
			if (Node.ConExists(nurbsNode, 'isaCurve')) {
				selectionArray[i] = nurbsNode;
			}
			if (Node.Exists(nurbsNode + '/CP to patch CP')) {
				selectionArray[i] = nurbsNode;
			}
		}

		if(ProtectSpecialNodes == true) {
			if(selectionArray[i] == Space.CurrentScene() + "/Vray") {
				//if(!System.Question("The Vray node is selected. Are you sure you want to Delete it?")) {
				if(!GlobalFS.Question("Vray is required for Offline rendering\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}

			if(selectionArray[i] == Space.CurrentScene() + "/YafaRay4tS") {
				if(!GlobalFS.Question("YafaRay4tS is required for Offline rendering\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}

			if(selectionArray[i] == Space.CurrentScene() + "/PhotoRender") {
				if(!GlobalFS.Question("PhotoRender is required for Offline rendering\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}

			selPathArr = selectionArray[i].split("/");
			if(selPathArr.length < 4) {
				if(!GlobalFS.Question(Node.ShortName(selectionArray[i]) + " may be a required trueSpace System object!\nIf you Delete this file, you may have to\nReset the Default Context\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			} else if("/"+selPathArr[1]+"/"+selPathArr[2] != Space.CurrentScene()) {
				if(!GlobalFS.Question(Node.ShortName(selectionArray[i]) + " may be a required trueSpace System object!\nIf you Delete this file, you may have to\nReset the Default Context\nRecommend that you do not Delete it!\n\nAre you sure you want to Delete it?", "Warning!", -1, true, 2)) {
					continue;
				}
			}
		}


		deleteArr.push(selectionArray[i]);
	}
	//for (var key in selectionArray) {
	//	Node.Delete(selectionArray[key]);
	//}

	var delNode;
	while(delNode = deleteArr.pop()) {
		Node.Delete(delNode);
	}
	var PVT_LOCKED = 2;
	RsStackView.RemovePanelsFromCurrSelection(PVT_LOCKED, 0);
	Space.Unselect(); //make scripts aware of deletion

}
Move it. When Delete is done that will be everyone who uses it.
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Show and Hide Commands

Post by clintonman »

Delete converted to "one" undo.
It looks like the questions may be creating more undos, but it is one undo for scene items.
Attachments
Delete.RsObj
(10.3 KiB) Downloaded 63 times
Clinton Reese

http://clintons3d.com
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Show and Hide Commands

Post by trueBlue »

clintonman wrote: 12 Aug 2022, 22:41 Delete converted to "one" undo.
It looks like the questions may be creating more undos, but it is one undo for scene items.
Scene undoes is 1 undo. Yay!

For me it is 2 undoes in the below Example
1
Widgets.DeactivateDefaultWidgets();
2
Delete Undo

Example:
In the LE, navigate to System and select the Status Line, then Ctrl + LMB select a few objects in the 3D View
Answer No to the Question
Press Undo twice
Note: The Status Line gets selected

If you do the same thing except Answer Yes, the Status Line gets unselected
Is the last line, Space.Unselect() not working?

Hint: The Status Line gets recreated after it is deleted so much it a little bit before running Delete
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Show and Hide Commands

Post by trueBlue »

Try this:

Add RsTool.Arrow() below Space.Unselect() to the Delete script
The Status Line gets unselected
Still 2 undoes
Edit: Never mind I forgot to press Undo twice
User avatar
trueBlue
Captain
Posts: 5208
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: Show and Hide Commands

Post by trueBlue »

clintonman wrote: 12 Aug 2022, 19:21 Here is the visibility fs with the isolate selected fix.
Testing shows that CloseORASettings doesn't work if you move it into the function set, it has to remain it's own thing.
I just noticed that the line(s) that have:
Activity.Run("Scripts/Commands/CloseORASettings");
should be:
Activity.Run("Scripts/UUCommands/CloseORASettings");
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Show and Hide Commands

Post by clintonman »

trueBlue wrote: 14 Aug 2022, 15:24
clintonman wrote: 12 Aug 2022, 19:21 Here is the visibility fs with the isolate selected fix.
Testing shows that CloseORASettings doesn't work if you move it into the function set, it has to remain it's own thing.
I just noticed that the line(s) that have:
Activity.Run("Scripts/Commands/CloseORASettings");
should be:
Activity.Run("Scripts/UUCommands/CloseORASettings");
Fixed
Attachments
Visibility Function Set.RsObj
(44.15 KiB) Downloaded 72 times
Clinton Reese

http://clintons3d.com
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Show and Hide Commands

Post by clintonman »

clintonman wrote: 07 Aug 2022, 23:41 VisibilityPrefs.jpg
This is what I came up with. It has an options panel for the show/hide buttons and moved UUFunctionSet into a new UUCommands.

replace Command nodes CycleCameras and EyeCam
remove Hide, Show, etc from Commands
add "Custom preferences" to Preferences
remove UUFunctionSet from Widgets
add UUCommands to Scripts
run "Modify Buttons" script with "Change Buttons" checked to update toolbar buttons to use new UUFunctionSet location


full install not sure of the details?
update buttons for all layouts and project and default_layout
replace init.js and reset.js for full or std, loads the UUCommands and new Custom preferences
export files for the 2 command nodes CycleCameras and EyeCam
quoting myself

I just found a problem with this script from August that was used to update the show and hide buttons.
It changes the buttons based on their name and one of the mesh edit buttons had the same name as the show/hide object button.

I'm working on a fix now.
Clinton Reese

http://clintons3d.com
Post Reply