ScriptSpot home

Forum topic · General Scripting

Wire Objects position to anothers vertex

By JokerMartini · 2011-05-11

Description

Is it possible to wire an objects position to another objects specific vertex position?

Comments (13)
JokerMartini

rewrite

I had written this
Since getVert is used to get the vert count of both editable mesh and editable poly but it did not work. I'll have to look into it more and see why its not working write.

obj = $Foo ; v = 6
if IsValidNode obj do
if IsKindOf obj Editable_mesh or IsKindOf obj Editable_Poly and obj.numVerts >= v then
getVert obj v
else [0, 0, 0]

JokerMartini

Editable Poly

Why no matter what I do this does not work with editable poly?

Reply to JokerMartini
Panayot Karabakalov

quick reply

shortly - modify the expression cause its made for meshes

JokerMartini

This is awesome Anubis.

Thanks Anubis for the help.

However when I just run $Box01.position.controller.update() specifically it errors out saying unknown property in position when using max 2011.


s = Sphere name:"Foo" ; b = Box()
b.position.controller = position_script()
b.position.controller.script = "
obj = $Foo ; v = 6
if IsValidNode obj and \
(getPolygonCount obj)[2] >= v then
getVert obj.mesh v
else [0, 0, 0]
"
when transform $Foo changes do $Box01.position.controller.update()

Reply to JokerMartini
Panayot Karabakalov

notes...

Hi John,
1st - a little correction needs.

I usually works with collapsed to mesh objects and experiment here to getVert() from TriMesh (.mesh) but that's wrong ;) So, the expression s'd be:

obj = $Foo ; v = 6
if IsValidNode obj and \
IsKindOf obj Editable_mesh and \
obj.numVerts >= v then
    getVert obj v
else [0, 0, 0]

I tested it in Max 2011 as well. Works fine. Remember that Max 2011 use 3 digits enumeration and the name of your Box is not 'Box01' but 'Box001' or 'Box002'.

Graph

thx anubis, cataloged and saved :)
john, once i add this you can do that, might not be today but it shall be awesome ;)

JokerMartini

Here is an example of what I'm trying to do.
I want to populate a plane with objects on every vert of that plane.
When those verts move I want their corresponding objects to move along with that vert.

The reason I'm not using the attachment controller is because it does it based on the center of each polygon face. Although I know i can go in and change the values to 1,-1 or 0,0 to place it on the vert but no matter what i do it leaves me with an empty edge on no objects.

Does that make sense?
That is why I figured it would be easier to possibly through script just link the objects transforms to the individual verts position.

Graph

yes i published one for populating a mesh with copys on the verts but the one brot linked actually links a node to another objs vert
if you wanna link a vert to an obj id suggest some rigging and weighting methods

Panayot Karabakalov

position_script

example:

s = Sphere name:"Foo" ; b = Box()
b.position.controller = position_script()
b.position.controller.script = "
obj = $Foo ; v = 6
if IsValidNode obj and \
(getPolygonCount obj)[2] >= v then
    getVert obj.mesh v
else [0, 0, 0]
"
Reply to Panayot Karabakalov
JokerMartini

Evalute

Now is there a way to get that to update the the sphere is moved. That way the object will follow that vert. So if i move the sphere or a move that individual vert the box position will update accordingly.

Reply to JokerMartini
Panayot Karabakalov

Update()

Script controllers has small gap about updating.
Moving the time slider will update the controller.
Also you can call <Ctrl>.Update() in WHEN construct:

when transform $Foo changes do $Box01.position.controller.update()
Reply to br0t
JokerMartini

I think Graphs script just places them. I didn't see anywhere that it linked the two or not.

As for placing objects for each vert inside a target object is not the hard part. Just getting the object to stay connected is the hard part. Which wire parameters or a script controller would work.