Geometry Creation in python node within dynamo context


#1

What is the proper way to create a new cap form or blend form within the python node without having reference to the revit document. For instance is it possible to create a form and have it only exist within the dynamo context, then eventually baking it out later using another node.

 

 

All the python api samples I see are showing creating the geometry within the revit context.


#2

Hi Michael,


I put together a basic example showing how to use the external geometry library inside of Python. A screenshot and the dynamo patch is attached. It uses some points to construct a curve, then it extrudes the curve. Here's the Python script:



# Default imports


import sys


import clr


import math


path = r'C:AutodeskDynamoCore'


exec_path = r'C:AutodeskDynamoCoredll'


sys.path.append(path)


sys.path.append(exec_path)


clr.AddReference('LibGNet')


from Autodesk.LibG import *



#The input to this node will be stored in the IN variable.


dataEnteringNode = IN




p1 = Point.by_coordinates(0, 0, 0);


p2 = Point.by_coordinates(10, 5, 0);


p3 = Point.by_coordinates(20, 10, 0);


p4 = Point.by_coordinates(30, -15, 0);



# We have to construct a new PointList object, due to the Python -> C++ link


# the points are put into a python array, and used to construct a PointList


# All types have a “List” type, eg CurveList, SolidList, GeometryList etc etc


list= PointList([p1, p2, p3, p4]);



dir = Vector.by_coordinates(0, 0, 1);



curve = BSplineCurve.by_points(list);



surf = curve.extrude(dir, 30);



#Assign your output to the OUT variable


OUT = surf



The rudimentary documentation for this library is here: http://designscript.org/libg/classds_1_1Geometry.html Unfortunately it’s for the C++ library, so it’s mainly useful for getting method names. Ignore the ‘*’s and ‘&’s



Hope this is enough to get you started. Let me know if you have any more specific questions.