-2

I´m working with python in Rhino 3D and have following problem. I have two Lists representing points.

List one for example:

StartPoints = [[x1,y1,z1],[x2,y2,z2],[x3,y3,z3]]

and the second list is:

EndPoints = [[x4,y4,z4],[x5,y5,z5],[x6,y6,z6]]

My goal is to join them in following form:

MergedPoints = [[x1,y1,z1],[x2,y2,z2],[x3,y3,z3],[x4,y4,z4],[x5,y5,z5],[x6,y6,z6]]

Everything I tried didn´t worked. When I use zip it gives me 3 branches with 3 elements. When I try to use map it says "Point3d is not callabe". My Goal is one List with 6 points. If you now grasshopper for Rhino3D it´s like the merge Element. I attached a pic for thouse who know. Thanks for your help!

enter image description here

  • What happened to `[x6,y6,z6]`? I also don't see a reason why `StartPoints + EndPoints` would not work, given that they are both of type `list`. – DeepSpace Mar 08 '17 at 13:24
  • Did you try `MergedPoints = StartPoints + EndPoints`? – MB-F Mar 08 '17 at 13:25
  • 3
    Possible duplicate of [How to append list to second list (concatenate lists)](http://stackoverflow.com/questions/1720421/how-to-append-list-to-second-list-concatenate-lists) – MB-F Mar 08 '17 at 13:26

3 Answers3

0

MergedPoints = StartPoints + EndPoints

N. Mauchle
  • 494
  • 1
  • 7
  • 20
0

See below.

StartPoints = [['x1','y1','z1'],['x2','y2','z2'],['x3','y3','z3']]
EndPoints = [['x4','y4','z4'],['x5','y5','z5'],['x6','y6','z6']]
MergedPoints = StartPoints + EndPoints
print MergedPoints

When i run it then getting below output:

[['x1', 'y1', 'z1'], ['x2', 'y2', 'z2'], ['x3', 'y3', 'z3'], ['x4', 'y4', 'z4'],
 ['x5', 'y5', 'z5'], ['x6', 'y6', 'z6']]
AJNEO999
  • 37
  • 7
0

I got it. It´s a bit difficult, becaue python sometimes cant´t use the data input from rhino. Thanks for your help!!

import rhinoscriptsyntax as rs


merged = []

for i in range(0,len(C)):
    S = rs.CurveStartPoint(C[i])
    merged.append(S)
    E = rs.CurveStartPoint(C[i])
    merged.append(E)
print merged