public ApplicationPlaceholderObject DirectShapeToNative(DirectShape speckleDs) { var docObj = GetExistingElementByApplicationId(speckleDs.applicationId); //just create new one if (docObj != null) { Doc.Delete(docObj.Id); } var converted = new List <GeometryObject>(); speckleDs.baseGeometries.ToList().ForEach(b => { switch (b) { case Brep brep: try { var solid = BrepToNative(brep); converted.Add(solid); } catch (Exception e) { var mesh = MeshToNative(brep.displayValue); converted.AddRange(mesh); } break; case Mesh mesh: var rMesh = MeshToNative(mesh); converted.AddRange(rMesh); break; default: ConversionErrors.Add(new Error("Incompatible geometry type", $"Type ${b.GetType()} is not supported in DirectShape conversions.")); break; } }); BuiltInCategory cat; var bic = RevitUtils.GetBuiltInCategory(speckleDs.category); BuiltInCategory.TryParse(bic, out cat); var catId = Doc.Settings.Categories.get_Item(cat).Id; var revitDs = DB.DirectShape.CreateElement(Doc, catId); revitDs.ApplicationId = speckleDs.applicationId; revitDs.ApplicationDataId = Guid.NewGuid().ToString(); revitDs.SetShape(converted); revitDs.Name = speckleDs.name; SetInstanceParameters(revitDs, speckleDs); return(new ApplicationPlaceholderObject { applicationId = speckleDs.applicationId, ApplicationGeneratedId = revitDs.UniqueId, NativeObject = revitDs }); }