【发布时间】:2019-04-04 23:33:03
【问题描述】:
[在此处输入图像描述]在我的模型中有一个框架元素,我正在计算该元素的边缘,但该元素已旋转并且对于 ex (0.4 , 0.6 , 0.2) 具有不同的面方向。我只想要(x,y)格式的元素边缘坐标,但我得到的坐标为(x,y,z),其中x可以是高度或长度或宽度。我怎样才能得到坐标。
我通过减去元素的位置点将边缘的坐标转换为相对坐标
我在想,如果我可以将元素的面方向更改为 (0, 0, 1),即在 Z 平面中托管它,那么我需要做的就是读取边缘的 (X, y) 和将其存储在列表中。如果这是正确的方法,请建议我如何?或者请提出任何其他方法
private List<XYZ> GetFacesAndEdges(Element sheet)
{
//Location p1 = sheet.Location;
//FamilyInstance ins = sheet as FamilyInstance;
//Transform tra = ins.GetTransform();
//tra.BasisX = new XYZ(1, 0, 0);
//tra.BasisY = new XYZ(0, 1, 0);
//tra.BasisZ = new XYZ(0, 0, 1);
//Location p2 = ins.Location;
String faceInfo = "";
List<XYZ> points = new List<XYZ>();
Location p = sheet.Location;
XYZ point = new XYZ();
if (sheet?.Location is LocationPoint location)
{
point = location.Point;
}
Autodesk.Revit.DB.Options opt = new Options();
Autodesk.Revit.DB.GeometryElement geomElem = sheet.get_Geometry(opt);
foreach (GeometryObject geomObj in geomElem)
{
Solid geomSolid = geomObj as Solid;
if (null != geomSolid)
{
int faces = 0;
double totalArea = 0;
foreach(Edge e in geomSolid.Edges)
{
IList<XYZ> pointd = e.Tessellate();
foreach(XYZ ptr in pointd)
{
XYZ ptrXYZ = new XYZ(ptr.X - point.X , ptr.Y - point.Y, ptr.Z - point.Z);
points.Add(ptrXYZ);
}
}
}
}
return points;
}
我希望边缘处于相对坐标以及仅在二维维度中。前任。 大小为 4*4 的框架正方形元素
This is the picture of the framing element Which has cuts not openings.
【问题讨论】:
-
我认为一张图片将有助于更好地解释您的意思。只需手绘草图即可。
-
我添加了有切口而不是开口的图片。我希望检索这些开口的相对边缘,即在 xy 平面中托管框架,然后各自的坐标将是(从最左下角顺时针方向):-(0,0); (0,8); (2 ,8) ; (2,6);(6,6);(6,0)