Message 1 of 1
Creating dimensions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
And how do I create dimensions without selecting points or objects?
My plugin creates a legend with windows, and I need the windows to immediately have dimensions (width and height).
I attached a piece of code (non-working) and a screenshot where the right window has the dimensions that need to be set automatically for all windows.
I'm new to revit api and I don't understand a lot yet. please share your thoughts.
PS: The array (Reference Array) variable is not filled in. during debugging, it shows the error "Invalid number of references". And I can't fix it.
BoundingBoxXYZ boundingBox = copiedElement.get_BoundingBox(duplicatedLegend);
if (boundingBox == null) continue;
XYZ minPoint = new XYZ(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Min.Z);
XYZ maxPoint = new XYZ(boundingBox.Max.X, boundingBox.Min.Y, boundingBox.Min.Z);
Line line = Line.CreateBound(minPoint, maxPoint);
ReferenceArray array = new ReferenceArray();
Options options = new Options
{
View = duplicatedLegend,
ComputeReferences = true
};
GeometryElement geom = copiedElement.get_Geometry(options);
foreach (GeometryObject go in geom)
{
if (go is Solid solid)
{
ProcessSolid(solid);
}
else if (go is GeometryInstance instance)
{
GeometryElement instanceGeometry = instance.GetInstanceGeometry();
foreach (GeometryObject nestedGo in instanceGeometry)
{
if (nestedGo is Solid nestedSolid)
{
ProcessSolid(nestedSolid);
}
}
}
}
void ProcessSolid(Solid solid)
{
foreach (Face face in solid.Faces)
{
foreach (EdgeArray edgeArray in face.EdgeLoops)
{
foreach (Edge edge in edgeArray)
{
if (edge.Reference != null &&
edge.Reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_LINEAR)
{
array.Append(edge.Reference);
}
}
}
}
}
Dimension dimension = doc.Create.NewDimension(duplicatedLegend, line, array);