hello all,
I’m trying to get both the rectangles separately (polycurves) from the cad file. all objects are in one layer.
overlaped lines.dwg (67.5 KB)
try to group curves first. Use Group Curves node and see if it helps…
Connect _groupedCurves with the node PolyCurve.ByCurves, and see if that helps.
EDIT: use level @1 in Group Curves node
nope, seems you have other issues as well…
but here is a rough way there probably could work on your unordered cad files
2 Likes
Hi,
during import Revit converts the curves into polylines when they are attached (which follow each other)
so here another solution with Python
import clr
import sys
import System
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.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
out = []
def get_CAD_polylines(importinstance, layer_Name=""):
"""
get import instance polylines and create closed polygons
"""
out = []
opt = Options()
geoSet = importinstance.get_Geometry(opt)
for geo in geoSet:
if isinstance(geo, GeometryInstance):
for g in geo.GetInstanceGeometry():
if isinstance(g, DB.PolyLine):
gStyle = doc.GetElement(g.GraphicsStyleId)
gstyleName = gStyle.GraphicsStyleCategory.Name
if System.String.IsNullOrEmpty(layer_Name) or layer_Name == gstyleName:
ds_polygon = DS.Polygon.ByPoints([p.ToPoint() for p in g.GetCoordinates()])
out.append(ds_polygon)
return out
importinstance = UnwrapElement(IN[0])
layerName = IN[1]
OUT = get_CAD_polylines(importinstance, layerName)
2 Likes