Yafaray4tS v0.9.0

LightWorks, VRay, Dribble, YafaRay and more..
User avatar
clintonman
Captain
Posts: 5428
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Yafaray4tS v0.9.0

Post by clintonman »

trueBlue wrote: 08 Aug 2018, 16:44
clintonman wrote: 08 Aug 2018, 02:50
trueBlue wrote: 08 Aug 2018, 01:34 YafaRay4tS Scene Utilities
Steps
Remove YafaRay4tS from scene
Select the Process Imported Scene button
Alert "Scene does not contain a YafaRay4tS node"
I get an error.
...
I have now idea where you're going with this. The code is written to update a scene that has a yafaray4ts node. It's like running it on a vray scene then declaring it doesn't work? :? 100% lost here.
Wow, this is a bubble buster! :(
I asked you a few months back how I could help you test your project.
Your reply was to use it and try and break it.
I have reported this broad issue to your several times and it is a pretty big deal if you do not know how to recoup from it.
You recently confirmed you were able to confirm this issue with the scene that I shared with you and supplied a fix in your Integrated Offline Render icons.

Yesterday I reported that it was not entirely fixed but there was indeed a workaround.

I was pretty stoked finding and sharing, what looks like, a solid fix and perhaps a better way to write if statements.!

I am pretty sure that the author of that script is Vladimir, who was one of the longest core developers of trueSpace and the iOptDetectors plugin.
That script is pretty simple and he uses the params.SetTerminationFlag() at the beginning of his if statements.
To be honest with you, I do not know what it does or how it works. I was hoping you had a better understanding of its use.

So to answer your question, I was simply sharing that script with you and hoping that it helps.
As always I respect your expertise and look for your approval! :)
Fair enough. I just don't see the use case where someone would delete the node and then try to convert data from the missing node. It's like if the user went into the link editor and removed some of the nodes in YafaRay4tS Scene Utilities, that would break it too. What specifically is the broad issue you are referring to that you've been talking about? and you are saying that the params.SetTerminationFlag() may fix it?
params.SetTerminationFlag(); is an interesting find along with all the other params dot functions. I have no idea what they do. Here's the confusion in the code you provided:

Code: Select all

try {
   tryStatements}
catch(exception){
   catchStatements}
finally {
   finallyStatements}
 
from the docs
tryStatements
Required. Statements where an error can occur.
exception
Required. Any variable name. The initial value of exception is the value of the thrown error.
catchStatements
Optional. Statements to handle errors occurring in the associated tryStatements.
finallyStatements
Optional. Statements that are unconditionally executed after all other error processing has occurred.

The code that can break goes into the try section, your sample has nothing in the try so the catch will never do anything unless that params.SetTerminationFlag is doing something magical.

I'll add your changes and test it. It may be a case of truespace holding something in memory again where you making a coding change and the old values are still having an effect.
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: Yafaray4tS v0.9.0

Post by trueBlue »

Broad meaning if statements that are not being honored or throw errors. Like empty string errors.
Also several different instances where the error stops the execution of the script.
Looking back at the pics of the errors posted the common one are where the Exporting XML file is being stopped.
Or the access YafarayXMLFileFnSet which gives you no clue. This is with old scenes and new scenes.

Again I am not saying that my code is correct.
Just a test or experiment if you will.
And yes I deliberately removed the YafaRay4tS node from the scene and renamed the YafaRay Folder to test it.
If an if statement has a break and it does not stop or handle the error and or allows the script to continue, there is something wrong with that if statement.

I have been searching for a definition of the SetTerminationFlag() but so far no go.
Here is another definition of Throw and Try to Catch Errors

The try statement lets you test a block of code for errors.
The catch statement lets you handle the error.
The throw statement lets you create custom errors.
The finally statement lets you execute code, after try and catch, regardless of the result.

https://www.w3schools.com/js/js_errors.asp
User avatar
clintonman
Captain
Posts: 5428
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Yafaray4tS v0.9.0

