simple script

simple script

Anonymous
Not applicable
1,029 Views
7 Replies
Message 1 of 8

simple script

Anonymous
Not applicable
Hi

I'm trying to put together a simple script and was hoping someone out there might be able to give me a hand.

Basically I have a scene full of objects and I want to create a cube for each one. Then attach each object to their corresponding cube in turn, take the pivot position and name from the object being attached to the cube, and then delete the element that is the cube.

So none of the original objects move, they retain their name and pivot position, but are effectively reset by attaching them to a new object (the cube) which is then deleted.

Any help would be mucho appreciated!
0 Likes
1,030 Views
7 Replies
Replies (7)
Message 2 of 8

Anonymous
Not applicable
Oh yeah, and the material has to come from the original object too and not the cube it's attached to 🙂
0 Likes
Message 3 of 8

Anonymous
Not applicable
here it is... tested on max2008, hope i helped.. and the purpose of this was? 🙂


arr_obj = selectByName title:"Select Objects" buttonText:"Proceed" showHidden:false single:false
ppointpos_w = undefined

in coordsys world
(
for o in arr_obj do
(
print ("Processing Object: " + o.name)
nBox = box lenght:10 width:10 height:10
--nBox.wirecolor = red -- uncoment this for visual confirmation in viewport
ppointpos_w = o.pivot
nBox.position = o.position
instanceReplace nBox o
nBox.pivot = ppointpos_w
nBox.name = o.name
nBox.material = o.material
)
)
delete arr_obj
0 Likes
Message 4 of 8

Anonymous
Not applicable
Basically I have Max crashing a lot at the moment when calculating a radiosity solution... something to do with the original meshes in the scene is all I've been able to work out.
So I can fix this by either exporting each mesh as a 3DS and bringing it back again, or a solution I've used before to sort out other problems, which is to attach the object to a new mesh and then delete that element.
I has the effect of 'resetting' the mesh in some way..... well one that makes things work again anyway 🙂 And seeing as I have a lot of meshes in the scene and I don't know which is crashing the radiosity it seemed like a perfect use for a script.

So much appreciated. I'll give it a go and see how I get on 🙂

Thanks again!
0 Likes
Message 5 of 8

Anonymous
Not applicable
Is this script working for you? Or not. i had some fun with results during development so post me if this is working way you mentioned.. may be useful, for me also 😉

ahoj
0 Likes
Message 6 of 8

Anonymous
Not applicable
ops, i tested it again right now in office and there are still some problems with pivot restoring.. i'll look at it evening.. must do something else right now.
0 Likes
Message 7 of 8

Anonymous
Not applicable
Yeah no problem. I'm still having problems with it anyway, even when I am going through the process manually.

It would be more helpful if Max gave me some sort of error message when it was crashing rather then dumping straight to the crash report screen. Ho hum.... I'm going to keep plugging away though.

I'm pretty sure your script is doing what it's meant to so thanks again 🙂 Maybe it's not the solution to the problem after all though.... whatever the problem might be
0 Likes
Message 8 of 8

Anonymous
Not applicable
this should make pivot in same location as before but process is nasty 😉
maybe someone could reduce # of lines

arr_obj = selectByName title:"Select Objects" buttonText:"Proceed" showHidden:false single:false
ppointpos_w = undefined
ppointpos_l = undefined

in coordsys world
(
for o in arr_obj do
(
print ("Processing Object: " + o.name)
nBox = box lenght:10 width:10 height:10
nBox.wirecolor = red -- uncoment this for visual confirmation in viewport
ppointpos_w = o.pivot
CenterPivot o
ppointpos_l = o.pivot
nBox.position = o.position
instanceReplace nBox o
CenterPivot nBox
nBox.position = ppointpos_l
nBox.pivot = ppointpos_w
nBox.name = o.name
nBox.material = o.material
)
)
delete arr_obj
print "Job Done!"
0 Likes