Ejemplo n.º 1
0
        /// <summary>
        ///     Creates a new family instance with NonStructural type.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="location"></param>
        /// <param name="symbol"></param>
        /// <param name="lvl"></param>
        /// <returns></returns>
        public static FamilyInstance CreateNonStructuralInstance(this Document doc, XYZ location, FamilySymbol symbol,
                                                                 Level lvl)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

            if (location == null)
            {
                throw new ArgumentNullException(nameof(location));
            }

            if (symbol == null)
            {
                throw new ArgumentNullException(nameof(symbol));
            }

            if (lvl == null)
            {
                throw new ArgumentNullException(nameof(lvl));
            }

            var parm = new FamilyInstanceParameter(location, symbol, lvl, StructuralType.NonStructural);

            return(doc.CreateFamilyInstance(parm));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Creates a new family instance.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="parm"></param>
        /// <returns></returns>
        public static FamilyInstance CreateFamilyInstance(this Document doc, FamilyInstanceParameter parm)
        {
            if (parm == null)
            {
                throw new ArgumentNullException(nameof(parm));
            }

            if (doc.IsFamilyDocument)
            {
                return(doc.FamilyCreate.NewFamilyInstance(parm.Location, parm.Symbol, parm.Level, parm.Type));
            }

            return(doc.Create.NewFamilyInstance(parm.Location, parm.Symbol, parm.Level, parm.Type));
        }
Ejemplo n.º 3
0
        /// <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);
        }