public Dimension AddDimension(Document doc, Autodesk.Revit.DB.View view, Face face1, Face face2)
        {
            Dimension dim;

            Autodesk.Revit.DB.XYZ startPoint = new Autodesk.Revit.DB.XYZ();
            Autodesk.Revit.DB.XYZ endPoint   = new Autodesk.Revit.DB.XYZ();
            Line           line;
            Reference      ref1;
            Reference      ref2;
            ReferenceArray refArray = new ReferenceArray();
            PlanarFace     pFace1   = face1 as PlanarFace;

            ref1 = pFace1.Reference;
            PlanarFace pFace2 = face2 as PlanarFace;

            ref2 = pFace2.Reference;
            if (null != ref1 && null != ref2)
            {
                refArray.Append(ref1);
                refArray.Append(ref2);
            }
            startPoint = pFace1.Origin;
            endPoint   = new Autodesk.Revit.DB.XYZ(startPoint.X, startPoint.Y, pFace2.Origin.Z);
            SubTransaction subTransaction = new SubTransaction(doc);

            subTransaction.Start();
            line = Line.CreateBound(startPoint, endPoint);
            dim  = doc.FamilyCreate.NewDimension(view, line, refArray);
            subTransaction.Commit();
            return(dim);
        }
Exemplo n.º 2
0
        private static bool ChangeView(Autodesk.Revit.DB.View view)
        {
            try
            {
                Application.ActiveUIDocument.RequestViewChange(view);

                var result = TaskDialog.Show("View Selection", "Please confirm whether this view shows your item",
                                             TaskDialogCommonButtons.No, TaskDialogResult.No);

                return(result == TaskDialogResult.Yes);
            }

            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 3
0
        internal static VType GetViewType(Autodesk.Revit.DB.View v)
        {
            VType vtype = new VType(VTypeSub.OTHER, VTtypeCat.OTHER, "Other View Type");

            switch (v.ViewType)
            {
            case ViewType.AreaPlan:
            case ViewType.CeilingPlan:
            case ViewType.EngineeringPlan:
            case ViewType.FloorPlan:
                vtype = new VType(VTypeSub.D2_HORIZONTAL,
                                  VTtypeCat.D2_WITHPLANE, "Plan 2D View");
                break;

            case ViewType.Elevation:
            case ViewType.Section:
                vtype = new VType(VTypeSub.D2_VERTICAL,
                                  VTtypeCat.D2_WITHPLANE, "Vertical 2D View");
                break;

            case ViewType.ThreeD:
                vtype = new VType(VTypeSub.D3_VIEW,
                                  VTtypeCat.D3_WITHPLANE, "3D View");
                break;

            case ViewType.Detail:
            case ViewType.DraftingView:
                vtype = new VType(VTypeSub.D2_DRAFTING,
                                  VTtypeCat.D2_WITHOUTPLANE, "Drafting View");
                break;

            case ViewType.DrawingSheet:
                vtype = new VType(VTypeSub.D2_SHEET,
                                  VTtypeCat.D2_WITHOUTPLANE, "Sheet View");
                break;
            }

            return(vtype);
        }