Notifications
Clear all

[Closed] (Rhetorical question) is it possible to define structure inside structure

the thread says all

34 Replies

Yes, you can.


struct info_struct
(
   struct obj_info(obj_name, obj_transform)
   new_var = "Variable"

   fn get_info obj =  
   (
      obj_data = obj_info obj.name obj.transform      
   )   

)


-- get the info on an object in the scene named "box01"
object_info = main_struct.get_info $box01


whatchu smokin on bro?

I don’t think it will work. Also nested structures is not what max would support accoring to me…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it can’t work

it’s what Autodesk answered me some years ago…

Can you make some structs via dot net when making a class library and pass data from max to the structs?

I have not used .NET much…

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

slow down… stop idolize .net
we are talking about maxscript.
do we always have to trust what Autodesk says?

Umm…I think we should sometimes when we get errors…
Probably you can refer to making nested structs in c++, which I do generally.

http://www.cplusplus.com/doc/tutorial/structures/

Is there any other solution?

I tried making structs and passing them to other structs, but the data type in struct is just a data.
if i do this:


global inner_Struct
struct inner_Struct (param1, param2)
struct outerStruct(inner_Struct, age, sex, location)

even if inner_Struct is a global variable, max takes it to be another parameter not a struct!!!

we are talking about mxs… pure maxscript

I don’t have max at home – but I would think this should work…


  -- struct def'ntions
  struct a ( aVar = "someinfo" )
   struct b ( bVar = undefined )
   
  -- instantiate struct a
   aStruct = a()
  
  -- instantiate struct b with struct a as a parameter. 
   bStruct = b aStruct
  
  print (bStruct.aStruct.aVar)
  
  
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

it might work, but this is not nested structure definition…

 lo1
struct a
(
	fn b =
	(
		struct c 
		(
			x
		)		
		
		c()
	),
	
	d = b()	
)

aa = a()
1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

this is not a definition. it’s the same as create a structure outside. the right definition is when all members of structure A can see and use structure C.

 lo1
struct a
(
	g,
	 
 	fn b =
 	(
 		g = struct c 
 		(
 			x
 		)		
 	),
 	
 	d = b(),
	
	h = g()
)
 
 aa = a()

?

Page 1 / 3