New NURBS tools

User avatar
clintonman
Captain
Posts: 5428
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: 14 Jan 2021, 12:32
trueBlue wrote: 11 Jan 2021, 23:20
clintonman wrote: 11 Jan 2021, 05:57 Are you also planning to put restrictions on all the other tools too? I see many that will probably not work properly with nurbs.
Skeleton tools
Paint a material on a curve, or the control meshes
Hair tool on cp meshes.
SDS tool
any editing tool that would change the mesh
several of the custom tools
etc.
So far I have fixed these toolbar commands for the Navigation toolbar
Simplify Mesh
Build Normalmap
ChangeSSLevel(1)
ChangeSSLevel(-1)
Reset SDS
Heal Vertices
Scissors
PE Poly draw
PE Edge draw
PE Vertex draw
Sub Divide
Smooth Divide
Hair Length
Hair Blowdryer
Hair Softness
Hair Direction
Hair Density
Add Morph
Paint Face

Material Editor
D3D & VRay Paint Face

I do not see anything else that causes problems for Patches nor Curves
If I am missing something, give me steps and what to look for
This is not working for Shortcuts
As an example for Add SDS in PE mode
Node.Value("Scripts/Commands/RestrictNURBS", "Cmd") = "MeshModifiers.ChangeSSLevel(1)";Activity.Run("Scripts/Commands/RestrictNURBS");
Best I can tell, the first part using Node.Value does not work for Shortcuts
Activity.Run does work for Shortcuts
Assigning the shortcut does not work either
It seems to be working here. Do you have anything you can share to show it not working?
Clinton Reese

http://clintons3d.com
User avatar
spacekdet
Captain
Posts: 1799
Joined: 27 May 2009, 15:00
Type the number ten into the box: 10
Location: On the day shift at the Utility Muffin Research Kitchen
Contact:

Re: New NURBS tools

Post by spacekdet »

Είναι όλα ελληνικά για μένα
User avatar
trueBlue
Captain
Posts: 5214
Joined: 06 Jul 2009, 22:50
Type the number ten into the box: 10

Re: New NURBS tools

Post by trueBlue »

spacekdet wrote: 14 Jan 2021, 19:40 Είναι όλα ελληνικά για μένα
Me too :?

Code: Select all

return this.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
User avatar
clintonman
Captain
Posts: 5428
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: New NURBS tools

Post by clintonman »

Here is an update of the RunCommand script that has an alternate way of calling it. The previous way of calling also still works.

Code: Select all

obj={cmd:"MeshModifiers.SimplifyMesh('')",RsApp:RsApp,Node:Node};RsApp.SendCustomEvent("Scripts/Commands/RunCommand", obj);

Code: Select all

obj={cmd:"MeshModifiers.ChangeSSLevel(1)",RsApp:RsApp,Node:Node};RsApp.SendCustomEvent("Scripts/Commands/RunCommand", obj);
Attachments
RunCommand.RsObj
(7.31 KiB) Downloaded 156 times
Clinton Reese

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

Re: New NURBS tools

Post by trueBlue »

Implemented your new way and it works using scripts and toolbar commands but I am not able to get a shortcut to work
Had to modify the script to get it to import correctly from a xml file
First of all you had a typo with the evetData
Node = evetData.Node;
Correct
Node = eventData.Node;
Lots of other tweaks as well
If you want me to explain the process, I will try
One of the main changes is replacing params to ret
Or you can study the xml files included here
The two shortcuts are for Add SDS & Subtract SDS
Also Shift L for Workspace Layers
Best to replace the two xml files in the tS761 directory and Reset the Default Context(Required) to import the RestrictNURB into Commands internally
After that you can copy the code from the Scripts/Commands/RestrictNURB and paste it into a jScript
Button command for Add SDS

Code: Select all

obj={cmd:"MeshModifiers.ChangeSSLevel(1)",RsApp:RsApp,Node:Node};RsApp.SendCustomEvent("Scripts/Commands/RestrictNURBS", obj);
Also includes the new CloseORASettings.xml file

Edit: I created new script by way of Exporting the script using params and that works as well, so scratch using ret
The only difference is when Exporting is there is no GUID
Still can not get the shortcut to work
And NOW my SpaceBar shortcut does not WORK!!! Every time I edit the shortcut xml file and add the above shortcut, they both will not WORK
Also notice with this new way the CmdName never enters the Command
CmdName.png
CmdName.png (3.92 KiB) Viewed 2515 times
Attachments
RestrictNURBS.zip
(6.49 KiB) Downloaded 158 times
User avatar
clintonman
Captain
Posts: 5428
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: 15 Jan 2021, 13:09 ...
One of the main changes is replacing params to ret
...
Edit: I created new script by way of Exporting the script using params and that works as well, so scratch using ret
...
What is ret?
trueBlue wrote: 15 Jan 2021, 13:09 Implemented your new way and it works using scripts and toolbar commands but I am not able to get a shortcut to work
...
The two shortcuts are for Add SDS & Subtract SDS
Also Shift L for Workspace Layers
...
Still can not get the shortcut to work
And NOW my SpaceBar shortcut does not WORK!!! Every time I edit the shortcut xml file and add the above shortcut, they both will not WORK
Are you saying none of the shortcuts work or that 4 of the shortcuts don't work?
Did you try assigning the shortcut using the shortcut dialog to see how it differs from your manual shortcut edit?


