Пример #1
0
        public void ViewCreate()
        {
            Document doc = this.ActiveUIDocument.Document;



            // get a ViewFamilyType for a 3D View. created new instance of ViewFamilYType calle 'viewFamilyType'

            ViewFamilyType viewFamilyType = (from v in new FilteredElementCollector(doc).
                                             // Creates new filteredElementCollector to select all ViewFamilyTypes
                                             OfClass(typeof(ViewFamilyType)).

                                             Cast <ViewFamilyType>()

                                             where v.ViewFamily == ViewFamily.ThreeDimensional

                                             select v).First();


            Categories categories = doc.Settings.Categories;

            Category dim = categories.get_Item(BuiltInCategory.OST_Dimensions);

            Category line = categories.get_Item(BuiltInCategory.OST_Lines);

            XYZ eye = new XYZ(100, 100, 100);

            XYZ forward = new XYZ(-1, 1, -1);

            XYZ up = new XYZ(-1, 1, 2);

            ViewOrientation3D vOrient = new ViewOrientation3D(eye, up, forward);


            using (Transaction t = new Transaction(doc, "Create view"))

            {
                t.Start();

                View3D view = View3D.CreateIsometric(doc, viewFamilyType.Id);

                view.get_Parameter(BuiltInParameter.MODEL_GRAPHICS_STYLE)
                .Set(4);


                view.SetOrientation(vOrient);

                view.HideCategoryTemporary(dim.Id);

                view.HideCategoryTemporary(line.Id);

                view.SaveOrientationAndLock();


                t.Commit();
            }
        }