Beispiel #1
0
    /// <summary>
    /// Hides refdes' before running ODB++ outputs
    /// </summary>
    /// <returns>True/False if successful.</returns>
    bool PreODB()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            IDXPDocument  PCBDoc = null;
            CurrentProject = CurrentWorkspace.DM_FocusedProject();
            IClient         tmpClient = DXP.GlobalVars.Client;
            IServerDocument PCBServerDoc;

            //Get pcb doc.
            for (int i = 0; i < CurrentProject.DM_LogicalDocumentCount(); i++)
            {
                if (CurrentProject.DM_LogicalDocuments(i).DM_DocumentKind() == "PCB")
                {
                    PCBDoc = CurrentProject.DM_LogicalDocuments(i);
                    break;
                }
            }
            if (PCBDoc == null)
            {
                MessageBox.Show("Unable to get PCB.");
                return(false);
            }
            PCBServerDoc = tmpClient.GetDocumentByPath(PCBDoc.DM_FullPath());
            if (PCBServerDoc == null)     //PCB not already open.
            {
                PCBServerDoc     = tmpClient.OpenDocument("PCB", PCBDoc.DM_FullPath());
                ODBFiles.WasOpen = false;
            }

            tmpClient.ShowDocument(PCBServerDoc);

            IPCB_Board Board;

            if (PCBServer == null)
            {
                return(false);
            }
            //Get board from pcb doc.
            Board = PCBServer.GetPCBBoardByPath(PCBDoc.DM_FullPath());     //Get current board
            if (Board == null)
            {
                return(false);
            }

            //Prep ODB class.
            ODBFiles.Board        = Board;
            ODBFiles.PCBServerDoc = PCBServerDoc;

            PCBServer.PreProcess();
            //Hid refdes if enables in preferences.
            if (ToolsPreferences.ODB_HideRefDes)
            {
                new ShowHideRefDes().ShowHide(Board, false);
            }
            PCBServer.PostProcess();
            Board.ViewManager_FullUpdate();
            return(true);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(false);
        }
    }