예제 #1
0
        /// <summary>
        /// 为选中房间创建专门的floorPlan和ceilingPlan
        /// Ctrate a New FloorPlan and CeilingPlan for the selected selRoom
        /// </summary>
        /// <param name="viewOffseet"></param>
        /// <param name="view3d"></param>
        public void CreateNewViewPlan(double viewOffseet, View3D view3d)
        {
            //过滤所有的ViewFamilyType
            var classFilter = new ElementClassFilter(typeof(ViewFamilyType));
            FilteredElementCollector collector = new FilteredElementCollector(DocSet.doc);

            collector = collector.WherePasses(classFilter);
            ViewPlan view = null;

            using (Transaction tran = new Transaction(DocSet.doc))
            {
                foreach (ViewFamilyType viewFamilyType in collector)
                {
                    //当类型为FloorPlan或者CeilingPlan时创建同类型视图
                    if (viewFamilyType.ViewFamily == ViewFamily.FloorPlan ||
                        viewFamilyType.ViewFamily == ViewFamily.CeilingPlan)
                    {
                        tran.Start("Creat view of type " + viewFamilyType.ViewFamily);
                        //创建视图时需要 视图类型ID 相关标高ID
                        view = ViewPlan.Create(DocSet.doc, viewFamilyType.Id, DocSet.selRoom.LevelId);

                        //TaskDialog.Show("CreatLevelView", "A new level's view has been Created");

                        view.Name = DocSet.selRoom.Name;//生成平面的名称

                        view.get_Parameter(BuiltInParameter.VIEWER_CROP_REGION).Set(1);
                        view.AreAnalyticalModelCategoriesHidden = false;
                        view.PartsVisibility = PartsVisibility.ShowPartsAndOriginal;
                        view.Scale           = 50;
                        view.CropBoxActive   = true;
                        view.CropBoxVisible  = true;

                        string viewName = "PLAN ";
                        view.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(DocSet.selRoom.Name);

                        if (viewFamilyType.ViewFamily == ViewFamily.CeilingPlan)
                        {
                            PlanViewRange range = view.GetViewRange();
                            range.SetLevelId(PlanViewPlane.TopClipPlane, DocSet.selRoom.UpperLimit.Id);
                            range.SetLevelId(PlanViewPlane.ViewDepthPlane, DocSet.selRoom.UpperLimit.Id);
                            range.SetLevelId(PlanViewPlane.CutPlane, DocSet.selRoom.LevelId);
                            range.SetLevelId(PlanViewPlane.BottomClipPlane, DocSet.selRoom.LevelId);
                            range.SetOffset(PlanViewPlane.CutPlane, 7.874);
                            range.SetOffset(PlanViewPlane.BottomClipPlane, 7.874);
                            view.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(DocSet.selRoom.Name);
                            view.SetViewRange(range);

                            viewName = "RCP ";
                            view.get_Parameter(BuiltInParameter.VIEW_DESCRIPTION).Set(DocSet.selRoom.Name + " - RCP");
                        }
                        viewName     += _SoANumber + "_" + DocSet.selRoom.Level.Name;
                        view.ViewName = viewName;
                        tran.Commit();
                        ChangeViewFitRoom(view, tran, viewOffseet);
                    }
                }
            }
        }
예제 #2
0
파일: Set.cs 프로젝트: sinnorfin/ExpApps
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication           uiapp        = commandData.Application;
            UIDocument              uidoc        = uiapp.ActiveUIDocument;
            Application             app          = uiapp.Application;
            Document                doc          = uidoc.Document;
            Selection               SelectedObjs = uidoc.Selection;
            ICollection <ElementId> ids          = uidoc.Selection.GetElementIds();
            ViewPlan                viewPlan     = uidoc.ActiveView as ViewPlan;
            PlanViewRange           VR           = null;

            foreach (ElementId eid in ids)
            {
                Element elem = doc.GetElement(eid);
                if (elem.Category.Name == "Views")
                {
                    ViewPlan selectPlan = elem as ViewPlan;
                    VR = selectPlan.GetViewRange();
                    TaskDialog.Show("Copying VR from", selectPlan.Title);
                }
            }
            if (VR == null)
            {
                TaskDialog.Show("error", "error");
            }
            using (Transaction t = new Transaction(doc, "Set View Range"))
            {
                t.Start();
                viewPlan.SetViewRange(VR);
                t.Commit();
            }
            return(Result.Succeeded);
        }