Getting faces from Autocad fails with "Geometry Scaling"

  • Hello, I have a python code to get the contour of the hatch
  • However, if I set the “Geometry Scaling to Medium” mode, it creates the PolyCurve but it gives an error
  • If I set it to “Large” mode, it doesn’t give an error, but the Polycurve cannot be created
  • How can I fix this situation?
import clr

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

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument
importinstance = UnwrapElement(IN[0])
out = []
opt = Options()
geoSet = importinstance.get_Geometry(opt)
for geo in geoSet:
	if isinstance(geo, GeometryInstance):
		for g in  geo.GetInstanceGeometry():
			if isinstance(g, Solid) and g.Volume == 0:
				for f in g.Faces:
					if doc.GetElement(f.GraphicsStyleId).GraphicsStyleCategory.Name == IN[1]:
						for loopCurve in f.GetEdgesAsCurveLoops():
							ds_polycurv = DS.PolyCurve.ByJoinedCurves(x.ToProtoType() for x in loopCurve)
							out.append(ds_polycurv)
OUT = out

This image didn’t post - try again and make sure the upload finishes by checking the preview before you completing the post. :slight_smile:



Leave geometry scaling on ‘medium’ and the Python script should work fine. That warning about ‘outside the range’ is related to geometry display; content should process correctly.