Hi,
I am trying to get the geometry of structural framing objects trought a python script, that sorts the objects by the relative position.
the problem is, I am getting this message:
Warning: One or more geometries have failed to convert due to this error: The call is ambiguous between the following methods or properties: ‘Revit.GeometryConversion.GeometryObjectConverter.Transform(System.Collections.Generic.IEnumerable<Autodesk.DesignScript.Geometry.Geometry>, Autodesk.DesignScript.Geometry.CoordinateSystem)’ and ‘Revit.GeometryConversion.GeometryObjectConverter.Transform(Autodesk.DesignScript.Geometry.Geometry, Autodesk.DesignScript.Geometry.CoordinateSystem)’
The script still works, but it always returns completed with warnings.
Wich method is the correct one? And how do I chose since both are from the same “Autodesk.DesignScript.Geometry.Geometry” class
my script is:
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
def takeThird(elem):
return elem[2]
studs=IN[0]
loc=IN[1]
m=[]
i=0
for p in studs:
s=[]
j=0
for e in p:
s.append([e, loc[i][j], loc[i][j].X])
j+=1
i+=1
s.sort(key=takeThird)
m.append(s)
# Place your code below this line
re=[]
for l in m:
r=[]
for n in l:
r.append(n[0])
re.append(r)
re2=[]
for l in m:
r=[]
for n in l:
r.append(n[0].Geometry()[0])
re2.append(r)
# Assign your output to the OUT variable.
OUT = re, re2
Thanks.
It might be helpful to post an rvt with an example of the geometry in question.
It’s not exactly the same but I have come across this same error when iterating over the geometry from a Revit instance (Python code below). In my case, e.get_Geometry
was returning a null for a solid that had no edges or faces and trying to call g.Convert()
on it raised the error. When I excluded it with if g != None and g.Faces.Size != 0 and g.Edges.Size != 0:
the error disappeared.
In my case calling e.Geometry()
worked fine (I was only using get_Geometry()
instead because I wanted to get the subcategory of the geometry prior to converting to Dynamo geometry) so I’m not sure what the issue might be for you, but I think it probably relates to the family
The Python node behaviour comparison between if g != None:
and if g != None and g.Faces.Size != 0 and g.Edges.Size != 0:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
# Document
doc = DocumentManager.Instance.CurrentDBDocument
# IN
e = UnwrapElement(IN[0]) # Unwrap family instances
# List and Options
solids = []
geomOptions = Options()
geoms = e.get_Geometry(geomOptions) # Get the geometry from the element
enum = geoms.GetEnumerator() ; enum.MoveNext() # Enumerator
geom = enum.Current.GetInstanceGeometry()
for g in geom:
if g != None and g.Faces.Size != 0 and g.Edges.Size != 0:
sol = g.Convert()
solids.append(sol)
OUT = solids
1 Like
Thanks a lot Thomas.
I will give it a go.
1 Like