How to load a Package in to python

How can i load a package like BimorphNodes into Python?

i tried this :

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import sys
sys.path.append(r'R:\Dynamo\PACKAGES\bimorphNodes\bin')
sys.path.append(r'R:\Dynamo\PACKAGES\bimorphNodes\extra')

#import BimorphNodes 

bm = sys.path.append(r'R:\Dynamo\PACKAGES\bimorphNodes')
bm = sys.path.append(r'R:\Dynamo\PACKAGES\bimorphNodes\bin')
bm = sys.path.append(r'R:\Dynamo\PACKAGES\bimorphNodes\extra')

import BimorphNodes as bim



# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line

# Assign your output to the OUT variable.
OUT = bm
1 Like

Yes, you can:

#Copyright 2019. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.com
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.com Package: BimorphNodes
#Follow: facebook.com/bimorphBIM | linkedin.com/company/bimorph-bim | @bimorphBIM

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

import System
from System.Collections.Generic import Stack

import sys
sys.path.append('ADD YOUR PATH TO THE BIMORPHNODES PACKAGE BIN FOLDER HERE')

clr.AddReference('BimorphNodes')
import Curve

curveList = IN[0]

stack = Stack[Autodesk.DesignScript.Geometry.Curve]()
for crv in curveList:
    stack.Push(crv)

ptList = Curve.IntersectAll(stack)

OUT = ptList

4 Likes

Thanks Thomas

it worked
why is that little r needed before the path in : sys.path.append(r’R:\Dynamo\PACKAGES\bimorphNodes\bin’) ?

The r prefix is telling it that the following string is a string literal, otherwise forward slashes are not interpreted as characters but instead they have a special function for interjecting strings with a new line for example: \n. That’s problematic in file paths so r tells it not to look for any of these special characters just treat it all as a string. More info here:

https://docs.python.org/2.0/ref/strings.html

2 Likes

Thank you