Grasshopper

algorithmic modeling for Rhino

I would like to write some of my own functions to be driven by the Leap Motion using they Python component in grasshopper.  

I am not sure how to begin this setup.  I have the leap SDK downloaded, but I do not know where to place the files that support its programming.  Any advice would be greatly appreciated.  I have been having trouble finding support for this issue.  Please let me know if there is any additional information from my end that may help to find a solution.

Kind Regards,

Jake

Views: 1879

Replies to This Discussion

For what it's worth, the leap motion has very good support through both Firefly and a one-off plugin called "Primate". Perhaps you could stream the data into python instead of trying to pull the libraries?

I have been working with the Leap Finger Tracker from Firefly and a few components from Primate, but I would like to bring some more information from the Leap SDK for Python into Grasshopper.  

I am still trying to get the Leap module to import, but until then, I am streaming some needed information from VVVV through UDP into Grasshopper. 

Thank you for the response.  I will report back if I have any success. 

Hi Jake,

You can use sys.path to find the folders that GHPython is checking for the libraries. try:

import sys

print sys.path

You can also add your optional path using path.append

sys.path.append("your folder address")

Then you should be fine to import the libraries.

Hope it helps,

Mostapha

Mostapha,

This makes a lot of sense, but it doesn't seem to take affect.  For this to work, will I need to have this code at the beginning of my file every time or will the optional path be retained until reboot or anything?

import sys

sys.path.append("location files and dll's")

import Leap

I am trying this simple code in Grasshopper Python, but no luck. I continue to receive the error no module named LeapPython. I get this same error when I try with Rhino's python editor as well.  I have contacted leap to see if they have a solution. Thank you for the response.  I feel that it is almost there.

Update:

I have found that I am able to get my idlePython editor to run the 32-bit SDK setup.  The 64-bit setup wont run, and I was assuming that idle is 32-bit.  Maybe I am wrong and there is an issue with the 64-bit setup from Leap?  I am going to attempt the same setup in Rhino 5 32-bit to see if I can get that part of the SDK to run.

... No luck, just tried and 32-bit 

1. Are you using C# libraries or Python libraries? You may need to AddReference to clr before importing the libraries.

2. Also you need to make sure that Leap libraries are managed libraries. I had a headache to import OpenStudio libraries. Check this discussion for more information: (http://www.grasshopper3d.com/forum/topics/grasshopper-script-compon...).

As far as I understand, Leap provides Python libraries along with dll's for 32-bit and 64-bit.  I will look into AddReference to clr later, because I honestly don't know what that is right now. I am also not sure if they are managed libraries.  I will ask the Leap contact next time they reply.

Thank you for all the help so far.  I will continue to chip away at this problem soon, but for now I have to get back to work. Updates will come as discoveries are made.

Update from IronPython people smarter than I:

"I think you are trying to mix LeapPython.pyd which appears to be cpython extension with IronPython. IronPython will not load it."

Conversation at:

https://ironpython.codeplex.com/workitem/35132

I have informed my Leap contact, and will update as information comes my way.

Hi Jake,

I should have guessed that. Why don't you just use the C# bindings with IronPython then? Download C# bindings and try something like this

yourFolder = "c:\\somewhere\\somewhereElse"

import clr
clr.AddReferenceToFileAndPath(youFolder + "\\Leap.dll")

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

import Leap

Are C# bindings just the C# SDK that was provided by Leap, or are C# bindings something that I need to add?  I haven't tried bringing in C# modules into IronPython.  And again, thank you for the help. Seems like you have pretty much solved my problem.

I meant the C# libraries which should come as part of the C# SDK. You can import the libraries similar to what I wrote above.

I am still trying to get this to work when I have free time, but this:

yourFolder = "C:\Users\jake_newsum\Documents\Programs\Leap\CSetup"

import sys
if yourFolder not in sys.path:
  sys.path.append(yourFolder)
  print sys.path
  import clr
  clr.AddReferenceToFileAndPath(yourFolder + "\Leap.dll")


import Leap

always returns:

Message: file does not exist: C:\Users\jake_newsum\Documents\Programs\Leap\CSetup\Leap.dll

I tried the way you had it written first:

yourFolder = "C:\Users\jake_newsum\Documents\Programs\Leap\CSetup"

import sys
import clr
clr.AddReferenceToFileAndPath(yourFolder + "\Leap.dll")

if yourFolder not in sys.path:
  sys.path.append(yourFolder)

import Leap

but I received the same results.  I checked the location and file name a lot, but I keep getting this error.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service