Clarification question for Python

python

(Davidebliss) #1

Hi,

I’m fairly new to scripting for Rhino on Mac and want to be sure I am not missing anything with regards to importing other packages.

I’ve found how to add search paths to Atom, but I am not able to successfully import packages that I install with PIP.

As a test I tried installing the noise package and then importing it from my python2.7/site-packages directory.

I’ve not be able to do this. Should it work?

Is there another way to use packages like the noise package on Rhino 5 for Mac?

– dave


(Nathan 'jesterKing' Letwory) #2

Modules that are implemented using the CPython API don’t work with IronPython. The noise module is a CPython module (here the code for perlin).


(Davidebliss) #3

Thanks for the confirmation.

I found a pure python version of perlin noise here: https://github.com/caseman/noise/blob/master/perlin.py

and was able to use it in Rhino 5 with the following:

import rhinoscriptsyntax as rs
from Rhino.Geometry import Point3d
from perlin import SimplexNoise
sn = SimplexNoise()

GRID_SIZE = 25
for x in range(GRID_SIZE):
for y in range(GRID_SIZE):
rs.AddSphere([x,y,sn.noise2(float(x)/GRID_SIZE, float(y)/GRID_SIZE)],sn.noise2(float(x)/GRID_SIZE, float(y)/GRID_SIZE)+1)