I’m trying to connect to a python library and am getting some weird behavior. I’m trying to use CPython3 to access an environment set up with Anaconda so i can use the grassfire module.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
# Add external paths
sys.path.append(r'C:\ProgramData\Anaconda3\envs\Dynamo212\Lib\site-packages')
sys.path.append(r'C:\Users\mclough\src')
from Autodesk.DesignScript.Geometry import *
import numpy
from tri.delaunay.helpers import ToPointsAndSegments
from grassfire import calc_skel
# The inputs to this node will be stored as a list in the IN variables.
if hasattr(IN[0],'__iter__'):
contours = IN[0]
else:
contours = [IN[0]]
shape = []
trace = []
skeleton = []
nSk = []
def PointToTuple (point):
return (point.X,point.Y)
def ConvToDyn (skel):
nOut = []
for node in skel:
edges = []
#nSource = Point.ByCoordinates(node[0][0],node[0][1],100)
nSource = node[0]
for sink in node[2]:
#nSink = Point.ByCoordinates(sink[0],sink[1],100)
edges.append([nSource,sink])
nOut.append(edges)
return nOut
# Assign your output to the OUT variable.
OUT = skeleton
i am able to import the modules ‘tri’ and ‘grassfire’, but i’m not able to use the methods above to import from, shown above. if i try and access the methods in the grassfire and tri modules directly, dynamo gives an error that tri does not have an attribute delaunay
When i create a python file with the anaconda environment i can import the modules with both methods.
the grassfire module uses this … ‘egg’ distribution that i’m not familiar with and it put it in a ‘src’ folder in my User profile instead of directly in the Anaconda site-packages folder. I tried installing the module using the ‘get-pip’ method for dynamo’s embedded python, but it failed when trying to install the dependencies, so i’m trying the approach with Anaconda, but i’m still pretty new to it so i probably messed something up.
packages installed in the Anaconda env seem to be discoverable. What am i overlooking here?