[Grasshopper] When creating a data tree on Python script

If you want to output in data tree format, you need to load the library and do some processing.

① Load the library

Please read below.

import System
import Grasshopper.Kernel.Data.GH_Path as GH_Path
import Grasshopper.DataTree as DataTree

② Data tree output

This time, we will create a tree by extracting one data from the list data of [3, 4, 6, 7].

list = [3, 4, 6, 7]
tree = DataTree[System.Object]()
for i in range(len(list)):
 path = GH_Path(0, i)
 val = list[i]
 tree.Add(val, path)
a = tree

First, create a tree object to store the data. Any path can be created by using GH_Path (○○) for the path of the data tree. Add those data to the tree one by one using Add and you're done.

It's easy once you remember it. It's a good idea to remember the above operations because you use them often. By the way, the output data tree is as follows. image.png

Recommended Posts

[Grasshopper] When creating a data tree on Python script
Precautions when creating a Python generator
Creating a python virtual environment on Windows
Things to watch out for when creating a Python environment on a Mac
Periodically execute Python Script on AWS Data Pipeline
Folium: Visualize data on a map with Python
A memo when creating a python environment with miniconda
Notes on creating a python development environment on macOS Catalina
Problems when creating a csv-json conversion tool with python
What's in that variable (when running a Python script)
[Piyopiyokai # 1] Let's play with Lambda: Creating a Python script
[Python] Notes on data analysis
A shell script that numbers duplicate names when creating files
Creating a Python script that supports the e-Stat API (ver.2)
A memo when creating a directed graph using Graphviz in Python
Dockerfile for creating a data science environment based on pip3
[Treasure Data] [Python] Execute a query on Treasure Data using TD Client
Build a python data analysis environment on Mac (El Capitan)
[GCP] A memorandum when running a Python program on Cloud Functions
Create a Python script for Wake on LAN (NAT traversal Wake on LAN [5])
When you want to hit a UNIX command on Python
A python script that converts Oracle Database data to csv
Building a Python environment on Mac
Creating a decision tree with scikit-learn
Building a Python environment on Ubuntu
[Python] View data on new coronavirus infections on a 7-day moving average
Create a Python environment on Mac (2017/4)
Support when installing pillow on python3.9
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
Create a python environment on centos
When creating an environment that uses python django on Ubuntu 12.04 LTS
[Python] Creating a scraping tool Memo
A note on using tab completion when running Python interactively on Windows
Determine if standard output is piped when running a Python script
Launch a Python script as a service
When creating a matrix in a list
Build a python3 environment on CentOS7
A python script that deletes ._DS_Store and ._ * files created on Mac
[Python] Chapter 03-01 turtle graphics (creating a turtle)
Write a batch script with Python3.5 ~
When writing a program in Python
A memo when using systemd to keep a Python script running as a daemon on CentOS 7 at all times.
[Python memo] Be careful when creating a two-dimensional array (list of lists)
A python script for Mac that zips without garbled characters on Windows
Make a decision tree from 0 with Python and understand it (4. Data structure)
[Python] Chapter 04-06 Various data structures (creating dictionaries)
Creating a simple PowerPoint file with Python
[Python] Use and and or when creating variables
Precautions when pickling a function in python
Add a Python data source with Redash
Build a python environment on MacOS (Catallina)
Run a local script on a remote host
Note when creating an environment with python
Create a python environment on your Mac
A memo with Python2.7 and Python3 on CentOS
Map rent information on a map with python
A struggle when installing pyenv on Cygwin
Run the Python interpreter in a script
Creating a data analysis application using Streamlit
A little more detail on python comprehensions
[Python] Creating a stock price drawdown chart