Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
I'm writing a macro which convert DWG (ImportInstance) into Revit Lines. It is working fine, but I'm frustrated because not all the lines are being converted, as you can see in the attached image, and I cannot find the reason why. I'd be grateful if someone could give me some advice regarding this issue.
I share my code in C# and the CAD file if it is useful.
The Code in the Macro:
//Get CAD's
var cads = new FilteredElementCollector(doc).OfClass(typeof(ImportInstance)).WhereElementIsNotElementType().WhereElementIsNotElementType();
ImportInstance imporInst = cads.FirstElement() as ImportInstance;
IList<Curve> lines = new List<Curve>();
IList<Curve> polylines = new List<Curve>();
IList<Curve> arcs = new List<Curve>();
IList<Curve> ellipses = new List<Curve>();
Options op = doc.Application.Create.NewGeometryOptions();
op.ComputeReferences = true;
op.IncludeNonVisibleObjects = true;
//Get Geometry
GeometryElement geoElem1 = imporInst.get_Geometry(op);
//Get Lines
if(geoElem1 != null)
{
foreach(GeometryObject geoObj1 in geoElem1)
{
GeometryInstance geoInst = geoObj1 as GeometryInstance;
if(geoInst != null)
{
GeometryElement geoElem2 = geoInst.GetInstanceGeometry() as GeometryElement;
if(geoElem2 != null)
{
foreach(GeometryObject geoObj2 in geoElem2)
{
//Lines
if(geoObj2 is Line)
lines.Add(geoObj2 as Curve);
//Polylines
if(geoObj2 is PolyLine)
polylines.Add(geoObj2 as Curve);
//Arcs
if(geoObj2 is Arc)
arcs.Add(geoObj2 as Curve);
//Ellipses
if(geoObj2 is Ellipse)
ellipses.Add(geoObj2 as Curve);
}
}
}
}
}
//Create Curves
using(Transaction curves = new Transaction(doc))
{
curves.Start("Convierte DWG a RVT");
//lines
foreach(Curve c in lines)
{
if(c != null)
doc.Create.NewDetailCurve(doc.ActiveView, c);
}
//polylines
foreach(Curve c in polylines)
{
if(c != null)
doc.Create.NewDetailCurve(doc.ActiveView, c);
}
//Arcos
foreach(Curve c in arcs)
{
if(c != null)
doc.Create.NewDetailCurve(doc.ActiveView, c);
}
//Ellipses
foreach(Curve c in ellipses)
{
if(c != null)
doc.Create.NewDetailCurve(doc.ActiveView, c);
}
curves.Commit();
}
Solved! Go to Solution.
Developer Advocacy and Support +