Grasshopper

algorithmic modeling for Rhino

Hi all,

 

I have some python scripts that I made originally for rhinoceros(without grasshopper)

and would like to use those scripts in the ghpython component.

 

the best thing will be importing those scripts like

 

----in the ghpython component----

import rhinoscriptsyntax as rs

import test

 

test.addpoint()

----in the ghpython component----

 

while having a test.py that looks like this..

 

----test.py in the same directory of the grasshopper file(.gh)--------

import rhinoscriptsyntax as rs

 

def addpoint():

rs.AddPoint((0.0,0.0,0.0))

----test.py in the same directory of the grasshopper file(.gh)--------

 

and seems to fail getting

Runtime error (ImportException): No module named test

 

my guess is my test.py file positioning is wrong, but is it possible to do this?

sorry if this is already handled...

 

just in case, I'm using...

Rhino 64-bit(latest) v 5.0  (5.1.2011.825, 2011/08/25)

grasshopper v0.80050

ghpython 0.4.5.2

 

 

Views: 2022

Replies to This Discussion

Hi Yasushi,

Yes it's possible but you need to add your directory to the search path manually.
This will hopefully be made simpler in the future.

 

import sys
if not my_path in sys.path:
    sys.path.append(my_path)

import my_library

 

There is a bugtrack item about this here.

I hope this helps.

- Giulio

____________
giulio@mcneel.com
McNeel Europe

Hi Giulio,

 

Thanks for the fast reply!

from this tip I can start integrating my scripts right away! 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service