I have a dwg file with a lot of hatches without polylines. I’m trying to get the face and from there I would like to get the boundaries because in Revit I have this, by hand:
Yes, you are right and finally I’m doing this. The problem is that the file is huge with a lot of layers, etc. so I’m losing a lot of time separating the dwg in several files (Revit can not explode big files). Thanks.
import clr
import sys
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)
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):
for f in g.Faces:
for loopCurve in f.GetEdgesAsCurveLoops():
ds_polycurv = DS.PolyCurve.ByJoinedCurves(x.ToProtoType() for x in loopCurve)
out.append(ds_polycurv)
OUT = out
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
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):
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