Message 1 of 1
line for dimension
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm trying to add a line for the size, but I can't do it, I haven't had any result for two weeks, please help me.
I am sure that there is an answer to my question on the Internet, but since I am not a native English speaker, it is difficult for me to understand the information that I find, and in everything that I manage to figure out, there is no answer to my questions.
foreach (var copiedPair in copiedElements)
{
Element copiedElement = doc.GetElement(copiedPair.Value);
BoundingBoxXYZ boundingBox = copiedElement.get_BoundingBox(duplicatedLegend);
if (boundingBox == null) continue;
Options options = new Options { View = duplicatedLegend, ComputeReferences = true };
GeometryElement geom = copiedElement.get_Geometry(options);
//списки для линий и их references
List<Line> lines = new List<Line>();
List<Reference> lineReferences = new List<Reference>();
foreach (GeometryObject go in geom)
{
if (go is Line lineGeom)
{
lines.Add(lineGeom);
lineReferences.Add(lineGeom.Reference);
}
else if (go is GeometryInstance instance)
{
foreach (GeometryObject nestedGo in instance.GetInstanceGeometry())
{
if (nestedGo is Line nestedLine)
{
lines.Add(nestedLine);
lineReferences.Add(nestedLine.Reference);
}
}
}
}
for (int i = 0; i < lines.Count; i++)
{
for (int j = i + 1; j < lines.Count; j++)
{
Line line1 = lines[i];
Line line2 = lines[j];
//direction - возвращает направление линии
XYZ direction1 = line1.Direction;
XYZ direction2 = line2.Direction;
if (direction1.IsAlmostEqualTo(direction2) || direction1.IsAlmostEqualTo(-direction2))
{
ReferenceArray array = new ReferenceArray();
array.Append(lineReferences[i]);
array.Append(lineReferences[j]);
//line for dimension
//Line line = Line.CreateBound(boundingBox.Min, boundingBox.Max);
XYZ start = line1.GetEndPoint(0);
XYZ end = start + direction1.CrossProduct(XYZ.BasisZ); //поворот на 90 градусов по оси Z (векторное произведение двух векторов = вектор, перепендикулярный к обоим векторам)
Line line = Line.CreateBound(start, end);
//XYZ start = line1.GetEndPoint(0);
//XYZ end = line2.GetEndPoint(1);
//Line line = Line.CreateBound(start, end);
//XYZ start = new XYZ(boundingBox.Min.X, boundingBox.Min.Y, boundingBox.Min.Z);
//XYZ end = new XYZ(boundingBox.Max.X, boundingBox.Min.Y, boundingBox.Min.Z);
//Line line = Line.CreateBound(start, end);
Dimension dimension = doc.Create.NewDimension(duplicatedLegend, line, array);
}
}
}
doc.Regenerate();
}
I will be grateful for any hint and help