New NURBS tools

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

Re: New NURBS tools

Post by clintonman »

Fixed one line that had "System.Alert" to just "Alert"
Added the Control aspect back in.
Formatted the code so it is readable.
Attachments
Guard.RsObj
(19.82 KiB) Downloaded 122 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: New NURBS tools

Post by trueBlue »

clintonman wrote: 10 Aug 2021, 23:35 Probably not a good place for it. This works with cameras and lights, it's not exclusive to NURBS. Which is also the reason Guard isn't inside the NURBS group.
Any suggestions?
Even though it protects Cameras & Lights, the majority protects NURBS
I thought it was the best choice since it is more front and center and because the Protect NURBS' Set button is in the NURBS Utilities
Set button script can also call the Guard panel

Code: Select all

if(!Node.Exists("Scripts/CustomCommands/Guard")) return;
if(Node.Value("%THIS_NAME%", "ProtectNURBS"))
Node.Value("Scripts/CustomCommands/Guard", "Active") = true;
else
Node.Value("Scripts/CustomCommands/Guard", "Active") = false;
if(Node.Value("Scripts/CustomCommands/Guard", "Active") == false) {
Warning("\nProtect NURBS is not Active!\n\nDisabling Protect NURBS is not recommended!")
UserInterface.OpenToolPanelViewEx2('', '','Scripts/CustomCommands/Guard',3,1,0);
}
function Warning(strText)
{
var nSecondsToWait = -1;
var strTitle = "Warning";
// values are hexadecimal
var MB_OK = 0;
var MB_SYSTEMMODAL = 4096;//1000L force on top
var MB_ICONEXCLAMATION = 48;//30L
var nType = MB_OK + MB_SYSTEMMODAL + MB_ICONEXCLAMATION;
var shell = new ActiveXObject("WScript.shell");
shell.Popup (strText, nSecondsToWait, strTitle, nType);
}
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: New NURBS tools

Post by clintonman »

Desktop would be a better place for it. Once there it can be removed from the NURBS panel.
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: New NURBS tools

Post by trueBlue »

clintonman wrote: 10 Aug 2021, 23:38 Fixed one line that had "System.Alert" to just "Alert"
Added the Control aspect back in.
Formatted the code so it is readable.
Cool, thanks!
Are you able to identify which tool is being used and display it in the Alerts?
Or break in down into individual Alerts with each tool?
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: New NURBS tools

Post by clintonman »

trueBlue wrote: 11 Aug 2021, 03:49
clintonman wrote: 10 Aug 2021, 23:38 Fixed one line that had "System.Alert" to just "Alert"
Added the Control aspect back in.
Formatted the code so it is readable.
Cool, thanks!
Are you able to identify which tool is being used and display it in the Alerts?
Or break in down into individual Alerts with each tool?
Nope, I wish. There is a command "params.GetControlIn();" which is supposed to tell you what called the script but it doesn't work.
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: New NURBS tools

Post by trueBlue »

clintonman wrote: 11 Aug 2021, 03:56
trueBlue wrote: 11 Aug 2021, 03:49
clintonman wrote: 10 Aug 2021, 23:38 Fixed one line that had "System.Alert" to just "Alert"
Added the Control aspect back in.
Formatted the code so it is readable.
Cool, thanks!
Are you able to identify which tool is being used and display it in the Alerts?
Or break in down into individual Alerts with each tool?
Nope, I wish. There is a command "params.GetControlIn();" which is supposed to tell you what called the script but it doesn't work.
Are you sure?
What do theses names mean or how are they being used to generate an Alert?

Code: Select all

	var reHair = /Hair/;
	var rePrim = /AddPrimitive/;
	var rePaintFace = /PaintFace/;

	var reCPMesh = /AddMorph|DisplacementMapping|OptimizeTriangulation|PE soft paint/
It seems to me, that you might be able to create individual functions for each tool with their own Alert's.
User avatar
clintonman
Captain
Posts: 5422
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: New NURBS tools

Post by clintonman »

trueBlue wrote: 11 Aug 2021, 04:11
clintonman wrote: 11 Aug 2021, 03:56
trueBlue wrote: 11 Aug 2021, 03:49
Cool, thanks!
Are you able to identify which tool is being used and display it in the Alerts?
Or break in down into individual Alerts with each tool?
Nope, I wish. There is a command "params.GetControlIn();" which is supposed to tell you what called the script but it doesn't work.
Are you sure?
What do theses names mean or how are they being used to generate an Alert?

