Grasshopper

algorithmic modeling for Rhino

Hey,
I want to do 'convex-hull' for a tree of curves. For each branch I need to make the Cnvx-Hull separately (but if I have a list in one branch, I wanna do the convex hull for the entire list- together).
But it didn't work directly on grasshopper (if you have an idea pls let me know)
So I also trying to use the convex hull function of rhino\ grasshopper in the python component...


I wrote this code:

# input: treeOfCrvPoints <Tree>

# output: cnvxHullTree <Tree>

import System

import rhinoscriptsyntax as rs
import clr
clr.AddReference("Grasshopper")
from Grasshopper.Kernel.Data import GH_Path as ghPath
from Grasshopper.Kernel.Geometry import ConvexHull as cnvxHull
from Grasshopper import DataTree as ghTree

tree = ghTree[System.Object]()
for i in range(treeOfCrvPoints.BranchCount):
  path = ghPath(i)
  crvs = treeOfCrvPoints.Branch(i)
  cnvxCrv = cnvxHull(crvs)
  cnvxHullTree.Add(cnvxCrv,path)

I have an error about this line: cnvxCrv = cnvxHull(crvs)

it says: Runtime error (ArgumentTypeException): namespace# is not callable

Views: 1208

Replies to This Discussion

I am not so familiar with the gh Kernel, but what about this?

it doesn't work.. but- I combined your code with my code and it worked.
Thank you very much :)

Attached here two pictures (for other people):

First only your code- didn't work in my case for som reason..
Second the combination (the green lines are the convex result)

Attachments:

forgot the second one :)

Attachments:

In my example the input "Pts" is defined as a list.
It probably does not work for you since you define your input as a tree.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service