/// <summary>
        ///     Creates a new CurtainSystem with transaction.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="app"></param>
        /// <param name="profile"></param>
        /// <param name="curtainParm"></param>
        /// <param name="normal"></param>
        /// <returns></returns>
        public static CurtainSystem CreateCurtainSystem(this Document doc, App app, CurveArrArray profile, CurtainParm curtainParm, XYZ normal)
        {
            if (doc is null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (app is null)
            {
                throw new NullReferenceException(nameof(app));
            }

            if (profile is null)
            {
                throw new NullReferenceException(nameof(profile));
            }

            if (normal is null)
            {
                throw new NullReferenceException(nameof(normal));
            }

            var plane = normal.CreatePlane(XYZ.Zero);

            var symbolParm = new SymbolParm(curtainParm.TemplateFileName, profile, plane, 1.0);

            var symbol = doc.CreateExtrusionSymbol(app, symbolParm);

            var location = profile.ToCurveList().GetDistinctPointList().GetMinPoint();

            var instParm = new InstParm(location, symbol, curtainParm.Room.Level, NonStructural);

            return(doc.CreateCurtainSystem(curtainParm, instParm, normal));
        }
Esempio n. 2
0
        /// <summary>
        ///     Creates a new CurtainSystem.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="profile"></param>
        /// <param name="lvl"></param>
        /// <param name="normal"></param>
        /// <param name="typeName"></param>
        /// <returns></returns>
        public static CurtainSystem CreateCurtainSystem(this Document doc, CurveArrArray profile, Level lvl, XYZ normal, string typeName = null)
        {
            if (normal is null)
            {
                throw new NullReferenceException(nameof(normal));
            }

            var pts = profile.ToCurveList().Select(s => s.GetEndPoint(0));

            pts = pts.OrderBy(o => o.Z).ThenBy(o => o.Y).ThenBy(o => o.X);

            var fdoc     = doc.CreateExtrusion(profile, normal.CreatePlane(XYZ.Zero), 100);
            var symbol   = doc.NewLoadFamily(fdoc);
            var location = pts.FirstOrDefault();
            var instance = doc.Create.NewFamilyInstance(location, symbol, lvl, NonStructural);

            doc.Regenerate();

            // The instance has thickness.
            var faces = instance.GetFaceList(6, -normal).ToFaceArray();

            var result = doc.CreateCurtainSystem(faces, typeName);

            doc.Delete(instance.Id);
            doc.Delete(symbol.Family.Id);

            var pnlTypeId = result.CurtainSystemType.get_Parameter(AUTO_PANEL).AsElementId();

            if (!(doc.GetElement(pnlTypeId) is PanelType pnlType))
            {
                return(result);
            }

            var thickness = pnlType.get_Parameter(CURTAIN_WALL_SYSPANEL_THICKNESS).AsDouble();

            ElementTransformUtils.MoveElement(doc, result.Id, normal * thickness / 2);

            return(result);
        }
Esempio n. 3
0
        /// <summary>
        ///     Resets the family symbol profile's location to zero point.
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="eps"></param>
        /// <returns></returns>
        public static CurveArrArray ResetCurveArrArray(this CurveArrArray profile, double eps = 1e-2)
        {
            if (profile is null)
            {
                throw new ArgumentNullException(nameof(profile));
            }

            var results = new CurveArrArray();
            var pts     = profile.ToCurveList().Select(s => s.GetEndPoint(0));

            pts = pts.OrderBy(o => o.Z).ThenBy(o => o.Y).ThenBy(o => o.X);

            var location = pts.FirstOrDefault();

            foreach (CurveArray lines in profile)
            {
                var tmpLines = new CurveArray();

                foreach (var line in lines.Cast <Line>())
                {
                    if (line.Length < eps)
                    {
                        throw new InvalidDataException(line.ToString());
                    }

                    var pt1     = line.GetEndPoint(0) - location;
                    var pt2     = line.GetEndPoint(1) - location;
                    var newLine = Line.CreateBound(pt1, pt2);

                    tmpLines.Append(newLine);
                }

                results.Append(tmpLines);
            }

            return(results);
        }