Dynamo sandbox and revit different?

Hello everyone,

I can easily combine polygons on it with the shapely library and it works great using dynamo sandbox.
1

However, when I try this when combining rooms in revit, it gives the following error.

Avertissement:AttributeError : ‘Polygon’ object has no attribute ‘Corners’ [’ File “”, line 15, in \n’]

What am I doing wrong?

import sys
import os
import clr

localapp = os.getenv(r'LOCALAPPDATA')
sys.path.append(os.path.join(localapp, r'python-3.8.3-embed-amd64\Lib\site-packages'))

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


polygons = IN[0]  
polygons_py = []  
for polygon in polygons:
    coords = [(point.X, point.Y) for point in polygon.Points] 
    polygons_py.append(coords)  


from shapely.geometry import Polygon, MultiPolygon

shapely_polygons = []
for coords in polygons_py:
    polygon = Polygon(coords)
    shapely_polygons.append(polygon)

merged_polygon = MultiPolygon(shapely_polygons).buffer(0).buffer(0)  


points_out = [Point.ByCoordinates(x, y) for x, y in merged_polygon.exterior.coords]

OUT = points_out

Standalone Dynamo and Dynamo for Revit are separate applications with separate versions, but I don’t see anything in your python code with a Corners method. Can you see if you get the error just from importing Polygon from shapely.geometry? There might be some confusion with duplicate class names?

I clearly understood this today. I had done all the opencv work in the sandbox before, I guess I will have to edit them all again according to revit. This is very bad.

The Shapely library works as coordinates, so if we give an input as point(x=10,y=20,z=0) as input, the shapely library accepts it as "POLYGON ((10,20)) ". So I need the points of all polygons to make this geometry edit.

That shouldn’t matter. I assume you are converting your Revit geometry to Dynamo geometry before the Python node, so there should be no difference in functionality. That’s why I’m worried the issue is more likely a conflict between Revit and Shapely.

It was very amateurish but I succeeded so I am happy.

I set the points of the polygons outside the python code and then I took the x and y points of the resulting single piece polygon as output and converted it into geometry directly outside the python code. It was really very amateurish but it solved my problem.
1