Code: Select all

	var reHair = /Hair/;
	var rePrim = /AddPrimitive/;
	var rePaintFace = /PaintFace/;

	var reCPMesh = /AddMorph|DisplacementMapping|OptimizeTriangulation|PE soft paint/
It seems to me, that you might be able to create individual functions for each tool with their own Alert's.
I misunderstood. I was trying to get GetControlIn to work when I read your message, so that was on my mind and I forgot that Guard has commands passed into it.
I see three possibilities. The button "Name" or "HelpText" or some manually typed in text can be sent into the Guard and used to make decisions.
this

Code: Select all

RsApp.SendCustomEvent("Scripts/CustomCommands/Guard", {Cmd:"MeshModifiers.ActivateBooleansTool('Intersection','')"});
Activity.Run("Scripts/CustomCommands/Guard");
would change to something like this

Code: Select all

RsApp.SendCustomEvent("Scripts/CustomCommands/Guard", {HelpText: "Boolean intersection", Name: "Intersection", Cmd:"MeshModifiers.ActivateBooleansTool('Intersection','')"});
Activity.Run("Scripts/CustomCommands/Guard");
Then inside Guard OnCustomEvent function this add more code with var Name="", Name=eventData.Name...

Code: Select all

	var Cmd = "";

	if(eventData.Cmd)
		Cmd = eventData.Cmd;

	params.Global("Cmd") = Cmd;
Then inside Execute add like Cmd only use Name instead... var Name = params.Global("Name")

Code: Select all

	var Cmd = params.Global("Cmd");
So long story short you add the new data to the button command, save the data in the OnCustomEvent, and finally read and use the data inside Execute.

It seems like a lot of work for such a small change.
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: New NURBS tools

Post by trueBlue »

clintonman wrote: 11 Aug 2021, 04:46
trueBlue wrote: 11 Aug 2021, 04:11
clintonman wrote: 11 Aug 2021, 03:56
Nope, I wish. There is a command "params.GetControlIn();" which is supposed to tell you what called the script but it doesn't work.
Are you sure?
What do theses names mean or how are they being used to generate an Alert?

Code: Select all

	var reHair = /Hair/;
	var rePrim = /AddPrimitive/;
	var rePaintFace = /PaintFace/;

	var reCPMesh = /AddMorph|DisplacementMapping|OptimizeTriangulation|PE soft paint/
It seems to me, that you might be able to create individual functions for each tool with their own Alert's.
I misunderstood. I was trying to get GetControlIn to work when I read your message, so that was on my mind and I forgot that Guard has commands passed into it.
I see three possibilities. The button "Name" or "HelpText" or some manually typed in text can be sent into the Guard and used to make decisions.
this

Code: Select all

RsApp.SendCustomEvent("Scripts/CustomCommands/Guard", {Cmd:"MeshModifiers.ActivateBooleansTool('Intersection','')"});
Activity.Run("Scripts/CustomCommands/Guard");
would change to something like this

Code: Select all

RsApp.SendCustomEvent("Scripts/CustomCommands/Guard", {HelpText: "Boolean intersection", Name: "Intersection", Cmd:"MeshModifiers.ActivateBooleansTool('Intersection','')"});
Activity.Run("Scripts/CustomCommands/Guard");
Then inside Guard OnCustomEvent function this add more code with var Name="", Name=eventData.Name...

Code: Select all

	var Cmd = "";

	if(eventData.Cmd)
		Cmd = eventData.Cmd;

	params.Global("Cmd") = Cmd;
Then inside Execute add like Cmd only use Name instead... var Name = params.Global("Name")

Code: Select all

	var Cmd = params.Global("Cmd");
So long story short you add the new data to the button command, save the data in the OnCustomEvent, and finally read and use the data inside Execute.

It seems like a lot of work for such a small change.
That was going to be my last question if you said, "Nope"
Was thinking there could be some kind of individual Flag in each of the toolbar commands that would give you an indication from where it was being ran
Also figured it would be a LOT of work!
I seen some toolbar commands like '%TOOLBAR_CMD%' or something like that
I will see if I can find it again
They were used in a Physics toolbar
I think Anton was the author
Post Reply