Notifications
Clear all

[Closed] custom attributes question

Hi,

Im trying to write a script based on combining ideas of cellular automata and lamarkism.

What I am trying to do is create some boxes which are capable of storing ‘bits of code’ within their custom attributes, I would then like to be able to have a way of compiling the bits of code from various boxes to form an executable command.

That isnt very clear but i will try and give you an example of what i would like to do:

$box01.CA = ($.pos = [0,0,0])
$box02.CA = ($.scale = [50,50,50])

The idea would then be to get all the bits of code and make box01 and box02 move to position [0,0,0] and scale down to 50% of their original size.

Is it possible to do something like this with custom attributes? Also is it possible to store functions, strings or arrays in custom attributes?

Any help anyone could give me would be great!!

Cheers

6 Replies
 PEN

Well in Max script it is easy but I don’t know if that is what you are looking for.


 def=attributes test
 (
 
 )
 custAttributes.add $ def
 
 

That will apply the attribute definition to the base of the selected object.

 PEN

Yes…yes and umm, yes. Do you need to know more?

How do you store functions in custom attributes?

I have tried doing something like this but i cant find what code i need to write in some places?!:

 
boxdata = attributes boxdata 
(
parameters main rollout:params
	 (
	 state type:# < something here??!>
	 )
	 rollout params "Box State"
		 (
		 < and something here?>
		 ) 
custattributes.add allboxes boxdata #unique
)

I know this is pretty vague but basically i just want to store functions within some boxes in a scene which i can then access.

Any ideas??

 PEN

 def=attributes test
 (
    fn testFn=(print #yup)
 )
 b=box()
 custAttributes.add b def
 
 b.test.testFn()
 

Thanks, I think that solves my problem! I assume if i have a function with variables i will be able to something like:

b.test.testFn variable01 variable02

Thanks again.

1 Reply
 PEN
(@pen)
Joined: 11 months ago

Posts: 0

Yep, works like any other function.