Notifications
Clear all

[Closed] Instancing costom attributes to penn attribute holder

 PEN

You can instance them there as well, works great and is probably faster then wires. It was just a habit to write it that way.

Glad that you have it working, I can鈥檛 wait to see the final results.

ok script is working fine but now i have a verable that wont run.

i am using a basic toolbar to feed it values but when i run it it errors out.

here is where the problem lyes when i鈥檓 trying to feed a spinner to a string

鈥搝Param=(spn1.value)
鈥搙Param=(spn2.value)鈥搕his is what i want to work

when i try to use this and it calutales the string i get a message saying 鈥渦nable to convert: 1 to Type: string鈥?where 1 is the value on the interface spinner and is suposed to repersent the contoller number.

of course if i do this it works fine

xParam=鈥?鈥?br>
zParam=鈥?鈥?/p>

all i can work out is that it doesnt like beening feed numbers into a string surly there is a way around this like 鈥減rint spn1.value鈥?or somthing. i have evne tried
xParam= execute 鈥渟pn2.value鈥?/p>

here is the code

macroscript instance_controller
	category:"john Scripts"
(


		
	rollout johnboy "Face j rigg tools" 
	(
		button btn1 "eggs-e-cute" pos:[50,160] width:91 height:32
		GroupBox grp1 "Selections" pos:[5,45] width:190 height:100
		spinner spn1 "controller number  " pos:[80,60] width:106 height:16 range:[0,10000,1] type:#integer
		spinner spn2 "modifier number  " pos:[82,85] width:104 height:16 range:[0,10000,1] type:#integer
		checkbox rotCheckBox "Rotation" pos:[10,100]
		checkbox posCheckBox "Postion" pos:[10,120]
		label lbl3 "Select objects you want to paste from and to " pos:[9,10] width:182 height:27
		
				
		on btn1 pressed do
		(
			getobj=selection[1] 
			setobj=selection[2]
	
	
			
			dParam=(getobj.name+"_Pos")
			hParam=(getobj.name+"_Rot")
					
			aParam=(getobj.name+"_xPos")
			bParam=(getobj.name+"_yPos")
			cParam=(getobj.name+"_zPos")
			eParam=(getobj.name+"_xRot")
			fParam=(getobj.name+"_yRot")
			gParam=(getobj.name+"_zRot")
			--xParam=(spn2.value)
			--zParam=(spn1.value) 
			xParam="1"
			zParam="1"

			(--position start--on posCheckBox yes do
				(
				str="def=attributes "+dParam +" 
(
"
				str+="	 parameters faceP 
	(
"
				str+="		"+aParam +" type:#float 
	"
				str+="	"+bParam +" type:#float 
	"
				str+="	"+cParam +" type:#float 
	)
"
				str+=")
"
				)
				caDef=execute str
				custAttributes.add setobj.modifiers[1] caDef
			)
					
				
			(
				(
				getobj=selection[1] 
				setobj=selection[2]
				
				str="
(
 setobj.modifiers[1]."+dParam +"."+aParam +".controller= getobj.pos.controller["+zParam +"].x_position.controller 
"
				str+=" setobj.modifiers[1]."+dParam +"."+bParam +".controller= getobj.pos.controller["+zParam +"].y_position.controller 
"
				str+=" setobj.modifiers[1]."+dParam +"."+cParam +".controller= getobj.pos.controller["+zParam +"].Z_position.controller 
)
"
				)
				execute str
			)
			(--rotation start-on rotCheckBox yes do
			
				(
				str="def=attributes "+hParam +" 
(
"
				str+="	 parameters faceP 
	(
"
				str+="		"+eParam +" type:#float 
	"
				str+="	"+fParam +" type:#float 
	"
				str+="	"+gParam +" type:#float 
	)
"
				str+=")
"
				)
				caDef=execute str
				custAttributes.add setobj.modifiers[1] caDef
			)
					
					
			(
				(
				getobj=selection[1] 
				setobj=selection[2]

				str="
(
 setobj.modifiers[1]."+hParam +"."+eParam +".controller= getobj.rotation.controller["+xParam +"].x_rotation.controller 
"
				str+=" setobj.modifiers[1]."+hParam +"."+fParam +".controller= getobj.rotation.controller["+xParam +"].y_rotation.controller 
"
				str+=" setobj.modifiers[1]."+hParam +"."+gParam +".controller= getobj.rotation.controller["+xParam +"].Z_rotation.controller 
)
"
				)
				execute str
			)

		)
						
	)			
				
			
				
	CreateDialog johnboy width:200 height:200		
				
				
)-- end of rollout 

any help would be great

cheers

john

Ok well i missed that one in the maxscript help! tipical though as soon as i鈥檓 about crack and i post a question i worked it out for myself.

i just worked it out that for all numbers or integers i needed to have 鈥渁s string鈥?after them

so finally got

xParam= spn2.value as string
zParam= spn1.value as string

work a treat:thumbsup:

its getting there

if anyone has any other feature requests i鈥檓 willing to see how far i can take this script

maybe make it so it can auto ad spiners and sliders for you characters

cheers

john

ok just posting to show you how things are coming along.

the only thing left to do is to get my checkboxes working. the only problem i鈥檓 hving is how to set it out. i think i鈥檓 approuching it the wrong way. what i want is for it to excucute bit of script depending on if the attribute is checked.

this is what i have but it won鈥檛 evaluate at this stage i havent worked out why yet so any clues would be great.

macroscript instance_controller
	category:"john Scripts"
(


		
	rollout johnboy "Face j rigg tools" 
	(
		button btn1 "eggs-e-cute" pos:[50,160] width:91 height:32
		GroupBox grp1 "Selections" pos:[5,45] width:190 height:100
		spinner spn1 "controller number  " pos:[80,60] width:106 height:16 range:[0,10000,1] type:#integer
		spinner spn2 "modifier number  " pos:[82,85] width:104 height:16 range:[0,10000,1] type:#integer
		checkbox rotCheckBox "Rotation" pos:[10,100]
		checkbox posCheckBox "Postion" pos:[10,120]
		label lbl3 "Select objects you want to paste from and to " pos:[9,10] width:182 height:27
		
						
		on btn1 pressed do
		(
			getobj=selection[1] 
			setobj=selection[2]
			
	
			
			dParam=(getobj.name+"_Pos")
			hParam=(getobj.name+"_Rot")
					
			aParam=(getobj.name+"_xPos")
			bParam=(getobj.name+"_yPos")
			cParam=(getobj.name+"_zPos")
			eParam=(getobj.name+"_xRot")
			fParam=(getobj.name+"_yRot")
			gParam=(getobj.name+"_zRot")
			xParam= spn2.value as string
			zParam= spn1.value as string
			yParam= spn2.value
			
						
			(
			on posCheckBox changed state do
				(
				
					(
					str="def=attributes "+dParam +" 
(
"
					str+="	 parameters faceP 
	(
"
					str+="		"+aParam +" type:#float 
	"
					str+="	"+bParam +" type:#float 
	"
					str+="	"+cParam +" type:#float 
	)
"
					str+=")
"
					
					caDef=execute str
					custAttributes.add setobj.modifiers[yParam] caDef
				
					
					getobj=selection[1] 
					setobj=selection[2]
					
					str="
(
 setobj.modifiers["+xParam +"]."+dParam +"."+aParam +".controller= getobj.pos.controller["+zParam +"].x_position.controller 
"
					str+=" setobj.modifiers["+xParam +"]."+dParam +"."+bParam +".controller= getobj.pos.controller["+zParam +"].y_position.controller 
"
					str+=" setobj.modifiers["+xParam +"]."+dParam +"."+cParam +".controller= getobj.pos.controller["+zParam +"].Z_position.controller 
)
"
					)
					execute str
							
					
					(
					on rotCheckBox changed state do 
						(
						
							(
							str="def=attributes "+hParam +" 
(
"
							str+="	 parameters faceP 
	(
"
							str+="		"+eParam +" type:#float 
	"
							str+="	"+fParam +" type:#float 
	"
							str+="	"+gParam +" type:#float 
	)
"
							str+=")
"
							
							caDef=execute str
							custAttributes.add setobj.modifiers[yParam] caDef
						
							
							getobj=selection[1] 
							setobj=selection[2]
			
							str="
(
 setobj.modifiers["+xParam +"]."+hParam +"."+eParam +".controller= getobj.rotation.controller["+zParam +"].x_rotation.controller 
"
							str+=" setobj.modifiers["+xParam +"]."+hParam +"."+fParam +".controller= getobj.rotation.controller["+zParam +"].y_rotation.controller 
"
							str+=" setobj.modifiers["+xParam +"]."+hParam +"."+gParam +".controller= getobj.rotation.controller["+zParam +"].Z_rotation.controller 
)
"
							)
					execute str
					)
				
				)
			CreateDialog johnboy width:200 height:200	
			
			)
				
		)			
	)		
						
)-- end of rollout 
  

i鈥檓 so close now. without the check boxes in the script everything works well you can choose what controller and what modifier you want it to instance to.

anyway

cheers

john

Ok yes i got it working.

the problem i was having was not the checkboxs at all i just needed to decler a few global varables. its allways somthing simple

here it the final script. download

and a test file download

install instructions are in the script

any coments would be great

anyway thanks again paul for your help.

cheers

john

Page 2 / 2