ScriptSpot home

Forum topic · Scripts Wanted

3 point select to line

By dussla · 2018-06-24

Downloads
Description

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.

Comments (6)
Panteleev Sergey

.

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

Attachments

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 ?

Reply to dussla
Panteleev Sergey

.

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

Reply to dussla
Panteleev Sergey

.

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)

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
~~