How to apply a .Net method to 3dsMax

IList propertyNames = TheJObject.Properties().Select(p => p.Name).ToList();

this is the code in .net i'm trying to use JSON library. Everything is fine but i can not handle "p => p.Name" part, what is it, how does it work and how can i change it to maxscript? I need it to be able to create a loop.

Thanks in advance.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Mambo4's picture

Sekopasa, any progress?

I am currently looking at JSON.NET in max script as well
And I'm pretty much at the same point you were in this post

barigazy's picture

Hey Mambo4, i not try jet

Hey Mambo4,
i not try jet JSON.NET. Tell me what is the adventage ei. purpose of json.net in combination with mxs.
Cheers!

bga

Mambo4's picture

I'm writing MAX export tools

I'm writing MAX export tools for a game engine that uses JSON to load its assets.

functionally JSON does the same thing as XML, which I guess most Max tools utilize.
but it's less verbose and slightly smaller in file size.
my background is manipulating JSON with MAYA/PYTHON, so I like it better.

Jsont.net is simply the first library I found for using json in dot net. It looks powerful, but getting it to cooperate with mxs is a challenge.

barigazy's picture

Cool. Thanks for the

Cool. Thanks for the explanation.

bga

sekopasa's picture

-

Ok the project is recreating Daz Studio materials in 3dsmax/Vray at least getting the texturemaps connected to materials.

Daz Studio exports a DSF file which is a JSON file defining the materials. I achieved to get the file into 3dsmax i can reach the values by keynames.

But i realised that i would need loops in some cases. JObject has a count value but you can not reach the values like an array. I was looking for how to create a loop, i thought if i had the property names in an array i would create my own loop.

So i found this thread.

http://json.codeplex.com/discussions/231381

this is what i get with showproperties

 .Count : <System.Int32>, read-only

  .EqualityComparer : <Newtonsoft.Json.Linq.JTokenEqualityComparer>, read-only, static

  .First : <Newtonsoft.Json.Linq.JToken>, read-only

  .HasValues : <System.Boolean>, read-only

  .Item[<System.String>propertyName] : <Newtonsoft.Json.Linq.JToken>

  .Item[<System.Object>key] : <Newtonsoft.Json.Linq.JToken>

  .Last : <Newtonsoft.Json.Linq.JToken>, read-only

  .Next : <Newtonsoft.Json.Linq.JToken>

  .Parent : <Newtonsoft.Json.Linq.JContainer>

  .Previous : <Newtonsoft.Json.Linq.JToken>

  .Root : <Newtonsoft.Json.Linq.JToken>, read-only

  .Type : <Newtonsoft.Json.Linq.JTokenType>, read-only

(by the way getPropNames is not working)

I can send the code but there is nothing fancy in it. Maybe i can upload a dsf file somewhere if you like to see. You can open it with text editor.

 

barigazy's picture

Yep, you can attach *.dsf

Yep, you can attach *.dsf below. This is interesting.
I know a little dotnet+mxs integration but JSON is not my specialty.
I have a few questions:
#1] Tell me, you use showproperties for what?
#2] If I understand correctly what you need is to convert DAZ material to VRayMtl.Right?
#3] I try something like this

ss = stringstream ""
showproperties $ to:ss
str = ss as string
arr = filterstring str " : "
for i = 1 to arr.count where mod i 2 != 0 collect arr[i] 
--#(".smooth", ".radius", ".segs", ".mapcoords", ".slice", ".hemisphere", ".sliceFrom", ".sliceTo", ".chop", ".recenter", ".realWorldMapSize")

bga

sekopasa's picture

#1 Just to see which

#1 Just to see which properties i can call
#2 Exactly.
#3 This is not what i actualy need but i didnt know that i could use "to" to store the printed values.

t1 - t3 is the most basic form of a material but for example in t5 its different. There is a "extra" slot and all the material is stored in that slot.

But i will give you a example, after i get the dsf file into a Jobject i can reach the values like below. What i need is to get the keys(strings) needed to call the values.

print o.item["scene"].item["materials"].item[0].item["type"].value

AttachmentSize
material_files.rar 10.09 KB
barigazy's picture

This is not easy task. If

This is not easy task. If other members can't solve this i suggest you to post this topic on CGTalk forum
http://forums.cgsociety.org/forumdisplay.php?f=6

bga

sekopasa's picture

Ok, thank you for trying. At

Ok, thank you for trying. At least i learned something from you.

barigazy's picture

you can simply

you can simply use

getPropNames $

or explain what you want to collect,

bga

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.