Need help with a few things please!

Hey so I'm a student, and my maxscript knowledge is pretty basic, so these errors may be easy to fix but any help would be awesome.

--- 1st Error ---
I have created 3 spinners that are going to be used to move a selected object.
Error message:
"Argument count error:EulerAngles wanted 3, got 1"

and here is the code i've currently got for it:
on rotate_Selection pressed do
(
rotate selection [eulerangles rotateSpinnerx.value, rotateSpinnery.value, rotateSpinnerz.value]
)

--- 2nd Error ---
I'm assuming the solution to the 1st one with also fix this but it's for a matrix so I'm not sure if it works differently.
Error message:
"Argument count error:EulerAngles wanted 3, got 1"

Code:
on Rotate_matrix pressed do
(
myrotateM = [eulerangles RMatrix_spinnerx.value,RMatrix_spinnery.value,RMatrix_spinnerz.value] as matrix3
mymatrix = mymatrix*myrotateM
format "mymatrix = %\n" (mymatrix as string)

--- 3rd Error ---
I have to create a button that returns the class of a selected object and then another button that returns the parent class of a selected object.
The class of button is fine as it returns this:
"ObjectName: Cone001 ; ObjectClass: Cone"

The parent class button returns this:
"ObjectName: Cone001 ; ParentName: -- ; ParentClass: --"

It's meant to say "node" in parent class right? but it just has the '--'

Code:
on find_class pressed do
(
if selection.count == 0 then messageBox "Select some objects!" else
(
for o in selection do format "ObjectName: % ; ObjectClass: %\n" o.name (classof o)
)
)
on find_parent_class pressed do
(
if selection.count == 0 then messageBox "Select some objects!" else
(
for o in selection do
(
if o.parent != undefined then
(
format "ObjectName: % ; ParentName: % ; ParentClass: %\n" o.name o.parent.name (classof o.parent)
)
else format "ObjectName: % ; ParentName: -- ; ParentClass: --\n" o.name
)
)
)

--- 4th Error ---
I've created a button that allows the user to browse for a material and I then need to create a button to apply material to a selected object.
Error Message:
"Unable to convert:undefined to type: FileName

Code:
on apply_Material pressed do
(
selection[1].material = standardMaterial diffuseMap: (Bitmaptexture fileName:usersimage) showInViewport:true
)

--- Final thing ---
So I have a button that creates a identity matrix and then sliders to translate, rotate (2nd Error)and scale that matrix. I then need to apply the matrix to a selected object, how would I go about doing this?

Thank you!

Comments

Comment viewing options

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

.

rotate selection (eulerangles spn_name1.value spn_name2.value spn_name3.value)
Chargrillz's picture

Hey cheers for the

Hey cheers for the reply!

With the rotation part, how do I incorporate it with the spinners? Because the rollout out needs to have spinners and then the 'rotate' button will apply the spinner value's to the selected object?

miauu's picture

.

1 and 2:

rotate selection (eulerangles 30 40 50)

3:
If your object do not have a parent it will return the same as you think is the error.

(
 
	if selection.count == 0 then messageBox "Select some objects!" else
	(
		for o in selection do
		(
			if o.parent != undefined then
			(
				format "ObjectName: % ; ParentName: % ; ParentClass: %\n" o.name o.parent.name (classof o.parent)
			)
			else 
			format "No Parent forn" o.name
		)
	)
)

4:

(
	usersimage = getOpenFileName()
	if doesFileExist usersimage do 
		selection[1].material = standardMaterial diffuseMap: (Bitmaptexture fileName:usersimage) showInViewport:true
)

5:

selection[1].transform = yourMatrix

Comment viewing options

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