Hey guys, just started learning MaxScript and I'm trying to make a tool for work but I've hit a wall. Embarrassingly early as well :P
So what I'm trying to do is this;
I have an object that's broken up into lots of chunks. Basically we need a dummy object positioned at the pivot position of each of these chunks.
place = $.pos
Dummy pos:place
Does it no problem. But I have an object here that has 55 pieces and while its already a time save condensing it down to a button press I need to work out how to loop this through all the selected objects not only for this script but as a basis of learning how to do this stuff.
Any help would be very much appreciated
![:) :)](https://polycount.com/plugins/emojiextender/emoji/twitter/smile.png)
Replies
CODE HERE
);
(i think, newbie myself :P)
This should loop through all your objects you have selected.
I would however place the dummy at the lowest point of your model, not just its position.
Gimme a holla if you want to go a step into this direction
EDIT:
place = 0
for i = 1 to selection.count do(
place = selection.pos
Dummy pos:place
)
Works, cheers buddy. One more question; how do I select all the dummy objects in a scene and delete them?
if $ = dummy (phew, however you will check this, do not know the exact line)
then delete.$ (does that work? Oo)
)
maybe you need to put in an else, but i dont think so though...
delete $Dummy*
this way you could have other dummys in there, too
or you look into automatically renaming those dummys (e.g. putting a prefix like "pivotdum_" before you create a dummy with the first script and then search through all objects in a scene and delete all those that have "pivotdum_" in their name...
objects -- all the objects
geometry
lights
cameras
helpers
shapes
systems
spacewarps
and we know that dummys are of the class dummy (type classof $ to get your selections class)
Deleting by class is in this case a much better option. Someone could name a scene element dummy and your script will delete it. not a good way to make friends
In general working with names is a no no, unless you make a name exceptionally specific.
fn delDummies =
(
delete (
for o in helpers where classOf o == Dummy collect o
)
);
is what i came up with based on your suggestions.
At the moment I'm trying to expand this tool to make it more autonomous. To do that I want to;
- Take all the objects in a selection and name them in sequence.
- Create a duplicate of all these objects in the scene adding a prefix to the current names and have these sorted in an array. While hiding all the original object selections
- Create a dummy at the origin of all these pieces (this bit is done
), but have the dummies named so they correspond to the piece of geometry they are sitting on.
- Parent the geometry to its corresponding chunk.
At the moment I'm aware of selection as array but don't fully understand how to sort them and use them, any help would be awesomeCheers.
also what is its coresponding chunk? is that the dummy or the hidden geometry?
- snapshot all the meshes in an array to a new single mesh. (tempMesh)
- determine the centre point on x and y - store these
- determine the lowest z point of the new mesh - store that
- create a dummy in this place (center x/y, lowest z)
- delete tmpMesh
Some of these things I can already do, the biggy for me is getting a snapshot of an array of meshes in the scene as 1 single mesh, that I can then use and discard.for i in collection do //change that to something like i in (yourarray) do
(
meshop.attach j i
)
found that on CGTalk, was a three minutes search.
there is also a "snapshotAsMesh" function in max, might wanna google that.
you can then check the snapshot (or merged) mesh with something like
for v=1 to num_verts do
(
vert = getVert checkMesh v
if min_v > vert.z then
(
min_v = vert.z
)
)
delete checkMesh
)
)
(got that from David Liam's AO render script where he puts a plane under your mesh at rendertime)