Grasshopper

algorithmic modeling for Rhino

Replace items in tree at certain index (now with picture)

Hi everyone

I have a tree of items (non-uniform number of elements per branch), and I am trying to replace some of the items, at certain indices, with other pre-determined items. I've tried list replace, list insert (after removing values first), and replace members, but can't get it to work.

The replacement value list gets put in at once, or it only puts in the replacement values of the original index, etcetera. Probably there's something I'm not getting.

Example:

Tree=

{0} 1 1 1

{1} 1 1 1 1

{2} 1 1

I need to replace {0}i=1 with 10, {1}i=2 with 2 and {2}i=0 with 3, for example. The indices are extracted from another tree, the replacement values are user input (in a panel with 10, 2 and 3 in it).

Does anybody know how I could do this? I will post a picture tomorrow to clarify further.

Thanks

Pieter.

Views: 3416

Replies to This Discussion

Here's a picture to clarify things (in case of list insert).

This is part of a larger script using the spiderweb add-on, and what I am trying to do here is to remap distances to input in a shortest path analysis, so that users can add weights to certain edges of the network.

Basically I want to tie the weights to specific new connections (red sketched lines). The black sketched lines indicate which weight I would like at each position.

But I can't seem to figure it out.. grrr.

Attachments:

I've solved the problem thanks to a colleague of mine, who pointed me to this discussion:

http://www.grasshopper3d.com/forum/topics/data-tree-matching

I used the c# component from the discussion, a merge and a path mapper in the end.

A picture of my final solution:

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service