Esempio n. 1
0
        static void UpdateViewConstructionPlanesFrom(RhinoDoc rhinoDoc, DB.Document revitDoc)
        {
            if (!string.IsNullOrEmpty(rhinoDoc.TemplateFileUsed))
            {
                return;
            }

            if (rhinoDoc.IsCreating)
            {
                Revit.EnqueueAction(doc => UpdateViewConstructionPlanesFrom(rhinoDoc, doc));
                return;
            }

            bool imperial = rhinoDoc.ModelUnitSystem == UnitSystem.Feet || rhinoDoc.ModelUnitSystem == UnitSystem.Inches;

            var modelGridSpacing = imperial ?
                                   1.0 * RhinoMath.UnitScale(UnitSystem.Yards, rhinoDoc.ModelUnitSystem) :
                                   1.0 * RhinoMath.UnitScale(UnitSystem.Meters, rhinoDoc.ModelUnitSystem);

            var modelSnapSpacing = imperial ?
                                   1 / 16.0 * RhinoMath.UnitScale(UnitSystem.Inches, rhinoDoc.ModelUnitSystem) :
                                   1.0 * RhinoMath.UnitScale(UnitSystem.Millimeters, rhinoDoc.ModelUnitSystem);

            var modelThickLineFrequency = imperial ? 6 : 5;

            // Views
            {
                foreach (var view in rhinoDoc.Views)
                {
                    var cplane = view.MainViewport.GetConstructionPlane();

                    cplane.GridSpacing        = modelGridSpacing;
                    cplane.SnapSpacing        = modelSnapSpacing;
                    cplane.ThickLineFrequency = modelThickLineFrequency;

                    view.MainViewport.SetConstructionPlane(cplane);

                    var min  = cplane.Plane.PointAt(-cplane.GridSpacing * cplane.GridLineCount, -cplane.GridSpacing * cplane.GridLineCount, 0.0);
                    var max  = cplane.Plane.PointAt(+cplane.GridSpacing * cplane.GridLineCount, +cplane.GridSpacing * cplane.GridLineCount, 0.0);
                    var bbox = new BoundingBox(min, max);

                    // Zoom to grid
                    view.MainViewport.ZoomBoundingBox(bbox);

                    // Adjust to extens in case There is anything in the viewports like Grasshopper previews.
                    view.MainViewport.ZoomExtents();
                }
            }
        }
Esempio n. 2
0
 Result IExternalApplication.OnShutdown(UIControlledApplication applicationUI)
 {
     try
     {
         return(Revit.OnShutdown(applicationUI));
     }
     catch (Exception)
     {
         return(Result.Failed);
     }
     finally
     {
         ApplicationUI = null;
     }
 }
        static void Stop()
        {
            using (var service = DBES.ExternalServiceRegistry.GetService(DBES.ExternalServices.BuiltInExternalServices.DirectContext3DService) as DBES.MultiServerService)
            {
                var activeServerIds = service.GetActiveServerIds();
                foreach (var preview in objectPreviews)
                {
                    activeServerIds.Remove(preview.Key);
                }
                service.SetActiveServers(activeServerIds);

                foreach (var preview in objectPreviews)
                {
                    service.RemoveServer(preview.Key);
                    preview.Value.ClearPrimitives();
                }
            }

            objectPreviews = null;

            Revit.RefreshActiveView();
        }
Esempio n. 4
0
        static bool Run()
        {
            if (idlePending)
            {
                Revit.ActiveDBApplication?.PurgeReleasedAPIObjects();
                idlePending = core.DoIdle();
            }

            var active = core.DoEvents();

            if (active)
            {
                idlePending = true;
            }

            if (Revit.ProcessIdleActions())
            {
                core.RaiseIdle();
            }

            return(active);
        }
Esempio n. 5
0
        static bool Run()
        {
            CheckInGuests();

            if (idlePending)
            {
                idlePending = core.DoIdle();
            }

            var active = core.DoEvents();

            if (active)
            {
                idlePending = true;
            }

            if (Revit.ProcessIdleActions())
            {
                core.RaiseIdle();
            }

            return(active);
        }