private void Destroy(Application InApp)
        {
            StopMetadataExport();

            InApp.DocumentChanged -= DocumentChangedHandler;
            DocumentChangedHandler = null;

            DatasmithDirectLink = null;
            DatasmithScene      = null;
            RootCache           = null;
            ModifiedLinkedDocuments.Clear();
        }
        private void MakeActive(bool bInActive)
        {
            if (!bInActive)
            {
                DatasmithDirectLink = null;
            }
            else if (DatasmithDirectLink == null)
            {
                DatasmithDirectLink = new FDatasmithFacadeDirectLink();

                if (!DatasmithDirectLink.InitializeForScene(DatasmithScene))
                {
                    throw new Exception("DirectLink: failed to initialize");
                }
            }
        }
Ejemplo n.º 3
0
        // Implement the interface to execute some tasks when Revit shuts down.
        public Result OnShutdown(
            UIControlledApplication InApplication             // handle to the application being shut down
            )
        {
            InApplication.ControlledApplication.DocumentClosing -= DocumentClosingHandler;
            InApplication.ViewActivated -= ViewActivatedHandler;

            DocumentClosingHandler = null;
            ViewActivatedHandler   = null;

            if (ExportMessagesDialog != null && !ExportMessagesDialog.IsDisposed)
            {
                ExportMessagesDialog.Close();
            }
            FDatasmithFacadeDirectLink.Shutdown();
            return(Result.Succeeded);
        }
Ejemplo n.º 4
0
        // Implement the interface to execute some tasks when Revit starts.
        public Result OnStartup(
            UIControlledApplication InApplication             // handle to the application being started
            )
        {
            // Create a custom ribbon tab
            string TabName = "Datasmith";

            InApplication.CreateRibbonTab(TabName);

            // Add a new ribbon panel
            RibbonPanel DirectLinkRibbonPanel = InApplication.CreateRibbonPanel(TabName, "Direct Link");
            RibbonPanel FileExportRibbonPanel = InApplication.CreateRibbonPanel(TabName, "File Export");
            RibbonPanel DatasmithRibbonPanel  = InApplication.CreateRibbonPanel(TabName, "Datasmith");

            string         AssemblyPath                = Assembly.GetExecutingAssembly().Location;
            PushButtonData ExportButtonData            = new PushButtonData("Export3DView", "Export 3D View", AssemblyPath, "DatasmithRevitExporter.DatasmithExportRevitCommand");
            PushButtonData SyncButtonData              = new PushButtonData("Sync3DView", "Synchronize", AssemblyPath, "DatasmithRevitExporter.DatasmithSyncRevitCommand");
            PushButtonData ManageConnectionsButtonData = new PushButtonData("Connections", "Connections", AssemblyPath, "DatasmithRevitExporter.DatasmithManageConnectionsRevitCommand");
            PushButtonData LogButtonData               = new PushButtonData("Messages", "Messages", AssemblyPath, "DatasmithRevitExporter.DatasmithShowMessagesRevitCommand");

            PushButton SyncPushButton          = DirectLinkRibbonPanel.AddItem(SyncButtonData) as PushButton;
            PushButton ManageConnectionsButton = DirectLinkRibbonPanel.AddItem(ManageConnectionsButtonData) as PushButton;
            PushButton ExportPushButton        = FileExportRibbonPanel.AddItem(ExportButtonData) as PushButton;
            PushButton ShowLogButton           = DatasmithRibbonPanel.AddItem(LogButtonData) as PushButton;

            string DatasmithIconBase = Path.Combine(Path.GetDirectoryName(AssemblyPath), "DatasmithIcon");

            ExportPushButton.Image      = new BitmapImage(new Uri(DatasmithIconBase + "16.png"));
            ExportPushButton.LargeImage = new BitmapImage(new Uri(DatasmithIconBase + "32.png"));
            ExportPushButton.ToolTip    = "Export an active 3D View to Unreal Datasmith";

            DatasmithIconBase         = Path.Combine(Path.GetDirectoryName(AssemblyPath), "DatasmithSyncIcon");
            SyncPushButton.Image      = new BitmapImage(new Uri(DatasmithIconBase + "16.png"));
            SyncPushButton.LargeImage = new BitmapImage(new Uri(DatasmithIconBase + "32.png"));
            SyncPushButton.ToolTip    = "Sync an active 3D View with DirectLink";

            DatasmithIconBase                  = Path.Combine(Path.GetDirectoryName(AssemblyPath), "DatasmithManageConnectionsIcon");
            ManageConnectionsButton.Image      = new BitmapImage(new Uri(DatasmithIconBase + "16.png"));
            ManageConnectionsButton.LargeImage = new BitmapImage(new Uri(DatasmithIconBase + "32.png"));
            ManageConnectionsButton.ToolTip    = "Manage connections";

            DatasmithIconBase        = Path.Combine(Path.GetDirectoryName(AssemblyPath), "DatasmithLogIcon");
            ShowLogButton.Image      = new BitmapImage(new Uri(DatasmithIconBase + "16.png"));
            ShowLogButton.LargeImage = new BitmapImage(new Uri(DatasmithIconBase + "32.png"));
            ShowLogButton.ToolTip    = "Show messages";

            DocumentClosingHandler = new EventHandler <DocumentClosingEventArgs>(OnDocumentClosing);
            InApplication.ControlledApplication.DocumentClosing += DocumentClosingHandler;

            ViewActivatedHandler         = new EventHandler <ViewActivatedEventArgs>(OnViewActivated);
            InApplication.ViewActivated += ViewActivatedHandler;

            // Setup Direct Link

            string RevitEngineDir = null;

            try
            {
                using (RegistryKey Key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\EpicGames\\Unreal Engine"))
                {
                    RevitEngineDir = Key?.GetValue("RevitEngineDir") as string;
                }
            }
            finally
            {
                if (RevitEngineDir == null)
                {
                    // If we could not read the registry, fallback to hardcoded engine dir
                    RevitEngineDir = "C:\\ProgramData\\Epic\\Exporter\\RevitEngine\\";
                }
            }

            bool bDirectLinkInitOk = FDatasmithFacadeDirectLink.Init(true, RevitEngineDir);

            Debug.Assert(bDirectLinkInitOk);

            return(Result.Succeeded);
        }
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(FDatasmithFacadeDirectLink obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }