PDA

View Full Version : How to URLEncode in maxscript?


OZRay
06-03-2011, 04:36 PM
Hi!

Is there a way to URLEncode with MaxScript ? Maybe with a DotNetObject? Or Class?
I need your help! :)

Thanks,

OZRay

Pjanssen
06-03-2011, 05:21 PM
You can use .net's HttpUtility.UrlEncode method.

http://stackoverflow.com/questions/575440/url-encoding-using-c

OZRay
06-03-2011, 05:30 PM
Hehehe I know that it's possible with .NET but can't figure out how to do it in maxscript hehehe !!

Regards,

OZRay

Pjanssen
06-04-2011, 09:00 AM
Well I suppose you can do something like this:
(
local httpUtility = dotnetClass "System.Web.HttpUtility"
local urlEncodedString = httpUtility.UrlEncode "theStringToEncode"
)

OZRay
06-04-2011, 01:03 PM
Thanks, I already tested this but the problem is any class that I try result in undefined...
I can't make it work...
encodeClass = dotnetClass "System.Web.HttpUtility"
encodeClass = dotnetClass "System.Web.HttpUtility.UrlEncode"
encodeClass = dotnetClass "System.Web"


Anything give me a undefined...
You know why?

Regards,

OZRay

Gravey
06-04-2011, 01:33 PM
Thanks, I already tested this but the problem is any class that I try result in undefined...try loading the System.Web assembly first. It's probably not loaded by default with max or something like that. dotnet.loadAssembly "System.Web"

Pjanssen
06-04-2011, 01:36 PM
Thanks, I already tested this but the problem is any class that I try result in undefined...
I can't make it work...
encodeClass = dotnetClass "System.Web.HttpUtility"
encodeClass = dotnetClass "System.Web.HttpUtility.UrlEncode"
encodeClass = dotnetClass "System.Web"It's probably caused by what Gravey mentioned, but just a small note: Of your three examples, only the first one is actually correct. The second is a method in the class HttpUtility, the third is a namespace.

OZRay
09-29-2011, 09:51 PM
It's working, for complete reference this is my function.

fn f_URLEncode _STR =
(
dotnet.loadassembly "System.Web"
local httpUtility = dotnetClass "System.Web.HttpUtility"
local urlEncodedString = httpUtility.UrlEncode _STR

return urlEncodedString
)
f_URLEncode "This! Is my %# URL *() Encode@@@"

return this: This!+Is+my+%25%23+URL+*()+Encode%40%40%40

Regards,

OZray

CGTalk Moderation
09-29-2011, 09:51 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.