An error appears when using the script. Could you explain it to me?
“Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 11, in
AttributeError: ‘type’ object has no attribute ‘ByPerimeterPoints’”
If you remove the RevitAPI Library, the script is executed.
I looked at the solution with a bypass of such problems, but I want to understand.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
lk11=IN[0]#
xtx2=Surface.ByPerimeterPoints(lk11)
OUT = xtx2
Both libraries (ProtoGeometry and RevitAPI) have a class named “Surface”. Your code contains two import statements and all names from first import are overridden by the second import.
It is considered a bad practice to use wildcard in ("*") in imports, because it leads to problems like the one in this thread. A solution is to write explicitly what you want to import:
from Autodesk.DesignScript.Geometry import Surface
And if there is a name conflict you can solve it like that
from Autodesk.DesignScript.Geometry import Surface as PGSurface
from Autodesk.Revit.DB import Surface as DBSurface
*Edit: @Andrey_Baranov You have answered yourself in the title of the thread.