ScriptSpot

Forum topic · General Scripting

Make a 4 vertices poly with 3 selected vertices

By titane357 · 2021-10-13

Downloads
Description

Hi

I want to make a new poly face with 4 vertices with 3 selected vertices.
( see pict )


SV = #()
SV = polyOp.getVertSelection $ as array
pt1 = polyOp.getVert $ SV[1]
pt2 = polyOp.getVert $ SV[2]
pt3 = polyOp.getVert $ SV[3]
DIST = pt3 - pt2   --- here
NP =  pt1 + DIST   --- and here
pt4 = polyop.createVert $ NP
append SV pt4
polyOp.createPolygon $ #( SV[1] , SV[2] , SV[3] , SV[4])
redrawViews()

It works in some situation, but as I'm a s### in maths, I don't know how to locate the 4th vertex in space...
If anybody could help. Thanks.

Comments (11)

titane357 · 2021-10-15

-

titane357 · 2021-10-13

Hi, Jahman.
Yes !
It is what I wrote :
DIST = pt3 - pt2
NP = pt1 + DIST
But in some case NP ( 4th vertex ) is not at the good place...
And I don't understand why...

.

jahman · 2021-10-13

If you could post this case here it would be easier to understand how to deal with it.

Attachments

titane357 · 2021-10-14

Hi, Jahman. It is a case it don't work...

Attachments

.

jahman · 2021-10-14

but what's wrong with the solution I posted in prev image?
p4 = p2 + 2 * ((p1 + p3) / 2.0 - p2)

titane357 · 2021-10-14

It do the same thing....


(
SV = #()
SV = polyOp.getVertSelection $ as array
pt1 = polyOp.getVert $ SV[1]
pt2 = polyOp.getVert $ SV[2]
pt3 = polyOp.getVert $ SV[3]
NP = pt2 + 2 * ((pt1 + pt3) / 2.0 - pt2)
pt4 = polyop.createVert $ NP
append SV pt4
polyOp.createPolygon $ #( SV[1] , SV[2] , SV[3] , SV[4])
redrawViews()
)

.

jahman · 2021-10-14

really? check your verts order
GIF

titane357 · 2021-10-15

I'll search for video capturing... and show you

.

jahman · 2021-10-15

I'd prefer scripted example scene instead of the vid

titane357 · 2021-10-14

It do the same thing....


(
SV = #()
SV = polyOp.getVertSelection $ as array
pt1 = polyOp.getVert $ SV[1]
pt2 = polyOp.getVert $ SV[2]
pt3 = polyOp.getVert $ SV[3]
NP = pt2 + 2 * ((pt1 + pt3) / 2.0 - pt2)
pt4 = polyop.createVert $ NP
append SV pt4
polyOp.createPolygon $ #( SV[1] , SV[2] , SV[3] , SV[4])
redrawViews()
)