[Closed] how to get vertex number?
MainFloater = NewRolloutFloater "Link To Vertex" 180 450
Rollout Vert_Linker "Vertex Linker" (
group "Pick Vert" (
Button GetVert_Button "Get Selected Vert" enabled:off
Label vertnumL "Vertex No is: "
)
group "Pick Child" (
PickButton GetChild_PB "Get Child" enabled:off
Label getChildL "Current Child is:"
Label getChildn ""
)
group "Pick Parent" (
PickButton GetPrent_PB "Get Parent"
Label getParentL "Current Parent is:"
Label getParentn ""
)
group "Link ME Plz!" (
Button LinkME_Button "Link ME!" enabled:off
Label gettest ""
)
on GetVert_Button pressed do (
global vertnum = int(polyOp.getVertSelection Parent_Obj)
vertnumL.text = "Vertex Number: " + (vertnum as string)
VertPicked = true
if VertPicked == true do LinkME_Button.enabled = on
)
on GetChild_PB picked obj do (
global Child_Obj = obj
ChildPicked = true
getChildn.text = Child_Obj.name as string
t = Child_Obj.name as string
)
on GetPrent_PB picked obj do (
global Parent_Obj = obj
ParentPicked = true
getParentn.text = Parent_Obj.name as string
if ParentPicked == true do GetVert_Button.enabled = on
if ParentPicked == true do GetChild_PB.enabled = on
if ParentPicked == true do select Parent_Obj
)
on LinkME_button pressed do (
Child_Obj.position = polyop.getvert Parent_Obj vertnum;
)
)
my problem is here
on LinkME_button pressed do (
Child_Obj.position = polyop.getvert Parent_Obj vertnum;
)
in this
polyOp.getVert <Poly poly> <int vertex>
how can I get this <int vertex>
I’m tired can some-one help?
Well, your problem is with-
global vertnum = int(polyOp.getVertSelection Parent_Obj)
You can’t just convert an array of numbers to one integer, even if there is only one number in the array, you have to instead choose which number to return from that array. Try-
vertnum = ((polyOp.getVertSelection Parent_Obj) as array)[1]
Which then, vertnum should return the 1st number in the vertex selectiom array.
Hope this helps.
[vertnum] is not going to be a single digit number, it will return the selected vertex number witch maybe double digits or maybe 3 digits, so how am I going to return the selected vertex number even if it’s not a single digit?
thank you Ian00 for the response.
Well, the input <int vertex> in polyOp.getVert requires an intevger value so vertnum would have to be a single value if you are going to use it, and polyOp.getVert is what will return the 3 X,Y,Z values for the Child_Obj.position. So, having vertnum return the first vertex in the selection I would think would be the best way to go since, I’m assuming you only want to link one object to one vertex at a time.
For example, here’s a function to get the position of a selected vertex-
global FN_getVertPos
fn getVertPos =
(
if ((polyOp.getVertSelection $).numberset == 1) then
(
vertnum = ((polyOp.getVertSelection $) as array)[1]
return (polyop.getVert $ vertnum)
)
)
FN_getVertPos = getVertPos()
Which in my case the listener returns [-28.9979,0.725746,17.1029] If you instead evaluate just
vertnum = ((polyOp.getVertSelection $) as array)[1]
my listener returns 119 and the modify panel confirms this because it reads Vertex 119 Selected.