adding loop into parameters setting

I have a very simply script to adding point3 controller to attribute holder modifier. My task is that I need X number of zk´s and this X is selection.count number. But in parameters dont work any loop. So is there any possibility to adding new controler to def attributes in another solution?

I know that I need define somehow array zk´s of type point3 .. but I dont know exactly how. Or maybe my whole logic about this proble is wrong.

 def=attributes MonkFace
(
 
	parameters param
   (
	for i=1 to 3 do
        (
          zk[i] type:#point3
        )
   )
)
custAttributes.add $.modifiers[1] def 

Comments

Comment viewing options

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

Swordslayer (díky moc) thank

Swordslayer (díky moc) thank you very much. Is there your own forum ? :) because I think that from whole planet only you answered me on my "stupid" questions about maxscript:)

Ok i searched somethink about point3Tab in maxscript help but i dont fully understand how can I add controllers. And The next issue is, if I write my problem understandable. Because I saw somethink about UI´s on point3Tab .. and i dont mean controllers like spinner slider checkbutton etc. I mean, from my example, 3 separated point3 controllers in MonkFace group of parameters.

Finaly i need X these separated controllers. (attachment)

AttachmentSize
point3_controllers.jpg 31.07 KB
Swordslayer's picture

No forum, sorry about that :)

No forum, sorry about that :) Just blog, email, and possibly skype (see PM). As for the issue, if you need to store/link controllers, maybe more appropriate would be to store them as maxObjects, so maxObjectTab. For example with controllers that have subcontrollers for each point3 token, such as Position/Euler/Scale XYZ, something like this could be a way:

def = attributes controls attribID:#(0x27e2358f, 0x4e216b60)
(
	parameters main rollout:params
	(
		ctrlList type:#maxObjectTab tabSize:0 tabSizeVariable:true
 
		on ctrlList tabChanged change tabIndex tabCount do
			this.params.updateCtrlList()
	)
 
	rollout params "Parameters"
	(
		listBox lbxCtrlList "Controllers: " items:#() selection:0
		group "Coordinates"
		(
			spinner spnX "X: " type:#float range:[-1e9,1e9,0] align:#center enabled:false
			spinner spnY "Y: " type:#float range:[-1e9,1e9,0] align:#center enabled:false
			spinner spnZ "Z: " type:#float range:[-1e9,1e9,0] align:#center enabled:false
		)
 
		fn updateCtrlList =
			lbxCtrlList.items = for ctrl in ctrlList collect ctrl as string
 
		on params open do
			updateCtrlList()
 
		on lbxCtrlList selected item do
		(
			if item > 0 then
			(
				spnX.controller = ctrlList[item][1]
				spnY.controller = ctrlList[item][2]
				spnZ.controller = ctrlList[item][3]
				#(spnX, spnY, spnZ).enabled = true
			)
			else #(spnX, spnY, spnZ).enabled = false
		)
	)
)
Spawn_x's picture

I send you PM on maxarea

I send you PM on maxarea because i cant find pm here. Okay if I fully understand you script ... it store items in controls rollout is that right ? But I dond understand if I can store items via script or I need add them with (add/edit parameters window)

ok another way .. what I need exactly now is. If i select 5 object. And I write some script (I know that is bad). Result must be what i send in attachment in previous comment. Is that understadable ? Because I would like tu understand fundamentals why it work and why not. with your perfect proffesional script my mind is blowing and I cant catch the line:)

def=attributes MonkFace
(
 
	parameters param
(
	--there must be somethink what define my zk´s with slection.count
)
)
custAttributes.add $.modifiers[1] def
Swordslayer's picture

Probably still contains a few

Probably still contains a few bugs and unfinished parts:

def = attributes controls attribID:#(0x7abfad32, 0x13a070d0)
(
	parameters main rollout:params
	(
		nodeList type:#nodeTab tabSize:0 tabSizeVariable:true
		posList type:#point3Tab tabSize:0 tabSizeVariable:true
 
		on nodeList tabChanged change tabIndex tabCount do
			this.params.updateList positions:true
	)
 
	rollout params "Parameters"
	(
		multiListBox lbxNodeList "Objects: " items:#() selection:0
		button btnAdd "Add" width:50 across:3 offset:[6, -5]
		button btnAddMultiple "..." width:20 offset:[-3, -5]
		button btnRemove "Remove" width:60 offset:[-9, -5]
 
		button btnReset "Reset" width:60 across:2
		button btnSave "Save..." width:60
		button btnUpdate "Update" width:60 across:2
		button btnLoad "Load..." width:60
 
		fn updateList positions:false =
		(
			lbxNodeList.items = for obj in nodeList collect obj.name as string
			if positions do posList = for obj in nodeList collect obj.transform.pos
		)
 
		fn addSingleItem item:(pickObject()) =
			if item != undefined do
				appendIfUnique nodeList item
 
		fn addMultipleItems items:(selectByName title:"Select Multiple" buttonText:"Add") =
			for item in items do
				appendIfUnique nodeList item
 
		fn removeItems listUnselected:(-lbxNodeList.selection) =
			nodeList = for i in listUnselected collect nodeList[i]
 
		fn resetPositions =
			for i = 1 to nodeList.count do
				nodeList[i].pos = posList[i]
 
		fn savePositions fileName:(getSaveFilename types:"ms|*.ms") =
			if fileName != "" AND fileName != undefined do
			(
				local file = createFile fileName
				format "(\n\tlocal obj = modPanel.getCurrentObject()\n" to:file
				format "\tobj.nodeList = #()\n" to:file
 
				for i = 1 to nodeList.count do
					format "\tif isValidNode (local node = getAnimByHandle %) do (node.pos = %; append obj.nodeList node)\n" \
						(getHandleByAnim nodeList[i]) posList[i] to:file
 
				format ")\n" to:file
				close file
			)
 
		fn loadPositions fileName:(getOpenFilename types:"ms|*.ms") =
			if fileName != "" AND fileName != undefined do
				fileIn fileName
 
		on params open do updateList()
		on btnAdd pressed do addSingleItem()
		on btnAddMultiple pressed do addMultipleItems()
		on btnRemove pressed do removeItems()
		on btnReset pressed do resetPositions()
		on btnUpdate pressed do updateList positions:true
		on btnSave pressed do savePositions()
		on btnLoad pressed do loadPositions()
	)
)
Swordslayer's picture

Is there anything that would

Is there anything that would prevent you from using for example parameters param (points type:#point3Tab)?

Comment viewing options

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