trueBlue wrote: 15 Jan 2021, 13:09 ...
First of all you had a typo with the evetData
Node = evetData.Node;
Correct
Node = eventData.Node;
...
Sorry about that, must have posted an old version
Clinton Reese

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

Re: New NURBS tools

Post by trueBlue »

What I do first is fix the toolbar button commands and save the toolbars
Test to see that they work
Manually edit the shortcut file with the same commands
So far I have only tried two shortcuts +SDS & -SDS
So far with the previous way & the newer way, every time I test the modified shortcuts, the Spacebar shortcut (probably others) stop working!
I have been editing the shortcut file this way for several years without issues.
I have made a point NOT to use tS761's shortcut dialog because, number 1, it makes a mess of the file and 2, there is several toolbars with the same icons/buttons. My concern is, if I did it this way which would be very time consuming, there is the very possibility of failure!
The shortcut dialog captures the toolbar's Name, the Help text, and the context, and if this is different from the toolbar and toolbar button, the shortcuts do not work!
I suspect that this new way is not even using the script's CmdName string because it is always blank.
What is the Script Buffer?
RsApp.RunScriptBuffer(eventData.cmd);
User avatar
clintonman
Captain
Posts: 5428
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: 15 Jan 2021, 16:56 What I do first is fix the toolbar button commands and save the toolbars
Test to see that they work
Manually edit the shortcut file with the same commands
So far I have only tried two shortcuts +SDS & -SDS
So far with the previous way & the newer way, every time I test the modified shortcuts, the Spacebar shortcut (probably others) stop working!
I have been editing the shortcut file this way for several years without issues.
I have made a point NOT to use tS761's shortcut dialog because, number 1, it makes a mess of the file and 2, there is several toolbars with the same icons/buttons. My concern is, if I did it this way which would be very time consuming, there is the very possibility of failure!
The shortcut dialog captures the toolbar's Name, the Help text, and the context, and if this is different from the toolbar and toolbar button, the shortcuts do not work!
I suspect that this new way is not even using the script's CmdName string because it is always blank.
What is the Script Buffer?
RsApp.RunScriptBuffer(eventData.cmd);
I'm not suggesting you give up maually editing the shortcuts file, just saying do 1 shortcut via the dialog to see if there is a difference. If you see a difference then you can use that knowledge to manually edit the file.
Also watch out for single quotes vs double quotes.

A buffer is usually just a kind of temporary storage. So in this case the eventData.cmd is placed into the buffer and then run from there.
Clinton Reese

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

Re: New NURBS tools

Post by trueBlue »

Okay, I tried applying +SDS to the WORKSPACENAV toolbar

Code: Select all

<RS_ACC KEY="ADD" GROUP="WORKSPACENAV" CONTEXT="" DESC="+ SDS - Add SDS" COMMAND="obj={cmd:&quot;MeshModifiers.ChangeSSLevel(1)&quot;,RsApp:RsApp,Node:Node};RsApp.SendCustomEvent(&quot;Scripts/Commands/RestrictNURBS&quot;, obj);" />
The shortcut works for a 3D object and a NURBS but the NURBS was damaged from the +SDS
So I am at a loss here
I am guessing that the script is not running, that only the tS command is running.
How did you get success?
As said, I have success with this new way form a jScript, toolbar command, but not a shortcut

I have another idea
How do you turn this first part of the script shown below into an if else?
if(IsNURBS(Sel)) {
return;
}
If possible just and an Alert to the else part

Code: Select all

function Execute(params)
{
	// validate to avoid tS script selection bug
	if(!IsValidSelection(Node.Selection())) {
		return;
	}

	for (var i=0; i<Node.SelectedCount(); i++) {
		var Sel = Node.Selected(i);

		if(IsNURBS(Sel)) {
		return;
		}
	}

}

function IsValidSelection(selection)
{
	if(!selection) return false;

	var reWhiteSpace = /^\s/; // whitespace in first character position for cleaning selection text

	var selectionArray = selection.split(";");

	for(var i = 0; i < selectionArray.length; i++) {
		var selClean = selectionArray[i].replace(reWhiteSpace, "");

		if(!Node.Exists(selClean)) {
			return false;
		}
	}

	return true;
}

function IsNURBS(curNode)
{
	var nurbsNode = curNode;

	if(Node.ConExists(curNode, "Matrix"))
		nurbsNode = Node.Owner(curNode);

	if(Node.ConExists(nurbsNode, "isaCurve")) {
		return true;
	}

	if(Node.Exists(nurbsNode + "/CP to patch CP")) {
		return true;
	}

	return false

}

User avatar
clintonman
Captain
Posts: 5428
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: 15 Jan 2021, 13:09 ...
Also notice with this new way the CmdName never enters the Command
CmdName.png
Because the new way doesn't use it.
Clinton Reese

http://clintons3d.com
Post Reply