Notifications
Clear all

[Closed] Accesing and moving vertices in editable poly

Hi, i’m trying somthing as simple as iterating through a vertex subobject selection and moving each vertex to a new specified position. but i just can’t. the maxscript help has guided me something, yet i still don’t understand why this simple script doesn’t work (i have a bunch of vertices selected):

for i in $.selectedVerts do
(
move $.selectedVerts[i] [0 0 10]
)

or:

for i in $.selectedVerts do
(
$.selectedVerts[i].pos.y=0
)
what happens here? i know the problem has to do with the selection set, the error says the method doesn’t apply, but the maxscript help confuses me a hell of a lot. if someone can help me understand how i can do this (accessing and modifying sub objects) would be very nice, thanks.

7 Replies
for i in (polyop.getVertSelection selection[1]) do
(
	polyop.moveVert selection[1] i [0,0,10] node:selection[1]  --Say node:selection[1] otherwise offset is in local space.

)

ok i understand a little better now, thanks. but i get a bunch of new questions:
-why selection[1]? why not just $? (it works too i see) what’s the difference, if at all? is it better?
-how can i set the position of the vertex in only one axis, like $.pos.y=50? the polyop methods in the help files just give me setVert, but i need a 3point value.
-how can i get the index of a selected vertex? if i want the position of a selected vertex, the polyop method asks me the index of the selected vertex first!
i’m a beginner i know, so thanks for your patience. i’m checking most of the tutorials i can find but there are none about this subject.
thank you again!!

No Problem.

  1. Selection[1], is what I use, at least if you want to use a single object selection. If you use $, if the object is instanced, it can cause the selected to shift to the parent/original object u instanced from, and do the operations on that one.

  2. To move on the Y, just do what I posted. Don’t modify the X,Z positions when you say moveVert. So if you extract a 3point from another value, you can just store that in a local variable like thePos = [20,50,10]. Then for the moveVert just do, moveVert [0,thePos.y,0].

  3. To get the index, you can do

polyop.getVertSelection selection[1]

Which will return the index of the vertex, or an bitArray, containing all of the vertex indexes selected.

For the pos, it says

Editable_Poly Methods    [left][b]polyop[/b].[b]getVert[/b] <Poly poly> <int vertex> [b]node[/b]:<node=unsupplied>
[/left]

So Poly is your mesh, so selection[1]. Int is the integer of the Vert, so you can use the index method I showed, or do like I did before and say

for i in (polyop.getVertSelection selection[1]) do
   (
   	local theVertPos = polyop.getVert selection[1] i node:selection[1]  --Say node:selection[1] otherwise offset is in local space.
           --theVertPos now has the Point3 Value of the vertex stored to use.
    
   )

thank you very much for this, i really appreciate your time. It’s been difficult for me to learn from the help file because there are like four topics of editable poly, and each one of them has its own methods and properties, very similar between them, but not exactly the same. This confuses me a LOT. In the editable poly topics index there are these:
ed poly properties
ed poly methods
ed poly geometry methods (polyop struct)
ed poly mapping methods (polyop struct)
interface:editable poly

what’s the difference between them?

The EditablePoly Methods are what you would get if you turned on macro recorder in the listener. It is used to control some button pushes and other properties of an EditablePoly Mesh, that polyop cannot control. Or maybe it can, but it does it a different way.

The editable poly stuff is like selection[1].editablePoly instead of polyop.ect.

It has examples in the maxscript, but I do agree it is confusing at first. I would recommend watching
http://vimeo.com/7616125 videos.

ok thank you very much for your help!

finally!! i could do what i wanted!! i wanted to flatten a selected group of vertices to a specified height. i know there is make planar, but i wanted to do it all in one step. here is what i came up with. i have to make a macroscript with a dialog so i can input the height though:

sel=polyop.getvertselection $
for i in sel do
(
pos=polyop.getvert $ i
polyop.setvert $ i [pos.x,pos.y,50] –50 is the specified height!
)