[SOLVED] Load object via Jscript - how?

Smart people ~ Great Scripts
Post Reply
User avatar
Draise
Captain
Posts: 2810
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

[SOLVED] Load object via Jscript - how?

Post by Draise » 03 Jul 2014, 04:11

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())
}
Last edited by Draise on 03 Jul 2014, 04:21, edited 1 time in total.

User avatar
Draise
Captain
Posts: 2810
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: Load object via Jscript - how?

Post by Draise » 03 Jul 2014, 04:14

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?

User avatar
Draise
Captain
Posts: 2810
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

Re: Load object via Jscript - how?

Post by Draise » 03 Jul 2014, 04:20

Figured it out, no need for defining the main directory, just use the full absolute path.

Example:

Code: Select all

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

Shell1850
Chief Petty Officer
Posts: 135
Joined: 21 May 2009, 21:44

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

Post by Shell1850 » 29 Aug 2014, 17:00

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.

User avatar
Draise
Captain
Posts: 2810
Joined: 21 Sep 2009, 19:33
Type the number ten into the box: 0
Location: Bogota, Colombia
Contact:

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

Post by Draise » 29 Aug 2014, 17:47

Oh wow! I did not know. Do you have a working or feux example? I'd love to learn.

Shell1850
Chief Petty Officer
Posts: 135
Joined: 21 May 2009, 21:44

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

Post by Shell1850 » 29 Aug 2014, 18:33

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest