Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
I am trying to update the geometry of a DirectShape element in DocA with geometry coming from a IFC model (DocB).
I’m able to copy the geometry successfully, but the issue is:
The previous geometry of the DirectShape in DocA is not erased or overridden.
Instead, it seems to accumulate geometry.
Here is the function I’m using:
private static void UpdateDirectShapeGeometry(Document docA, Element hostElem, Element modifiedElement)
{
if (hostElem is DirectShape hostDs && modifiedElement is DirectShape linkedDs)
{
// Extract geometry from modified element
Options geomOptions = new Options
{
ComputeReferences = true,
DetailLevel = ViewDetailLevel.Fine
};
GeometryElement geomElem = modifiedElement.get_Geometry(geomOptions);
if (geomElem != null)
{
List<GeometryObject> newGeom = new List<GeometryObject>();
foreach (GeometryObject obj in geomElem)
newGeom.Add(obj);
if (newGeom.Count > 0)
{
try
{
// Clear old geometry and apply new one
hostDs.SetShape(newGeom);
}
catch (Exception ex)
{
TaskDialog.Show("Error", $"Failed to update DirectShape geometry: {ex.Message}");
}
}
}
}
}
Is it possible to change or override the DirectShape geometry using API?
Solved! Go to Solution.