- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
My goal is to import geometry from a 3d library containing tiled models of cities into Revit. Those imported models need to respond to sectioned views.
The source data for these city models is from airborne photogrammetry. I am not 100% sure what the process is that creates the geometry from the photogrammetry but it eventually finds its way to a dwg format. These files contain nothing but Solids. Example image below showing the dwg file:
The first attempt was to import the dwg as an ImportInstance and simply explode it back to its raw elements (creating section views through an ImportInstance does not section the objects hence the need to explode). If we get lucky this approach works and we are left with a collection of native Revit solids. However, more aften than not, exploding the ImportInstance will result in the whole instance being deleted because Revit is not able to deal with the complex solids.
Second idea was to import the dwg as an ImportInstance and create a DirectShape using the geometry:
IList<ImportInstance> Imports = (from elem in
new FilteredElementCollector(doc)
.OfClass(typeof(ImportInstance))
let type = elem as ImportInstance
select type).ToList();
foreach (ImportInstance import in Imports)
{
if (import == null)
return;
Options opt = new Options();
//opt.DetailLevel = ViewDetailLevel.Fine;
//opt.IncludeNonVisibleObjects = true;
//opt.ComputeReferences = true;
foreach (GeometryObject geometryObj in import.get_Geometry(opt))
{
DirectShape ds = DirectShape.CreateElement(doc,
new ElementId(BuiltInCategory.OST_GenericModel));
ds.SetShape(new List<GeometryObject>() { geometryObj });
// only one geometry object in this loop so static name OK
ds.Name = "MyShape";
}
}
This works OK and results in a “solid” that can be sectioned. However, there is another problem with this approach – If the original ImportInstance is deleted, the DirectShape is also deleted. It’s like the geometry of the DirectShape is directly linked to the geometry of the ImportInstance. A work around is to hide the ImportInstance in the views as required but that is not ideal.
I have not used DirectShape before and ask why the object it deleted when the original ImportInstance is removed from the model, and is there a way to decouple them?
I will add that there are tens of thousands of these files so automation is the key.
Solved! Go to Solution.