Ejemplo n.º 1
0
    /// <summary>
    /// Updates base design parameters based on provided data.
    /// </summary>
    /// <param name="VarList">Parameter data</param>
    void SetBaseDesign(Var_Type VarList)
    {
        try
        {
            string        RefDes;
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer;
            IClient         Client         = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            Progress.Maximum = LogicalDocumentCount;
            Progress.Value   = 0;
            UpdateLabel("Updating Variants");
            bool DocOpened = false;
            //Iterate through all documents looking for scheatic docs.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    //Open document if not already open.
                    DocOpened = false;
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

                    //Client.ShowDocument(ServerDoc);

                    ISch_Lib SchDoc;
                    SchDoc = SchServer.LoadSchDocumentByPath(CurrentSheet.DM_FullPath()) as ISch_Lib;

                    ISch_Iterator             LibraryIterator, PIterator;
                    ISch_Component            Component;
                    ISch_Parameter            Param;
                    VarParam <string, string> CompVars = new VarParam <string, string>();
                    if (SchDoc == null)
                    {
                        return;
                    }
                    //Iterate theough all components on the schematic.
                    LibraryIterator = SchDoc.SchIterator_Create();
                    LibraryIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = LibraryIterator.FirstSchObject() as ISch_Component;
                    while (Component != null)
                    {
                        RefDes = Component.GetState_SchDesignator().GetState_Text();
                        if (VarList.Components.ContainsKey(Component.GetState_SchDesignator().GetState_Text()))
                        {
                            if (VarList.Components[Component.GetState_SchDesignator().GetState_Text()].Saved == false)
                            {
                                Component.UpdatePart_PreProcess();
                                CompVars = VarList.Components[Component.GetState_SchDesignator().GetState_Text()];
                                //Iterate theough all parameters in the component.
                                PIterator = Component.SchIterator_Create();
                                PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eParameter));

                                Param = PIterator.FirstSchObject() as ISch_Parameter;
                                while (Param != null)
                                {
                                    if (Param.GetState_Name() != null)
                                    {
                                        if (Param.GetState_Name().ToUpper() != null)
                                        {
                                            //Set parameter data in component if it is in the provided parameter data.
                                            //Param = null;
                                            if (CompVars.ContainsKey(Param.GetState_Name().ToUpper()))
                                            {
                                                if (Param.GetState_Text() == "x")
                                                {
                                                    Param.SetState_Text(CompVars[Param.GetState_Name().ToUpper()]);
                                                }
                                                else if (OverwriteValue(Param.GetState_Text().ToUpper(), CompVars[Param.GetState_Name().ToUpper()], Component.GetState_SchDesignator().GetState_Text(), Param.GetState_Name().ToUpper()))
                                                {
                                                    Param.SetState_Text(CompVars[Param.GetState_Name().ToUpper()]);
                                                }
                                            }
                                        }
                                    }
                                    Param = PIterator.NextSchObject() as ISch_Parameter;
                                }
                                Component.UpdatePart_PostProcess();
                                VarList.Components[Component.GetState_SchDesignator().GetState_Text()].Saved = true;
                            }
                        }
                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    if (ServerDoc.GetModified())
                    {
                        ServerDoc.DoFileSave("");
                    }

                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
                Progress.Value += 1;
                UpdateLabel("Updating Variants");
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Iterates through all schematic docs of the active project and
    /// changes the grid snap and aligns components based on parameters.
    /// </summary>
    /// <param name="SizeInMils">Desired grid size in mils.</param>
    /// <param name="AlignToGrid">True/False if components should be aligned to the new grid.</param>
    void ChangeGridSize(int SizeInMils, bool AlignToGrid = false)
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();
            ISch_Document   SchDoc;
            IClient         Client = DXP.GlobalVars.Client;
            IServerDocument ServerDoc;
            IDXPDocument    ActiveDoc = DXP.GlobalVars.DXPWorkSpace.DM_FocusedDocument(); //Save current open document so it can be reopened after process is done.

            DXP.Utils.PercentInit("Updating Grid", LogicalDocumentCount);

            bool DocOpened = false;

            //Loop through each SCH document in project.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    SchDoc    = CurrentSheet as ISch_Document;
                    //Open document if not already open.
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }
                    Client.ShowDocument(ServerDoc);
                    SetGrid(SizeInMils);      //Set document grid size.
                    ServerDoc.DoFileSave(""); //Save file.

                    //Align parts to grid of active document.
                    if (AlignToGrid)
                    {
                        this.AlignToGrid();
                    }
                    if (!DocOpened & !AlignToGrid)
                    {
                        Client.CloseDocument(ServerDoc);
                    }
                    ServerDoc = null;
                }
                DXP.Utils.PercentUpdate();
            }
            DXP.Utils.PercentFinish();
            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Ejemplo n.º 3