Post by clintonman »

Well I guess the bottom line is that only specific, repeatable errors can be fixed. If I have errors and you never see them you'll have a hard time trying to fix them. One of the errors you had I never saw until after you shared a scene file, the kitchen scene which was included with all those other scenes. That one would still be giving errors if you hadn't shared the scene. Gotta have samples and steps to recreate errors, otherwise it's hit and miss.
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: Yafaray4tS v0.9.0

Post by trueBlue »

Agreed I have not been a very good beta tester, still learning.
My thought is that the SetTerminationFlag is an Important/Mandatory part of the script that actualy kills the process.
User avatar
clintonman
Captain
Posts: 5428
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Yafaray4tS v0.9.0

Post by clintonman »

trueBlue wrote: 08 Aug 2018, 01:34 YafaRay4tS Scene Utilities
Steps
Remove YafaRay4tS from scene
Select the Process Imported Scene button
Alert "Scene does not contain a YafaRay4tS node"
I get an error.

Update YafaRay Render Node2 script:
First I tried incorporating a try/catch/error
That did not work

I think, I found a solution to this problem that I found in the Interactive Replace Tool.RsObj in the Activities - My Activities library.
Author sets a params.SetTerminationFlag();

Fix:
...

I tried the above immediately after getting an error and so far it is working.
The params.SetTerminationFlag(); and the try/catch/error is need in both blocks of code.
I tested with and without and both are needed.
Your thoughts?
SetTerminationFlag.jpg
Here is what I found.
The try catches don't do anything and I don't know why it made a difference for you. Makes me think you need to restart the computer before testing further. Truespace will keep thinks in memory and mess you up, I've lost hours because of that in the past. If it misbehaves for no reason - restart.
"I get an error" - The error comes from the Process Textures script which is inline after the Update YafaRay Render Node2
The params.SetTerminationFlag() seems to stop downstream connected scripts from running - super useful! :bananathumb:
Clinton Reese

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

Re: Yafaray4tS v0.9.0

Post by clintonman »

trueBlue wrote: 08 Aug 2018, 20:48 ...
My thought is that the SetTerminationFlag is an Important/Mandatory part of the script that actualy kills the process.
Close - see the previous cross post. Experiment shows it stops the trailing scripts from running.
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: Yafaray4tS v0.9.0

Post by trueBlue »

Okay I get the reboot tS and PC, makes a lot of sense. :)
Sincere apology for the wasted hours!!!

Not sure I am following your test. I misled you in my post. I used the modified code in the other Update YafaRay Render Node.RsObj to test.
"I get an error" - The error comes from the Process Textures script which is inline after the Update YafaRay Render Node2
The params.SetTerminationFlag() seems to stop downstream connected scripts from running - super useful!
If the params.SetTerminationFlag() stops the downstream connected scripts from running, why did you get an error?
Not so sure your theory is correct about stopping connected scripts. If you look at that script in the Interactive Replace Tool at the bottom there is params.Param("lastSelectedObject") in with which lastSelectedObject is an Output. Seems to me that if the script ran without errors then there would be success verses failure at the Termination Flag. If there was success then and only then would a chained script fire. Nevertheless this is all an assumption on my part.
You know best, so whatever works correctly, works for me. Let me know how to use it properly.

Testing your new Camera modifications.
Looks like all of the old attributes in the Cam Name script are no longer needed.
As a TEST, I selected a Yafaray Camera and pressed the Set Camera button.
Works and renders as expected.
I rename the Yafaray Camera to Camera without setting it up in the UI.
I get the Errors Found message and it renders the scene. <- The message is misleading with regards invalid selection in this scenario.
All is good except you are not setting the Output - Render File to View.
Thinking this might be a problem with imported scenes too if you do not make the switch!!!

Also made some changes for a future RC-26 candidate:
RC-26
Replaced YafaRay4tS.RsScn

