Dotnet can't access #userScripts or #userMacros

Dotnet can't access #userScripts or #userMacros

TurboChiken
Contributor Contributor
832 Views
3 Replies
Message 1 of 4

Dotnet can't access #userScripts or #userMacros

TurboChiken
Contributor
Contributor

Years ago I wrote a script that was saved in the max installation folder, but now I'm trying to do things properly and move it to the #userscripts folder. Unfortunately every time I use (dotNetClass "System.Drawing.Image").fromFile to load a bitmap image from #userScripts or #userMacros, it kicks an exception. Can anyone confirm this is an issue, and is there a reasonable workaround? Thanks.

0 Likes
Accepted solutions (1)
833 Views
3 Replies
Replies (3)
Message 2 of 4

shawnolson
Autodesk
Autodesk

Can you post the full line you are using (including the string you are passing to the FromFile() method)?

0 Likes
Message 3 of 4

shawnolson
Autodesk
Autodesk
Accepted solution

You could always wrap your path with pathConfig.convertPathToAbsolute() as in this example:

 

(dotNetClass "System.Drawing.Image").fromFile (pathConfig.convertPathToAbsolute "$maps\uv-grid.png")
0 Likes
Message 4 of 4

TurboChiken
Contributor
Contributor

Hi, Shawn, sorry for the late reply (crunching for deadlines... sigh)

 

Your suggestion worked! For some reason, if I used this:

(dotNetClass "System.Drawing.Image").fromFile "$userMacros\\testimage.tif"

 

I would get the error in the listener, "Runtime error: .NET runtime exception: $userMacros\testimage.tif". But when I wrapped it as you suggested, it works fine. Not sure what's up with that, but thank you.

0 Likes