Accessing all sub classes of Autodesk.DesignScript.Geometry

Hi, I’m trying to change all Dynamo nodes into single python script.
What I’m trying to make is pretty simple. Several curves imported from .dxf file on Revit, and making a solid with those curves(while doing some difference operation to make a hole)

The problem is that I cannot acces some sub-classes of Autodesk.DesignScript.Geometry.
As you can see in these pictures, it returns a error “AttributeError : type object ‘Surface’ has no attribute ‘ByPatch’ ['File”", line 25, in \n’].

I need to patch the curves, + do difference between the patched surfaces + extrude final surface as solid.

Plz help.

P.S. It is totally fine to use only Revit to do the same thing if that is possible. Just doing it with python code is important.

import sys
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference(“RevitServices”)
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

t5 = Revit.Elements.Element.Geometry(IN[0])
surface = Surface.ByPatch(t5)

surface_hole = surface[0]
for i in range(1, len(surface)):
surface_hole = Autodesk.Surface.Difference(surface_hole, surface[i])

solid = Autodesk.Surface.Thicken(surface_hole, -3000, false)

geometry = Geometry.Rotate(solid, Plane.YZ(), -90)

OUT = geometry

Have you confirmed that t5 element types are aligned to what you got with the design script version? Commenting out all subsequent lines and adding OUT = t5 should make that fairly easy.

the t5 works perfectly same as design script version.
I don’t know why it is assigned as #5 but just left it bcs it doesn’t matter.

Can you expand the preview of the t5 data from the Python node?

Just 3 polycurves.

Python doesn’t have associative code capabilities. This means that if you want to patch a list of polycurves into a list of surfaces you need to explicitly provide a loop.

Try surface = [Surface.ByPatch(crv) for crv in t5] and see if that works.

Also because you are importing both the design script geometry library and the Revit API library you may have two surface classes - one for Dynamo stuff and one for Revit stuff. Commenting out the line from Autodesk.Revit.DB import * might resolve the issue for now. If you need both you’ll need to bring in one class as an alias, which I usually accomplish via something like from Autodesk.DesignScript import Geometry as DG and putting DG. down as a prefix every time you want to call a Dynamo geometry class (ie: DG.Surface.ByPatch(crv)).

1 Like

Gosh I couldn’t expact them to have same surface classes.
Now I’ve got a different error at different line, though the original problem has solved by coomenting out the Revit.DB line. Thx alot.

1 Like