Importing Custom Nodes into Python


#1

Hello. I have been trying to import LunchBox into a python node to use the Surfaces.DivideSurfaceUV but cannot figure out the right way. I have been looking through different forum posts but am not sure what I am missing, whether I am not using the correct name, the command is called incorrectly, or import is wrong/what the correct name is. Any help would be appreciated.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
.
.
.
for i in range(len(tops)):
	points.append(Surfaces.DivideSurfaceUV(tops[i],UVDiv, UVDiv))

#2

You have to tell it what you want to import, but not all packages are built from a dll file so may not be able to be imported into python.


#3

Why not use the node instead?

Feels like you’re setting up your own personal DLL hell when a user doesn’t have the package installed and the node doesn’t work, so you have to narrow down what in the code is broken, then they have to call you to have it fixed instead of going ‘oh I my days it couldn’t find this node let me check package manager’ and solving it themself. Just my two cents.


#4

Thank you. Currently my script crashes Dynamo and Revit from what I have been assuming is too much processing. When done in parts, it works fine but if it has to do more than half at once, it crashes. From what I have read, and please correct me if I am wrong, if you can dispose or delete unneeded geometry, solids, and variables using Python or Zero-touch nodes, it can save on the processing power. That is why I have started trying to convert the major chunks of my script into Python code.


#5

Turns out the crash was related to something else and the script runs fine now, albeit very slowly. Thanks for the help and information, though!