defining an array as a custom attribute

Ok, at the moment, I am trying to make an array as a custom attribute.. Only problem, I'm getting the following weird error:

-- Error occurred in anonymous codeblock; filename: J:\Dropbox\ICT312 (1)\scripts\entityAttribs.ms; position: 579; line: 30
-- Unable to convert: #() to type: String

for the following code:

newAttrib = attributes entityAttrib
(
	parameters posParam rollout:entParams
	(
		isStatic type:#boolean ui:isStatic checked:false
		castShadow type:#boolean ui:castShadow checked:false
		isChild type:#boolean
		childeren type:#()
	)
 
 
	rollout entParams "Entity Atributes"
	(
		checkbox isStatic "Static Entity"
		checkbox castShadow "Casts Shadows"
		edittext isChildTxt "is child" text:"no"
 
		on isChild changed do
		(
			if isChild == true then			
			(
				isChildTxt.text = "yes"
			)
			else
			(
				isChildTxt.text = "no"
			)
		)
	)
)
custAttributes.add $ newAttrib
--and then use >>
$.baseObject.entityAttrib.castShadow = on
$.baseObject.entityAttrib.isStatic = on
$.baseObject.entityAttrib.isChild = on
$.baseObject.entityAttrib.childeren = on	
isProperty $.baseObject #castShadow
isProperty $.baseObject #isStatic
isProperty $.baseObject #isChild
isProperty $.baseObject #childeren

if I follow tutorials on how to make an array inside of just any odd script, not inside of a custom paramater, i.e.

childeren = #()

I get the following error:

-- Error occurred in anonymous codeblock; filename: J:\Dropbox\ICT312 (1)\scripts\entityAttribs.ms; position: 231; line: 8
-- Syntax error: at =, expected name
--  In line: 		childeren = #

I know it's probably something silly.. But I can't for the life of me understand why my array isn't working inside of a parameters :(

Is there a proper way??

If anyone's curious, the reason why I need an array is because I'm holding children meshes inside of an array (needed for proper extraction of scene data for exporter)

Comments

Comment viewing options

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

Maybe this is not best solution

hlp = Dummy()
newAttrib = attributes entityAttrib
(
	local childerens = #("content1","content2","content3")
	parameters posParam rollout:entParams
	(
		isStatic type:#boolean ui:isStatic checked:false
		castShadow type:#boolean ui:castShadow checked:false
		isChild type:#boolean
	)
 
	rollout entParams "Entity Atributes"
	(
		checkbox isStatic "Static Entity"
		checkbox castShadow "Casts Shadows"
		edittext isChildTxt "is child" text:"no"
 
		on isChild changed do
		(
			if isChild == true then (isChildTxt.text = "yes")
			else (isChildTxt.text = "no")
		)
	)
)
custAttributes.add hlp newAttrib
format "childrensArr = %\n" (hlp.baseObject.entityAttrib.childrens)

bga

falconmick's picture

Ill try that in a second, but

Ill try that in a second, but I think I found a solution anyway:

		childeren type:#maxObjectTab

Right now my issue is that I need to get my script to deselect the current object, and then add the next selected item to the childerens list.. so far this is my script:

currentBody = $
 
deselect $
--if $ == undefined then
while $ == undefined do
(
--waiting for user to select object
)
 
if $ != currentBody then
(
append $.baseObject.entityAttrib.childeren $
outputdata.text = "body: %, added to childeren of %" $.name currentBody.name
)
else
(
outputdata.text = "you can't add yourself to your childerens list"
)

I thought scripts ran as a subroutine, aparently not.. as soon as it reaches the while loop 3ds max freezes =.= is there a better/proper way to get the user to select another object?

falconmick's picture

Who'da known, you can

Who'da known, you can multitask in ms after all, ok, so that's all handled, now I would love to know, how can I make a dynamicly sized maxObjectTab

I get the following error:

-- Error occurred in waitOnSelect(); filename: J:\Dropbox\ICT312 (1)\scripts\test2.ms; position: 250; line: 13
--  Frame:
--   outputdata: undefined
>> MAXScript dotNet event handler Exception:
-- Runtime error: Array parameter size fixed, cannot dynamically expand: childeren <<

the definition of the datatype is this:

childeren type:#maxObjectTab

and the error is caused by:

		currBody.baseObject.entityAttrib.childeren[currBody.baseObject.entityAttrib.childeren.count + 1] = $

Is there any dynamic types so I can add to somthing simular to maxObjectTab?

barigazy's picture

This is en excellent example

This is en excellent example by DenisT
This is the way how to solve the array problem

global nodeTabAttr = attributes nodeTabAttr attribID:#(0x1cabedab, 0x5551de47)
(
	parameters main rollout:main
	(
		nodes type:#nodeTab tabSize:0 tabSizeVariable:on
		on nodes tabChanged do
		(
			this.main.nodes_count.text = (nodes.count as string)
		)
	)
	rollout main "Nodes"
	(
		edittext nodes_count "Nodes Count: " text:"0" fieldwidth:40 readonly:on
		on main open do nodes_count.text = (this.nodes.count as string)
	)
)
delete objects
d = dummy name:"Node_Holder"
for k=1 to 10 do box()
 
custAttributes.add d nodeTabAttr baseobject:on
 
for obj in objects where obj != d do append d.nodes obj
select d
max modify mode

bga

Comment viewing options

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