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
falconmick's picture

How in gods earth do you find

How in gods earth do you find these things.. I search for hours...

I'll check out in full in the morning.. 3am isn't best time to script

barigazy's picture

The basic rule: only that you

The basic rule:
only that you need is to know what do you want and place where to find.:)
Hope this help.
Cheers man!

bga

barigazy's picture

At the end of code you

At the end of code you probable noticed the line "max modify mode".
This is important because by switchin command panel to modfy mode
you create CA rollout and thus avoiding errors

bga

falconmick's picture

I hate to ask stupid

I hate to ask stupid questions, but you can probably tell, that I aint really all that familiar with MaxScript.. Is there anyway I can intigrate an array into this function

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:#nodeTab
 
	)
 
 
	rollout entParams "Entity Atributes"
	(
		checkbox isStatic "Static Entity"
		checkbox castShadow "Casts Shadows"
		edittext isChildTxt "is child" text:"no" readOnly:true
		button selectChilderen "add child" across:1
		--on selectChilderen pressed do
		--(
			--deselect $
			--if
		--)
	)
)
custAttributes.add $ newAttrib
--and then use >>
$.baseObject.entityAttrib.castShadow = on
$.baseObject.entityAttrib.isStatic = on
$.baseObject.entityAttrib.isChild = false
$.baseObject.entityAttrib.childeren	
isProperty $.baseObject #castShadow
isProperty $.baseObject #isStatic
isProperty $.baseObject #isChild
isProperty $.baseObject #childeren

I' just really not confident with the language as a whole and I understand how that code words and I feer translating my code into that other structure will cause more and more stupid little problems Ide know how to fix if I knew the language better. And I would learn the language better, but by the looks of it it's an experience language, meaning u learn from eperience.. Unfortunately I don't have 4 weeks to learn.

It sounds like I am being lazy here and just not doing the hard hours.. But trust me, I am doing the hard hours.. I am in final year uni with 2 other units all demanding all my time.

barigazy's picture

If I understand you correctly

If I understand you correctly you want when press button "add child"
to collect all children nodes of current selection and store it in
"children" array.Right?

bga

falconmick's picture

yes correct, then my exporter

yes correct, then my exporter would make it a node inside of itself, here's an example of our XML structure.

<root>
  <static>
    <name> Box001 </name>
    <position>
		<x> -6.34422 </x>
		<y> 0.0 </y>
		<z> -0.827736 </z>
	</position>
	<rotation>
		<x> 0.0 </x>
		<y> 0.0 </y>
		<z> 0.0 </z>
	</rotation>
	<scale>
		<x> 1.0 </x>
		<y> 1.0 </y>
		<z> 1.0 </z>
	</scale>
    <castShadow> true </castShadow>
      <static>
        <name> Box002 </name>
        <position>
			<x> -6.34422 </x>
			<y> 0.0 </y>
			<z> -0.827736 </z>
		</position>
		<rotation>
			<x> 0.0 </x>
			<y> 0.0 </y>
			<z> 0.0 </z>
		</rotation>
		<scale>
			<x> 1.0 </x>
			<y> 1.0 </y>
			<z> 1.0 </z>
		</scale>
        <castShadow> true </castShadow>
      </static>
  </static>
 
</root>

box02 in this case is a child of box01

don't worry about my ability to export the XML, it's already up and running, all I'm doing now is adding all the attributes for it to export

barigazy's picture

Here we go now you can

Here we go
now you can collect all children nodes of current selection and store it in children array.
Press the button and look what Listener throw

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:#nodeTab tabSize:0 tabSizeVariable:on
 
	)
	rollout entParams "Entity Atributes"
	(
		checkbox isStatic "Static Entity"
		checkbox castShadow "Casts Shadows"
		edittext isChildTxt "is child" text:"no" readOnly:true
		button selectChilderen "add child" across:1
		on selectChilderen pressed do
		(
			local thisObj = (refs.dependents (custAttributes.getOwner this))[1]
			this.childeren = for c in 1 to thisObj.children.count collect thisObj.children[c]
				format "chi = %\n" this.childeren
		)
	)
)
custAttributes.add $ newAttrib

bga

falconmick's picture

would you be able to break

would you be able to break down this:

local thisObj = (refs.dependents (custAttributes.getOwner this))[1]
this.childeren = for c in 1 to thisObj.children.count collect thisObj.children[c]

I think I understand it, the first line finds the item which this rollout is attached to, the next one itterates through all the elements inside of the childeren array...

one problem...

my code doesn't seem to be working :( again :(

global currBody
 
fn waitOnSelect =
(
	while $ == undefined do
	(
		--waiting for user to select object
	)
 
 
	if $ != currBody then
	(
		--currBody.baseObject.entityAttrib.childeren[currBody.baseObject.entityAttrib.childeren.count + 1] = $
 
		append currBody.baseObject.entityAttrib.childeren $
		format (currBody.baseObject.entityAttrib.childeren[1].name as string)
 
	)
	else
	(
		format  "you can't add yourself to your childerens list\n"
	)
 
)
 
rollout main "tester"
(
	label testOutput "test output:"
	editText outputdata height:100
	button testBut "test code" across:1
	on testBut pressed do
	(
		currBody = $
		deselect $
		MainThread = dotnetobject "CSharpUtilities.SynchronizingBackgroundWorker"
		dotNet.addEventHandler MainThread "DoWork" waitOnSelect
		MainThread.RunWorkerAsync()
	)
)
 
MoCapFloater = newRolloutFloater "Test executer" 500 188 100 100
 
addRollout Main MoCapFloater

neither

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

or

append currBody.baseObject.entityAttrib.childeren $

add it to the childerens array :( any help?

Sorry for heaps of questions.. just this is kinda vital and I have no where near enought max experience

barigazy's picture

Aha, i see that. You're an

Aha, i see that. You're an inexperienced user who know all about Beckground Worker, XML and when construct. tell me about it :)
I know somethig about BGWorker and XML but i never use before when construct.
You need to explaine what do you want to achive now?
If you need to append picked object in "children array" try to use pickbutton.Then you don't need other advanced fn

bga

Comment viewing options

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