PDA

View Full Version : Setting Relative Paths Using an LScript



vfxaaron
04-16-2009, 11:50 AM
Is there any command to set relative content directories such as "Scenes, Hierarchies, Objects, Images, etc"? I've found the command for setting the content directory, which is "ContentDirectory \\PathToProject", but I can't find any way outside of the interface for setting the relatives paths beneath this.

The goal is to create a tool which will allow artists in a production environment to select from a list of projects, which will activate the project as the Content Directory and parse from a file what the relative paths should be set to for that project.

I'm very new to LScript, so I'm not even sure where to begin. Do these paths exist as environment variables? An example of how the config file stores these values is, "DirectoryType Scenes \\Full_Path", but "DirectoryType" does not exist as a command within Layout.

Any suggestions?

vfxaaron
04-16-2009, 03:59 PM
This is what I've got so far for setting the Content Directory. Works pretty well if every project is set up exactly the same, but I'd still like to be able to automate changing all the relative paths.


generic
{
oldCD = getdir(CONTENTDIR);
chdir("\\\\Server\\Share\\Projects");
file = File("_ProjectList.txt","r");
chdir(oldCD);
if(file == nil)
{
info("Could not find project list file.");
return;
}
index = 1;
while(!file.eof())
{
projects[index] = file.read();
index ++;
}

reqbegin("Select A Project");
c0 = ctlpopup("Active Projects:",1,projects);
return if !reqpost();
newCdIndex = getvalue(c0);
reqend();

info("Setting Content Directory: " + projects[newCdIndex]);
ContentDirectory(projects[newCdIndex]);
}

faulknermano
04-17-2009, 07:22 AM
My suggestion is a workaround, since, afaik, there are no commands for what you want to do.

The relative paths are taken from the LW9.cfg file. I suggest making a duplicate of this config file, make a folder that's specific to the project, and then modify the config file as you like. Then run another LightWave process but this time with the configuration flag pointed to the project config folder and kill the current LightWave session that called the script.

So in the script, here are the main actions:
1. Copy LW9.cfg to ..\CONFIG_Project1\LW9.cfg
2. Parse and modify CONFIG_Project1\LW9.cfg; change relative paths
3. Run "lightwav.exe -cC:\LightWave\CONFIG_Project1\". Of course any other lightwav.exe flags you might be using should be appended here as well.
4. Quit the current LW session (e.g. CommandInput("Quit"))

Of course, when the script starts there could be a requester asking for which project is to be used, which dictates the values inputted in step # 2.

faulknermano
04-17-2009, 07:24 AM
To run a process you can use spawn(), or system(), but spawn() is recommended for applications (which system() is usually used for commands).

To copy files, use filecopy(origfile,newfile).

vfxaaron
04-21-2009, 03:32 PM
Thanks for the help. This is working pretty well now.

However, since all of the artists have their own personal configs set up, I need a way to query what config path was used when Lightwave was started. That way, the individual artist's config file can be copied & parsed.

Is this possible? Or will I have to write a bit of interface to allow the artist to point to their own configs?

Thanks.

faulknermano
04-21-2009, 07:38 PM
Yes, I believe the function to that is:


getdir("Settings");

Do you have Mike Green's LScript docs? They're arranged in a very convenient way to search for certain commands (granted you know the commands to look for :) )

http://www.mikegreen.name/Lscripts.html#Lscript