0
    public void frmBatchOutjob_Load(object sender, System.EventArgs e)
    {
        IDXPProject Project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject();

        IProject project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject() as IProject;

        //Load cboVariant with all variants in the active projet.
        if (project.DM_ProjectVariantCount() > 0)
        {
            cboVariant.Enabled = true;
            cboVariant.Items.Add("Original");
            cboVariant.Items.Add("[No Variations]");

            for (int i = 0; i < project.DM_ProjectVariantCount(); i++)
            {
                cboVariant.Items.Add(project.DM_ProjectVariants(i).DM_Description());
            }
            cboVariant.SelectedIndex = 0;
        }
        else
        {
            cboVariant.Enabled = false;
        }

        bool ODB = false;

        DXP.Utils.StatusBarSetState(2, "Collecting Outjobs");

        List <string> lstOutjobDocPaths = GetOutputJobPath();    //Get a list of all outjob docs in the project

        if (lstOutjobDocPaths == null)
        {
            return;
        }

        this.Text = Project.DM_ProjectFileName();


        //Open the outjob docs
        foreach (string strPath in lstOutjobDocPaths)
        {
            lstServerDocs.Add(tmpClient.OpenDocument("OUTPUTJOB", strPath));
        }

        DXP.Utils.PercentInit("Load Outjobs", lstServerDocs.Count);    //Progressbar init.
        List <TreeNode> lstTreeNode;

        //Get outjob mediums
        foreach (IServerDocument ServerDoc in lstServerDocs)
        {
            OutJobDoc = (IWSM_OutputJobDocument)ServerDoc;

            lstTreeNode = new List <TreeNode>();
            for (int i = 0; i < OutJobDoc.GetState_OutputMediumCount(); i++)
            {
                ODB = false;
                for (int j = 0; j < OutJobDoc.GetState_MediumOutputersCount(OutJobDoc.GetState_OutputMedium(i)); j++)
                {
                    //Check to see if outjob container is will generate ODB++ files. Flag it for hide refdes later.
                    if (OutJobDoc.GetState_MediumOutputer(OutJobDoc.GetState_OutputMedium(i), j).DM_GetDescription() == "ODB++ Files")
                    {
                        ODB = true;
                    }
                }
                //If outjob is not a Print then store the information and add to list.
                if (OutJobDoc.GetState_OutputMedium(i).GetState_TypeString() != "Print")
                {
                    dictOutputMedium.Add(System.IO.Path.GetFileName(ServerDoc.GetFileName()) + "-" + OutJobDoc.GetState_OutputMedium(i).GetState_Name(), new clsOutJob(OutJobDoc.GetState_OutputMedium(i), ServerDoc, ODB));
                    lstTreeNode.Add(new TreeNode(OutJobDoc.GetState_OutputMedium(i).GetState_Name()));    //Build list of nodes for form tree view
                }
                else
                {    //Dont remember why this is excluded.
                     //throw new  NotImplementedException("Batchoutjob \"print\" medium type");
                }
            }
            //Add collected outjob info to treeview.
            treeOutjobs.Nodes.Add(new TreeNode(System.IO.Path.GetFileName(ServerDoc.GetFileName()), lstTreeNode.ToArray()));     //Populate form treenodes
            DXP.Utils.PercentUpdate();
        }
        treeOutjobs.ExpandAll();

        DXP.Utils.PercentFinish();
        DXP.Utils.StatusBarSetState(2, "Select Outjobs to Run");
    }