How to search for value in two lists?

Hello, I need to create a sequence of lines. I have 3 lists. List of points. StartPoint index list, EndPoint index list.

How do I create a line by searching for the points in the point list? Searching for the indexes in these other two lists

hello, don’t overmultiply the topics
here is

lst_Pt=List.Flatten([Point.ByCoordinates(1..7,0,0),
Point.ByCoordinates(0,7..1,0)]);
ind_start;
ind_end;
Line.ByStartPointEndPoint(
List.GetItemAtIndex(lst_Pt,ind_start),
List.GetItemAtIndex(lst_Pt,ind_end)
);

Sincerely
christian.stan

I have a list of points:
P1 = (0,0,0)
P2 = (10,10,10)
P3 = (20,20,20)

List of indices (SP)
1
3
1

Index list (EP)
3
2
2

How do I create Line.ByStartPointEndPoint(SP,EP) following the indices and coordinates from the list of points?
How do you do this for infinite points?

@mateusc94 I merged your duplicate topic into this thread so that we don’t have two of the same topics kicking around. Please refrain from duplicating posts in the future.

Related use, this is for a face, which includes lines, but likely you can figure out what you’re after.

initVals =
	[
		[1.53107908172953,7.04002429703468,2.72827167422585],
		[5.26714147480435,5.63325357817501,2.59722676668331],
		[6.39523314317772,0.90014910715074,2.80358789812416],
		[6.56630533209906,7.86500621205188,2.30868727493463],
		[2.90466500913472,0.401293044354233,2.44644582694475],
		[6.93655945833426,5.22560058241544,2.56193837252474],
		[2.22703573523041,6.66244048092214,2.65364806118298],
		[1.60082388677793,7.09676755071685,2.70950132144502],
		[7.03898894283722,5.70580404432509,2.71940746309097],
		[7.11993325251859,2.82942701265365,2.34452396489751]
	];
indxLists =
	[
	    [1,5,9],
	    [9,4,1],
	    [2,4,9],
	    [8,5,1],
	    [3,6,7],
	    [7,6,0],
	    [1,3,8],
	    [6,3,1],
	    [1,4,6],
	    [6,4,0],
	    [5,8,9]
	];

vals = List.Transpose(initVals);
points = Point.ByCoordinates(vals[0],vals[1],vals[2]);
facePnts = List.GetItemAtIndex(points,indxLists);
patch = Surface.ByPatch(Polygon.ByPoints(facePnts));

Note: if you’re building a topography or similar, it’s likely better to use a Mesh rather than surfaces or lines.

thanks for the replies. do you know of any way of doing this if the list of indexes is longer than the list of points?

1 Like

Should be fine to work with them at any length, so long as the list of indices only contains values between zero and one less than the length of the list of points.

1 Like

I have the following points:
points = [(0,0),(5,0),(5,5),(3,3),(0,5)]
initial_index = [1,1,1,2,2,3,3,5]
final_index = [2,5,4,3,4,4,5,4]

I would like to draw 8 lines with the command line.ByStartPointEndPoint using these points and indices. Would this be possible in dynamo?

hi

/*Look closely at Mr. Jacob's remark about indexes
the 1st index starts at 0.
*/
lst_PT=Point.ByCoordinates(
[0,5,5,3,0],
[0,0,5,3,5]);
ind_start=[0,0,0,1,1,2,2,4];
ind_end=[1,4,3,2,3,3,4,3];
Line.ByStartPointEndPoint(
List.GetItemAtIndex(lst_PT,ind_start),
List.GetItemAtIndex(lst_PT,ind_end)
);


cordially
christian.stan

Thank you for your replies. Would it be possible to use these lines as a longitudinal axis and draw pipes?

1 Like

Yes. But that is another topic. Please mark a solution here and start a new topic. Be sure to try something on your own first.

1 Like

I plan to create a script to create a pyramid, I thought that was your goal.
I’ll share if anyone is interested

Script Python
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
pbase=IN[0]
psom=IN[1]
sbase=[Surface.ByPerimeterPoints(pbase[i] for i in range(len(pbase)))]
pbase.extend([IN[0][0]])
slat=[Surface.ByPerimeterPoints([pbase[i],psom,pbase[i+1]]) for i in range(len(pbase)-1)]
slat.extend([sbase[0]])
OUT = Solid.ByJoinedSurfaces(slat)

cordially
christian.stan

1 Like