Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Softimage® / XSI SDK / How do I get the 'self' file path?
  RSS 2.0 ATOM  

How do I get the 'self' file path?
Rate this thread
 
30098
 
Permlink of this thread  
avatar
  • saajjj
  • Posted: 11 September 2008 08:24 AM
  • Total Posts: 161
  • Joined: 10 June 2008 12:38 PM

Hello,
Apologies for the ambiguous title. I’m trying to set the siUIKeywordFile attribute for a text editor widget. The following works fine:

var JScriptKeywordPath "C:\\syntaxHighlight\\jscript.keywords";

However what I want is to set a relative path. edit: (or get the full path of the file executing the code)
I have a couple of ideas in my head but ‘Googling’ hasn’t helped much:

1. Is there a way to get the path of the current file? Since everything is under an Addon folder, I can just build the path if I can get the path of my current js file. I know about [B]Scripting.fileSystemObject[/B] and the [B]getFile(ref)[/B]/[B]getAbsolutePathName(ref)[/B] method but I can’t figure out how to set [B]ref[/B] to the file itself (without using an absolute path)

2. I tried using [B]Application.InstallationPath(siWorkgroupAddonPath)[/B] but that returns the path to the top-most workgroup. I can’t expect people to put my addon right at the top.

3. The SDK desn’t specify whether an absolute path is required for siUIKeywordFile. If not, the easiest way would, of course, be to have the ability to use relative paths. I tried ..\\syntaxHig… it doesn’t work, tried many other combination but none of them worked. Which leads me to believe that relative paths are not supported.

Any help appreciated :)

Cheers,



Replies: 0
avatar

Can you package everything as an addon?
Then you use the addon location.



Replies: 0
avatar
  • saajjj
  • Posted: 11 September 2008 09:25 AM

My directory structure is as in the image attached.
I’m assuming this means I’m already in the MyTools Addon. However when I call, InstallationPath(siAddonPath) from the scriptEditor plug-in it returns:
C:\Softimage\XSI_7.0\Addons

if I use InstallationPath(siAddonPath) I get:
C:\Users\saj\Documents\XSITools\Addons <-- this is correct

But, if I add another workgroup above XSITools then
InstallationPath(siAddonPath) returns the path to that new workgroup.

Is there some attribute I need to set within the plugin file which sets the path to the right workgroup?

Thanks.



Attachment Attachment
Replies: 0
avatar
  • saajjj
  • Posted: 11 September 2008 09:32 AM

Ah managed to solive it :) I used:
var oFn = Application.Plugins("scriptEditor").FileName;

This returns the complete path to the current file. Simple string operations and I’ll be good to access my keyword file. Since you pointed to the SDK workgroup example in another thread, I’ve been using it feverishly to make my ends meet.

Thanks again.

off Topic: Could it be possible to configure the forum so that the thread starter can edit the thread title or attach a prefix like ‘resolved’?



Replies: 0
avatar

Maybe you could of used Plugin.OriginPath?



Replies: 0
avatar
  • saajjj
  • Posted: 11 September 2008 08:44 PM

That works slightly better, thanks.



Replies: 0