consider the following text in rhino python where arrPts is a list of points
start_point = rs.GetPoint()
arrPts0 = []
arrPts0 = rs.GetPoints()
arrPts=[]
for ind, pt in enumerate(arrPts0):
arrPts.append( [pt,ind, 'angle','vector',0] )
then I run the arrPts through a function (def) which replaces 'angle' with actual strings of angles (e.g. '>45') and then I want to run through the following code which ends up calling another separate function (def) called 'add_Vectors':
Vectors = []
newPts = []
for pt in arrPts:
if '>45' or '<45' in pt[2]:
newPts.append(pt)
Vectors.append(add_Vectors(newPts, start_point))
how can I rewrite the above part with list comprehension so that it runs only when the condition is met instead of creating a new list (newPts) but working always on the main list (arrPts), if there's a function (def) in the way ?
something like:
Vectors.append(add_Vectors(newPts, start_point) ----> for '>45' in pt[2]
thanks
Pav
1h later...... tried this but doesn't seem to work:
newPts = []
Vectors = add_Vectors([newPts for pt in arrPts if '<45' in pt[2]], start_point)