YafarayScripts
Changed Intergrated Buttons to version to 5
Changed Console and Alert messages
Object Render (experimental mode) Added (HideALL/Show Selected) and (ShowALL after render)

Installer does not show YafaRay4tS Setup. Could be because I had Vray loaded.

YafaRay4tS Setup library - Fixed D3D Preview Background objects icons and descriptions

YafaRay4tS Scene Utilities.RsObj
Add - WindowsManager.ActivateFrame(1); to the Browse button
Add - try/catch code from the Camera script to Lights, Update YafaRay Render Node2, and Update YafaRay Render Node2 scripts

Code: Select all

	try {
		utilitydata = System.CreateDO("Clintons3D Package/Utility functions");
	} catch(err) {
		System.Alert("Requires Clintons3dPlugin.rsx plugin");
		return;
	}
	currentnode = Source;
	thedata = utilitydata.GetConnectorData(currentnode);
	connectors = thedata.split("\n");
	for(var i=0;i<connectors.length;i++) {

		connector = connectors[i].split("\t");

		if(connector[3] & CONFLG_IN && !(connector[3] & CONFLG_HIDDEN)) {
			if(Node.ConExists(Destination, connector[0])) {
				if(connector[0] == "Yaf_Path") {
					continue;
				} else {
					Node.Value(Destination, connector[0]) = Node.Value(Source, connector[0]);
					System.Trace(connector[0]);
				}
			}
		}
	}
User avatar
clintonman
Captain
Posts: 5428
Joined: 21 May 2009, 21:08
Type the number ten into the box: 0
Location: California
Contact:

Re: Yafaray4tS v0.9.0

Post by clintonman »

trueBlue wrote: 08 Aug 2018, 21:52 ...
If the params.SetTerminationFlag() stops the downstream connected scripts from running, why did you get an error?
...
Without the fix:
1. new scene - so no YafaRay4tS node
2. run and get message "Scene does not contain a YafaRay4tS node" then get an error on line 19 of Process Textures
line 19 of Process Textures error because trying to read value from non-existent YafaRay4tS node

Code: Select all

var filename = Node.Value(Space.CurrentScene() + "/YafaRay4tS", "Yaf_BkgImage");
With fix only get the message "Scene does not contain a YafaRay4tS node".
Process Textures never runs so don't get the error
Clinton Reese

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

Re: Yafaray4tS v0.9.0

Post by clintonman »

trueBlue wrote: 08 Aug 2018, 21:52 ...
Not so sure your theory is correct about stopping connected scripts. If you look at that script in the Interactive Replace Tool at the bottom there is params.Param("lastSelectedObject") in with which lastSelectedObject is an Output. Seems to me that if the script ran without errors then there would be success verses failure at the Termination Flag. If there was success then and only then would a chained script fire. Nevertheless this is all an assumption on my part.
...
I don't think the params.SetTerminationFlag(); does anything in that script. It still works if the line isn't there. My guess is either the SetTerminationFlag behavior changed after he wrote the script or the script was used with some down stream functionality that was removed.
Clinton Reese

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

Re: Yafaray4tS v0.9.0

Post by clintonman »

trueBlue wrote: 08 Aug 2018, 21:52 ...

Testing your new Camera modifications.
Looks like all of the old attributes in the Cam Name script are no longer needed.
As a TEST, I selected a Yafaray Camera and pressed the Set Camera button.
Works and renders as expected.
I rename the Yafaray Camera to Camera without setting it up in the UI.
I get the Errors Found message and it renders the scene. <- The message is misleading with regards invalid selection in this scenario.
...
What is the Errors Found message?
If the camera in the YafaRay4tS node is invalid it will give a message and then search the scene for a camera and use it. If it finds no camera at all it uses the 3D view and if it still fails it gives some other error and probably fails to render.
Clinton Reese

http://clintons3d.com
Post Reply