Notifications
Clear all

[Closed] get coordinates of each vertex on plane

I have a ground plane which is uneven and I want to get world coordinates of each vertex in the plane. Can someone show me some example scripts to do that!
Thanks

10 Replies

Hi.

This function will return an array with the world-space vertex positions for the object “obj”.

fn getVertexPositions obj = (
	local vPositions = #()
	local triMesh = snapshotAsMesh obj
	for v = 1 to triMesh.numVerts do (
		append vPositions (getVert triMesh v)
	)
	delete triMesh
	return vPositions
)

Did you mean that?

Looks like it, but I am not able to run this; it gives a runtime error “snapshotAsMesh requires a node”.
Thanks for the quick reply

Try getVertexPositions $

Light

If I try
getVertexPositions $Plane01
it Works!
(Plane01 is the name of the object in my scene.)

But
when I try
getVertexPositions ($+objName)
OR
$objname
Doesn’t Work!
(obName is the name of object in my script)

Any help on this.

if you mean you assigned a variable objname to the object in your scene like this:

objname = $Plane01

then you call the function with just the variable name as the argument like this:

getVertexPositions objname

Thats what I tried for the first time
Did not work

I have one object in my scene named “Plane01” and this works fine for me:


fn getVertexPositions obj = (
	local vPositions = #()
	local triMesh = snapshotAsMesh obj
	for v = 1 to triMesh.numVerts do (
		append vPositions (getVert triMesh v)
	)
	delete triMesh
	return vPositions
)

objname = $Plane01
getVertexPositions objname

What are you doing differently?

Say I have a list of object names in an array; Plane01, Plane02 etc
This way I do not have “$” in front. I tried adding that to the name and it still gives problems.

fn getVertexPositions obj = (
::::::::::::
::::::::::::
)

newName = “$”+objName
getVertexPositions newName

1 Reply
(@halfvector)
Joined: 11 months ago

Posts: 0

No, the function expect a node not a string. So if you have the name of the node (Plane01, Plane02, etc) do:

obj = getNodeByName objName
getVertexPositions obj

Thank you for your reply