Пример #1
0
        /// <summary>
        /// Convert a LinearElement to a Rhino Brep
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static RC.Brep ConvertToBrep(LinearElement element)
        {
            if (element.Geometry is Line)
            {
                return(ConvertToExtrusion(element)?.ToBrep());
            }
            else
            {
                Curve           perimeter = element?.Family?.Profile?.Perimeter;
                CurveCollection voids     = element?.Family?.Profile?.Voids;
                if (perimeter != null && element.Geometry != null)
                {
                    //TODO: Deal with voids!

                    RC.Curve profile = Convert(perimeter);
                    var      cSystem = element.Geometry.LocalCoordinateSystem(0, element.Orientation);

                    RC.Plane startPlane = Convert(cSystem.YZPlane());
                    profile.Transform(RC.Transform.PlaneToPlane(RC.Plane.WorldXY, startPlane));
                    RC.Brep[] breps = RC.Brep.CreateFromSweep(Convert(element.Geometry), profile, false, 0.001); //TODO: Change tolerance
                    if (breps.Length > 0)
                    {
                        return(breps[0]);
                    }
                }
            }
            return(null);
        }