/// <summary>
        ///     Creates CurtainSystem list.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="app"></param>
        /// <param name="room"></param>
        /// <param name="pnlType"></param>
        /// <param name="tplFileName"></param>
        public static List <CurtainSystem> CreateCurtainSystemListWithTrans(this Document doc, Application app, SpatialElement room, PanelType pnlType, string tplFileName)
        {
            if (doc == null)
            {
                throw new NullReferenceException(nameof(doc));
            }

            if (room == null)
            {
                throw new NullReferenceException(nameof(room));
            }

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

            if (pnlType == null)
            {
                throw new NullReferenceException(nameof(pnlType));
            }

            if (tplFileName == null)
            {
                throw new NullReferenceException(nameof(tplFileName));
            }

            var roomc   = room.GetBoundingBox(doc).GetBoxCenter();
            var walls   = room.GetBoundaryWallList(doc);
            var results = new List <CurtainSystem>();

            foreach (var wall in walls)
            {
                var parm = new CurtainSystemParameter(wall, roomc, pnlType, tplFileName);

                results.Add(doc.CreateCurtainSystemWithTrans(app, parm));
            }

            return(results);
        }
        /// <summary>
        ///     Creates a new CurtainSystem.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="app"></param>
        /// <param name="parm"></param>
        public static CurtainSystem CreateCurtainSystemWithTrans(this Document doc, Application app, CurtainSystemParameter parm)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

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

            if (parm == null)
            {
                throw new NullReferenceException(nameof(parm));
            }

            var wline       = parm.RefWall.GetLocationCurve() as Line;
            var wdir        = wline.GetLineDirection(parm.RefCenter);
            var innerNormal = wdir.GetInnerNormal();
            var face        = parm.RefWall.GetInnerFace(parm.RefCenter);
            var profile     = face.GetEdgesAsCurveLoops().ToCurveArrArray();
            var minPt       = profile.ToCurveList().GetDistinctPointList().GetMinPoint();

#if R2016
            var plane = new Plane(innerNormal, XYZ.Zero);
#endif
#if !R2016
            var plane = Plane.CreateByNormalAndOrigin(innerNormal, XYZ.Zero);
#endif

            var           symbolParm   = new FamilySymbolParameter(parm.TemplateFileName, profile, plane, 1);
            var           symbol       = doc.CreateExtrusionSymbol(app, symbolParm);
            var           lvl          = doc.GetElement(parm.RefWall.LevelId) as Level;
            var           instanceParm = new FamilyInstanceParameter(minPt, symbol, lvl, StructuralType.NonStructural);
            CurtainSystem result       = null;

            doc.AutoTransaction(() =>
            {
                var inst = doc.CreateFamilyInstance(instanceParm);

                doc.Regenerate();

                // The instance has thickness.
                var faces = inst.GetFaceList(-innerNormal).ToFaceArray();

                result = doc.CreateCurtainSystemWithTrans(faces);
                doc.Delete(inst.Id);
                doc.Delete(symbol.Family.Id);

                if (parm.PanelType == null)
                {
                    return;
                }

                result.CurtainSystemType.get_Parameter(BuiltInParameter.AUTO_PANEL).Set(parm.PanelType.Id);

                var thickness = parm.PanelType.get_Parameter(BuiltInParameter.CURTAIN_WALL_SYSPANEL_THICKNESS).AsDouble();

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

            return(result);
        }