Page 1 of 1

[SOLVED] Load object via Jscript - how?

Posted: 03 Jul 2014, 04:11
by Draise
From THIS thread
trueBlue wrote:Here is an example button that loads an RsObj from a Library.
This assumes that the object and path exist and is correct. Note: I went by your screen capture.

Code: Select all

RsFileIO.LoadObject(System.GetMainDir() + '\\Rs Main Libraries\\O. Tools\\tS761 Bevel - Extrude.RsObj', Space.CurrentScene())

Just revisiting this. As.. I need to delete and load whole light systems for my pass management.

Question: How can I load an object via Jscript to import an *.rsobj?


I tried the code below, which will delete, but then it won't load. Any pointers?

Code: Select all

function Execute(params)
{
	Node.Delete(Space.CurrentScene() + "/Sky")
	RsFileIO.LoadObject(System.GetMainDir() + "\\Colombian Personal Meme\\Obj - Sky\\Sky.RsObj", Space.CurrentScene())
}

Re: Load object via Jscript - how?

Posted: 03 Jul 2014, 04:14
by Draise
Wait, I just need it to go search for it in the harddrive - not in the main trueSpace directory.

How do I make it do that?

Re: Load object via Jscript - how?

Posted: 03 Jul 2014, 04:20
by Draise
Figured it out, no need for defining the main directory, just use the full absolute path.

Example:

Code: Select all

"D://folder//subfolder//item"

Re: [SOLVED] Load object via Jscript - how?

Posted: 29 Aug 2014, 17:00
by Shell1850
Did you know you can use the StripPath command to get a working directory.

params.ConValue('WorkingDirectory') = StripPath(TFile);

I use a OpenFile Control on the brick to select any file in my working directory.

Re: [SOLVED] Load object via Jscript - how?

Posted: 29 Aug 2014, 17:47
by Draise
Oh wow! I did not know. Do you have a working or feux example? I'd love to learn.

Re: [SOLVED] Load object via Jscript - how?

Posted: 29 Aug 2014, 18:33
by Shell1850
Did you see my last Train Simulator program. It works with a function set. It started simple as a simple program but became complex. it uses a text file to describe the different cars on the train, and converts the track description file (my pride and joy) into a list of track and radius.