コード例 #1
0
        /// <summary>
        ///     Creates a new sweep symbol.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="app"></param>
        /// <param name="parm"></param>
        /// <param name="rfaPath"></param>
        /// <returns></returns>
        public static FamilySymbol CreateSweepSymbol(this Document doc, Application app, FamilySymbolParameter parm,
                                                     string rfaPath = null)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

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

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

            var templateFilePath = app.GeTemplateFilePath(parm.TemplateFileName);
            var fdoc             = app.NewFamilyDocument(templateFilePath);

            fdoc.AutoTransaction(() =>
            {
                var profileArrArray = ResetCurveArrArray(parm.Profile);
                var profile         = app.Create.NewCurveLoopsProfile(profileArrArray);

                fdoc.FamilyCreate.NewSweep(true, parm.SweepPath, profile, parm.Index, parm.Location);
            });

            return(doc.GetFamilySymbol(fdoc, rfaPath));
        }
コード例 #2
0
        /// <summary>
        ///     Creates a new extrusion symbol.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="app"></param>
        /// <param name="parm"></param>
        /// <param name="rfaPath"></param>
        /// <returns></returns>
        public static FamilySymbol CreateExtrusionSymbol(this Document doc, Application app, FamilySymbolParameter parm,
                                                         string rfaPath = null)
        {
            if (doc == null)
            {
                throw new ArgumentNullException(nameof(doc));
            }

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

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

            var templateFilePath = app.GeTemplateFilePath(parm.TemplateFileName);
            var fdoc             = app.NewFamilyDocument(templateFilePath);

            fdoc.AutoTransaction(() =>
            {
                var profile      = ResetCurveArrArray(parm.Profile);
                var skectchPlane = fdoc.CreateSketchPlane(parm.Plane);

                fdoc.FamilyCreate.NewExtrusion(true, profile, skectchPlane, parm.End);
            });

            return(doc.GetFamilySymbol(fdoc, rfaPath));
        }
コード例 #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);
        }