3 point select to line

Good morning
I need help again and I'm back.
Not different
When I select three vertices of a spline or poly
I want to implement a script that will create lines to that length
This is a difficult code I am wandering
I can ask you for help.

AttachmentSize
3_point_line.jpg229.35 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jahman's picture

.

This one creates a copy of your splineshape and delete all knots that are preceed and those that go after the selected ones. Idea is clear and simple. You need to modify it to work with multi-spline shapes.
upd I just realized that it works incorrectly if spline is closed and the middle vert is first one ;)
I guess it is not the only bug

(
	ksel = getKnotSelection $ 1 as array
 
	if ksel.count == 3 do
	(	
		shp = copy $
 
		for i = numKnots shp 1 to 1 by -1 where i > ksel[3] or i < ksel[1] do deleteKnot shp 1 i
 
		updateShape shp
 
	)
)

Poly verts indexes are not ordered so you can't tell which selected vert is the middle one. And because of that you'll get three valid variants of spline: 1-2 + 2-3, 2-3 + 3-1, 3-1 + 1-2

AttachmentSize
verttoshape.png 21 KB
dussla's picture

thank you about good reply

Thank you
I use closed spline common
I will try your code

But in poly
If i dont use vertex ,
How about 3 edges ?
Is that imposble also ?

jahman's picture

.

same absolute story. I'll have to define mid vert/edge index in order to get right subSpline

dussla's picture

thank you for good advice

https://www.flyingcfx.com/?page_id=7

I seen select border there
So i thought idea~~

jahman's picture

.

0. get edge by vert index
1. get open edges polyop.getBorderFromEdge <Poly poly> <int edge>
2. sort edge indexes (the most complicated part)
3. toggle between two edge groups to select the one you need (or select shortest one if edge groups have different edge count)

dussla's picture

thank you for good answer

Thank you fast ansewr
That is not my area
I thought that is simple
But as your advice , that is difficult to me
~~

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.