Object Data

How do I make a Structure that retains the information for Position,Rotation and Scale.

Right now if you use the script below it only retains the position information of the selected objects.

Use:
1.Select Objects
2.Click the button
3.Move objects
4.Uncheck the button

result - the objects return to their original position. However i want them to return to there original position, rotation and scale.
Help is appreciated.
Thanks
JokerMartini

(
--//Variables
obj_collection = #() -- stores preview objects
obj_Node_collection = #() -- stores list objects node information

--//Functions
fn cacheObjNodes userSel =
(
obj_collection = #() -- stores preview objects
obj_Node_collection = #() -- stores original wirecolors
if userSel.count !=0 then
(
--// Storing the selected objects materials as arrays
for o in userSel do
(
try
(
m = o.pos
if m != undefined then
(
append obj_collection o
append obj_Node_collection m
)
)
catch
(
)
)

)
)

fn restoreObjNodes =
(
--// Restore previous materials
for i = 1 to obj_collection.count do
(
try
(
obj_collection[i].position= obj_Node_collection[i]
--obj_collection[i].scale = obj_Node_collection[i]
--obj_collection[i].rotation = obj_Node_collection[i]
)
catch
(
)
)
)

rollout rlStoreObjNode "Store Nodes"
(
checkbutton ckbtnStore "Store" width:140 height:40

on ckbtnStore changed st do
(
if st ==true then --// Button state checked TRUE
(
userSel =getCurrentSelection ()
cacheObjNodes userSel
print "I got you!"
)
else --// Button state checked FALSE
(
restoreObjNodes()
print "Back to normal!"
)
)
)
createDialog rlStoreObjNode 150 50 900 500
)

Comments

Comment viewing options

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

thanks Anubis that makes

thanks Anubis that makes sense and is a lot easier.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

Then you need whole PRS just

Then you need whole PRS just use ".transform" instead of ".pos":

rollout rlStoreObjNode "Store Nodes"
(
	local nodesData = #() -- array to strore data
 
	fn cacheNodes objSet =
	(
		local tmp = #()
		for obj in objSet do (
			data = #(obj, obj.transform)
			append tmp data
		)
		tmp -- result of the function
	)
 
	fn restoreNodes objSet =
	(
		for obj in objSet do obj[1].transform = obj[2]
	)
 
	checkbutton ckbtnStore "Store" width:140 height:40
 
	on ckbtnStore changed st do
	(
		if st == true then -- if checked
		(
			userSel = getCurrentSelection ()
			if userSel.count > 0 then (
				nodesData = cacheNodes userSel
				print "I got you!"
			) else (nodesData = #())
		)
		else -- if not checked
		(
			if nodesData.count > 0 do (
				-- filter for valid nodes (in case any of them deleted)
				nodesData = for itm in nodesData where isValidNode itm[1] collect itm
				restoreNodes nodesData
				print "Back to normal!"
			)
		)
	)
)
createDialog rlStoreObjNode 150 50 900 500 

my recent MAXScripts RSS (archive here)

Comment viewing options

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