ksobon / Bumblebee

Excel interop for Dynamo
36 stars 14 forks source link

BB nodes will return null if not located in default packages folder #15

Closed andydandy74 closed 8 years ago

andydandy74 commented 8 years ago

After moving my packages to a custom folder I noticed that BB nodes would return null. The reason for this is that the Python scripts are looking for bumblebee.py in the default package location. A possible solution for this would be to have your script look at the package folder paths stored in DynamoSettings.xml, iterate through them and try to locate the file that way.

ksobon commented 8 years ago

Great suggestion, I will have that incorporated. Yes, originally when I wrote it I don't think that people could actually define their own custom location for packages. Great catch.

ksobon commented 8 years ago

This should get the job done:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

import os
appDataPath = os.getenv('APPDATA')
dynPath = appDataPath + r"\Dynamo\0.9"
if dynPath not in sys.path:
    sys.path.Add(dynPath)

bbPath = appDataPath + r"\Dynamo\0.9\packages\Bumblebee\extra"
if bbPath not in sys.path:
    try:
        sys.path.Add(bbPath)
        import bumblebee as bb
    except:
        import xml.etree.ElementTree as et
        root = et.parse(dynPath + "\DynamoSettings.xml").getroot()
        for child in root:
            if child.tag == "CustomPackageFolders":
                for path in child:
                    if path not in sys.path:
                        sys.path.Add(path)
        import bumblebee as bb

I will post update all of the nodes and post it to package manager.

ksobon commented 8 years ago

Ps. Let me know if this solved it and i will close this issue.

Cheers!

ksobon commented 8 years ago

pushed a package update out...should fix that.

andydandy74 commented 8 years ago

Doesn't work for me. Maybe because path is not a string?

Please note: I copy/pasted this into an Excel Read node in BB 2016.1.22 as that is the last 0.9.0 compatible version. So if it does work under 0.9.1 please ignore - I created a local 0.9.0 compatible version that has our package path hardcoded...

andydandy74 commented 8 years ago

Just couldn't leave this alone... :-) This should work:

for path in child:
   path_bb = path.text + "\Bumblebee\extra"
   if path_bb not in sys.path:
      sys.path.Add(path_bb)
ksobon commented 8 years ago

yes, you are right my friend. Please see the latest in package manager.

mkdrafter commented 8 years ago

Im currently experiencing same issue on Dynamo 1.0 and Bumblebee 2016.6.30. I posted screenshots to the Dynamo forum.

https://forum.dynamobim.com/t/bumblebee-null-values-w-custom-installation-location-on-a-network-drive/5400