Community
3ds Max Programming
Welcome to Autodesk’s 3ds Max Forums. Share your knowledge, ask questions, and explore popular 3ds Max SDK, Maxscript and Python topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how to move object along local axis with spinner.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
suecke
850 Views, 2 Replies

how to move object along local axis with spinner.

What do I need to do to this script to make it move along its local x axis?

I believe "in coordsys local" should be placed in here but I am not seeing it.

I would appreciate some assistance.

ResetMaxFile #noPrompt

tag = teapot name:"Tea" dir:[1,1,0]
tag.position.controller = Position_XYZ ()

utility TeapotMoveSpinner "TeapotMoveSpinner"

(    ----- open utility

 	group "Teapot Mov By Spinner"
    (
	spinner TeapotPositionMoving2 "Tea Pot Position Moving:" fieldwidth:75 range:[-100,100,0] type:#integer align:#right
    )	
	

     on TeapotPositionMoving2 changed val do
 	(
     tag.position.controller.x_position = val ----does not work
	)	

	)  ----close utility

 

2 REPLIES 2
Message 2 of 3
Swordslayer
in reply to: suecke

Basically, you can either link the object to a parent so that its controller values (which are always in parent space, when not assigned a parent, parent space simply == world space) can be directly linked to the ui control:

 

(
	delete objects
	local tag = teapot prefix:"Tea" dir:[1,1,0] parent:(Point dir:[1,1,0])

	try destroyDialog ::TeapotMoveSpinner catch()
	rollout TeapotMoveSpinner "TeapotMoveSpinner" width:200
	(
 		group "Teapot Mov By Spinner"
		(
			spinner TeapotPositionMoving2 "Teapot Position Moving:" \
				fieldwidth:40 range:[-100,100,0] type:#integer align:#right \
				controller:tag.position.controller[1]
		)
	)
	createDialog TeapotMoveSpinner 
)

 Or you can calculate the new position yourself:

 

(
	delete objects
	local tag = teapot prefix:"Tea" dir:[1,1,0]

	try destroyDialog ::TeapotMoveSpinner catch()
	rollout TeapotMoveSpinner "TeapotMoveSpinner" width:200
	(
 		group "Teapot Mov By Spinner"
		(
			spinner TeapotPositionMoving2 "Teapot Position Moving:" \
				fieldwidth:40 range:[-100,100,0] type:#integer align:#right
		)

		on TeapotPositionMoving2 changed val do
		(
			tag.pos = val * x_axis * tag.transform.rotationPart
		)
	)
	createDialog TeapotMoveSpinner 
)

 

Message 3 of 3
suecke
in reply to: Swordslayer

thank you. Of the two solutions, calculating new position myself worked best.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report