Revit寻找CAD元素

xiaoxiao2025-10-11  8

  transGroup.Start();   CurveArray curveArray = new CurveArray();     //判断元素类型             foreach (var gObj in geoElem)       {GeometryInstance geomInstance = gObj as GeometryInstance;    //坐标转换。如果选择的是“自动-中心到中心”,或者移动了importInstance,需要进行坐标转换        Transform transform = geomInstance.Transform;                  if (null != geomInstance)    {     foreach (var insObj in geomInstance.SymbolGeometry)                    {     if (insObj.GraphicsStyleId.IntegerValue != graphicsStyleId.IntegerValue)      continue;            if (insObj.GetType().ToString() == "Autodesk.Revit.DB.NurbSpline")               {                            //未实现                        }            if (insObj.GetType().ToString() == "Autodesk.Revit.DB.Line")                    {                            Line line = insObj as Line;           XYZ normal = XYZ.BasisZ;     XYZ point = line.GetEndPoint(0);        point = transform.OfPoint(point);         curveArray.Append(TransformLine(transform, line));      CreateModelCurveArray(curveArray, normal, point);                }                         if (insObj.GetType().ToString() == "Autodesk.Revit.DB.Arc")             {                            //未实现                        }     if (insObj.GetType().ToString() == "Autodesk.Revit.DB.PolyLine")           {                            PolyLine polyLine = insObj as PolyLine;     IList<XYZ> points = polyLine.GetCoordinates();                        for (int i = 0; i < points.Count - 1; i++)                      {                                Line line = Line.CreateBound(points[i], points[i + 1]);      line = TransformLine(transform, line);         curveArray.Append(line);                      }                           XYZ normal = XYZ.BasisZ;             XYZ point = points.First();                    point = transform.OfPoint(point);                 CreateModelCurveArray(curveArray, normal, point);            }                  }                 }              }            transGroup.Assimilate();

转载请注明原文地址: https://www.6miu.com/read-5037733.html

最新回复(0)