Grasshopper

algorithmic modeling for Rhino

Hello,

Probably a dumb question:

How do I flatten items that enter the Python component as grafted into separate lists? 

Any help would be great!

Views: 1362

Replies to This Discussion

items = [stuff]
temp = []
for item in items:
temp.append(item)
results = temp
a = results

I tried creating a new list, but the data is still coming out grafted...any thoughts.

Hi Aaron

can you send an example of what you are trying to do? What is precisely the task that you are trying to accomplish in this case?

Thanks

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

 Giulio,

Here's the code and a snap shot of this section of the def.

I want to try and avoid iterating through every item of every list if I can help it.

evalPts = rs.EvaluateCurve(srfCrvsOuter, dist1)

ptA = tubeCenters
ptB = evalPts
tubeNormals = rs.AddLine(ptA,ptB)

divPts = rs.DivideCurve(tubeNormals, 10, True)

innerPts = []
for i in range(11):
pt1 = divPts[i]
pt1 = rs.AddPoint(pt1)
eval = rs.CurveClosestPoint(srfCrvsInner, pt1)
evalPt = rs.EvaluateCurve(srfCrvsInner,eval)
innerPts.append(evalPt)

lines = []
lengths = []
for i in range(11):
pt1 = divPts[i]
pt2 = innerPts[i]
line = rs.AddLine(pt1,pt2)
lines.append(line)

length = rs.CurveLength(line)
lengths.append(length)

sortedLines = [x for (y,x) in sorted(zip(lengths,lines))]

Thanks for your time.

Attachments:

You can use the usual GH right-click menu to flatten an input parameter. See attached file.

Attachments:

HAHA!  Yes...I could just flatten the data on input, however it is useful to deal with it as separate branches and then flatten in the code...

...the code I posted is the simplest case I could imagine...Grafted List enters component => Exits Flattened.  

I've noticed a flatten_data flag in C# and VB  does such a thing exist in GHPython?

 

Hehe, well you did say it was a dumb question ;)

Not quite sure I follow, but the GH datatree class has a method called flatten. Perhaps this is what you're looking for? See attached. Hope that helps.


Attachments:

Hi again Aaron

then, I think you want to have a 'Tree Access' input and then navigate it the way you like.

You can see an example in the Help (just Right click -> Help for links to discussions) or search this forum for it. I saw Anders' himself answering with a great sample here:

http://www.grasshopper3d.com/xn/detail/2985220:Comment:722462

Does it help?

Thanks,

Giulio
--
Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

This works Great!!!!

Tree Access on Input and Flatten() function are perfect!

Thanks So Much, Anders and Giulio!

aaron

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service