Пример #1
0
    /// <summary>
    /// Undo PreODB() changes or close document.
    /// </summary>
    /// <returns>True/False if successful.</returns>
    bool PostODB()
    {
        try
        {
            IClient tmpClient = DXP.GlobalVars.Client;

            if (!ODBFiles.WasOpen)
            {
                tmpClient.CloseDocument(ODBFiles.PCBServerDoc); //Close document if it wasnt already open.
            }
            else                                                //Undo changes.
            {
                tmpClient.ShowDocument(ODBFiles.PCBServerDoc);
                DXP.Utils.RunCommand("PCB:Undo", "");
                ODBFiles.Board.ViewManager_FullUpdate();
            }
            ODBFiles = new clsODBFiles();
            return(true);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(false);
        }
    }
Пример #2
0
    /// <summary>
    /// Get the number of Alternates in the provided variant.
    /// </summary>
    /// <param name="VariantName">Name of variant to check.</param>
    /// <returns>Quantity of Alternates in provided variant.</returns>
    public int Get_VariantAlternates(string VariantName)
    {
        try
        {
            IProject            project = DXP.GlobalVars.DXPWorkSpace.DM_FocusedProject() as IProject;
            IProjectVariant     Variant;
            IComponentVariation CompVariant;

            VarParam <string, string> Parameters = new VarParam <string, string>();
            int cnt = 0;
            for (int i = 0; i < project.DM_ProjectVariantCount(); i++)
            {
                Variant = project.DM_ProjectVariants(i);
                //Find variant with the same name as the one provided.
                if (project.DM_ProjectVariants(i).DM_Description() == VariantName)
                {
                    for (int j = 0; j < Variant.DM_VariationCount(); j++)
                    {
                        CompVariant = Variant.DM_Variations(j);
                        //Count the number of alternates.
                        if (CompVariant.DM_VariationKind() == TVariationKind.eVariation_Alternate)
                        {
                            cnt++;
                        }
                    }
                }
            }
            return(cnt);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(-1);
        }
    }
Пример #3
0
    /// <summary>
    /// Selects all components on the current schematic page.
    /// </summary>
    void SelectAll()
    {
        try
        {
            ISch_Document        SchDoc = SchServer.GetCurrentSchDocument();
            ISch_Iterator        SchIterator;
            ISch_GraphicalObject Component;

            if (SchDoc == null)
            {
                return;
            }
            //Iterate theough all objects on the schematic.
            SchIterator = SchDoc.SchIterator_Create();
            SchIterator.AddFilter_ObjectSet(new SCH.TObjectSet(AllObjects()));
            //Select all objects on the current page.
            Component = SchIterator.FirstSchObject() as ISch_GraphicalObject;
            while (Component != null)
            {
                Component.SetState_Selection(true);
                Component = SchIterator.NextSchObject() as ISch_GraphicalObject;
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #4
0
        public bool validar()
        {
            bool ok = true;
            // [email protected]
            Regex RX = new Regex("^[a-zA-Z0-9]{1,20}@[a-zA-Z0-9]{1,20}.[a-zA-Z]{2,3}$");

            if (!RX.IsMatch(txtMail.Text))
            {
                ErrorMail.SetError(txtMail, "Ingrese Mail con formato correcto([email protected])");
                ok = false;
            }
            else
            {
                ErrorMail.Clear();
            }

            if (txtClave.Text == "")
            {
                ErrorMail.SetError(txtClave, "Ingrese Contraseña)");
                ok = false;
            }
            else
            {
                ErrorMail.Clear();
            }

            return(ok);
        }
Пример #5
0
    /// <summary>
    /// Generates a report comparing schematic height parameter to footprint body height.
    /// </summary>
    /// <param name="Update">Update body heights to schematic height parameter.</param>
    public void GetReport(bool Update = false)
    {
        try
        {
            Dictionary <string, Heights> CompHeights = new Dictionary <string, Heights>();
            DXP.Utils.StatusBarSetState(2, "Scanning Documents");
            ScanDocuments(ref CompHeights);
            if (CompHeights != null)
            {
                DXP.Utils.StatusBarSetState(2, "Generating CSV");
                GenerateCSV(ref CompHeights);
                DXP.Utils.StatusBarSetState(2, "Generating Report");
                GenerateReport(ref CompHeights);

                if (Update)
                {
                    UpdateBodies(CompHeights);
                }
            }
            DXP.Utils.PercentFinish();
            DXP.Utils.StatusBarSetStateDefault();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #6
0
    /// <summary>
    /// Get column letters for specific column names.
    /// </summary>
    /// <param name="Name">Column name</param>
    /// <param name="xlWorksheet">Referene to excel document to search.</param>
    /// <returns></returns>
    string GetColumn(string Name, ref Excel.Worksheet xlWorksheet)
    {
        try
        {
            int Col = 65;

            while (Col < 91)
            {
                if (xlWorksheet.Range[((char)Col).ToString() + "1"].Value2 != null)
                {
                    if (xlWorksheet.Range[((char)Col).ToString() + "1"].Value2.ToUpper() == Name.ToUpper())
                    {
                        return(((char)Col).ToString());
                    }
                }
                Col++;
                if (Col == 91)
                {
                    return("");
                }
            }
            return("");
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return("");
        }
    }
Пример #7
0
    /// <summary>
    /// Toggle rule on/off.
    /// </summary>
    /// <param name="RuleName">Name of rule to toggle</param>
    public void ToggleDesignRule(string RuleName)
    {
        try
        {
            IPCB_Rule  Rule;
            IPCB_Board Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return;
            }

            Rule = GetRule(RuleName);
            if (Rule == null)
            {
                MessageBox.Show("No rule found that matches '" + RuleName + "'.");
                return;
            }
            PCBServer.PreProcess();
            Rule.BeginModify();                                    //        {Rule has to be prepared for modification}
            Rule.SetState_DRCEnabled(!Rule.GetState_DRCEnabled()); // Toggle rule state.
            Rule.EndModify();                                      //        {Let script know we are done modifying the rule}


            Rule = null;
            PCBServer.PostProcess();
            //{Dispatch message to system now that processing is complete}
            Board.DispatchMessage(SCH.SCHConstant.FromSystem, SCH.SCHConstant.BroadCast, SCH.SCHConstant.SCHMYieldToRobots, SCH.SCHConstant.NoEventData);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #8
0
    /// <summary>
    /// Get the height parameter value from all schematic components.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    void GetParamHeights(ref Dictionary <string, Heights> argHeights)
    {
        try
        {
            ISch_ServerInterface schServer = SCH.GlobalVars.SchServer;
            if (schServer == null)
            {
                return;
            }
            ISch_Document currentSheet = schServer.GetCurrentSchDocument();

            SCH.TObjectSet objectSet = new SCH.TObjectSet();
            objectSet.Add(SCH.TObjectId.eSchComponent);
            ISch_Iterator iterator = currentSheet.SchIterator_Create();
            iterator.AddFilter_ObjectSet(objectSet);

            ISch_Component schComponent = iterator.FirstSchObject() as ISch_Component;
            while (schComponent != null)
            {
                ObtainParamHeight(ref argHeights, schComponent);
                if (argHeights == null)
                {
                    return;
                }
                schComponent = iterator.NextSchObject() as ISch_Component;
            }
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #9
0
    public void Create_Variant_BOM()
    {
        try
        {
            PartnumberCompList = new PNCompList();
            RefCompList        = new RefDesCompList();
            //Load base design data
            if (!GetBaseVariants())
            {
                return;
            }
            //Load variant data (Var_flt, Var_eng)
            if (!Get_Variants("VAR_ENG"))
            {
                return;
            }
            if (!Get_Variants("VAR_FLT"))
            {
                return;
            }
            if (!Get_Variants("VAR_PE"))
            {
                return;
            }

            OutputBOM();
            MessageBox.Show("Process Complete");
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #10
0
    /// <summary>
    /// Gets height parameter of specified component.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    /// <param name="argComponent">Component to get height from.</param>
    private void ObtainParamHeight(ref Dictionary <string, Heights> argHeights, ISch_Component argComponent)
    {
        try
        {
            ISch_Designator designator    = argComponent.GetState_SchDesignator();
            ISch_Iterator   paramIterator = argComponent.SchIterator_Create();
            paramIterator.SetState_IterationDepth((int)SCH.TIterationDepth.eIterateAllLevels);
            SCH.TObjectSet objectSet = new SCH.TObjectSet();
            objectSet.Add(SCH.TObjectId.eParameter);
            paramIterator.AddFilter_ObjectSet(objectSet);

            if (argComponent.GetState_CurrentPartID() > 1)
            {
                return;
            }

            //Make sure component is already logged.
            if (!argHeights.ContainsKey(designator.GetState_Text()))
            {
                argHeights.Add(designator.GetState_Text(), new Heights());
            }
            else
            {
                argHeights = null;
                DXP.Utils.ShowWarning("A duplicate refdes detected. Opeartion will stop. Please correct this issue.");
                return;
            }

            argHeights[designator.GetState_Text()].Library = argComponent.GetState_LibraryIdentifier() + "/" + argComponent.GetState_DesignItemId();

            //Go through all parameters looking for component height.
            ISch_Parameter param = paramIterator.FirstSchObject() as ISch_Parameter;
            while (param != null)
            {
                if (param.GetState_Name() == "ComponentHeight")
                {
                    if (param.GetState_Text() == null)
                    {
                        argComponent.SchIterator_Destroy(ref paramIterator);
                        return;
                    }
                    int height;
                    if (Int32.TryParse(param.GetState_Text(), out height))
                    {
                        argHeights[designator.GetState_Text()].ParameterHeight = height;
                    }
                    argComponent.SchIterator_Destroy(ref paramIterator);
                    return;
                }
                param = paramIterator.NextSchObject() as ISch_Parameter;
            }
            argComponent.SchIterator_Destroy(ref paramIterator);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #11
0
    void Loadrules()
    {
        IPCB_Board         Board;
        IPCB_BoardIterator BoardIterator;

        Board = Util.GetCurrentPCB();
        if (Board == null)
        {
            return;
        }
        BoardIterator = Board.BoardIterator_Create();
        try
        {
            IPCB_Rule Rule;
            IClient   Client = DXP.GlobalVars.Client;
            IPCB_PowerPlaneConnectStyleRule ConnStyleRule;
            //Iterate through all rules
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            FilterSet.Add(PCB.TObjectId.eRuleObject); //Filter for rules only
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
            Rule = (IPCB_Rule)BoardIterator.FirstPCBObject();
            //Step through all rules.
            while (Rule != null)
            {
                if (Rule.GetState_RuleKind() == TRuleKind.eRule_PowerPlaneConnectStyle)
                {
                    ConnStyleRule = (IPCB_PowerPlaneConnectStyleRule)Rule;
                    if (Rules.ContainsKey(ConnStyleRule.GetState_Name()))
                    {
                        DXP.Utils.ShowError("Multiple rules of the same name.", "Rule Error");
                    }
                    else
                    {
                        Rules.Add(ConnStyleRule.GetState_Name(), new RuleValues(EDP.Utils.CoordToMils(ConnStyleRule.GetState_ReliefConductorWidth()), ConnStyleRule.GetState_ReliefEntries()));
                        cboRules.Items.Add(ConnStyleRule.GetState_Name());
                    }

                    cboRules.Items.Add(ConnStyleRule.GetState_Name());
                }
                Rule = (IPCB_Rule)BoardIterator.NextPCBObject();
            }


            //Generate report.
            //File.WriteAllLines(Util.ProjPath() + Path.GetFileNameWithoutExtension(Board.GetState_FileName()) + "-Rules.do", (string[])Report.ToArray(typeof(string)));
            //Client.ShowDocument(Client.OpenDocument("Text", Util.ProjPath() + "\\" + Path.GetFileNameWithoutExtension(Board.GetState_FileName()) + "-Rules.do"));
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
        finally
        {
            Board.BoardIterator_Destroy(ref BoardIterator); //Iterator clean-up
        }
    }
Пример #12
0
 void LoadNets(string FilePath)
 {
     try
     {
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
         return;
     }
 }
Пример #13
0
        public void habilitar()
        {
            txtNombre.Visible       = true;
            txtApellido.Visible     = true;
            txtDni.Visible          = true;
            txtMail.Visible         = true;
            cbxActivo.Visible       = true;
            rbtnHombre.Enabled      = true;
            rbtnHombre.Checked      = true;
            rbtnMujer.Enabled       = true;
            btnGuardar.Visible      = true;
            dtpFechaNac.Visible     = true;
            cboTipoTelefono.Visible = true;
            cboRol.Visible          = true;
            txtNumero.Visible       = true;
            txtContacto.Visible     = true;

            btnAnterior.Visible              = true;
            btnSiguiente.Visible             = true;
            btnPrimero.Visible               = true;
            btnUltimo.Visible                = true;
            usuarioToolStripMenuItem.Visible = true;

            ErrorNombre.Clear();
            ErrorApellido.Clear();
            ErrorDNI.Clear();
            ErrorFecha.Clear();
            ErrorMail.Clear();
            ErrorTipo.Clear();
            ErrorTE.Clear();

            TipoTelefonoBusiness TipoTelefonoBusiness = new TipoTelefonoBusiness();

            try
            {
                cboTipoTelefono.DataSource = TipoTelefonoBusiness.listar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            RolBusinness rolBusinness = new RolBusinness();

            try
            {
                cboRol.DataSource = rolBusinness.listar();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Пример #14
0
 public void Export()
 {
     try
     {
         ExportModBOM();
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
         return;
     }
 }
Пример #15
0
    /// <summary>
    /// Get paths of all outjobs in the project.
    /// </summary>
    /// <returns>List of outjobs in project.</returns>
    public List <string> GetOutputJobPath()
    {
        try
        {
            List <string> DirList          = new List <string>();
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            IDXPDocument  CurrentSheet;
            CurrentProject       = CurrentWorkspace.DM_FocusedProject();
            LogicalDocumentCount = CurrentProject.DM_LogicalDocumentCount();

            int          BoardCount = 0;
            string       BoardName  = "";
            DialogResult dlgResult;

            //Loop through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Trying to determine if there are multiple PCB files. Give warning if multiple PCBs.
                if (CurrentSheet.DM_DocumentKind() == "PCB")
                {
                    if (BoardCount == 0)
                    {
                        BoardCount += 1;
                        BoardName   = CurrentSheet.DM_FileName();
                    }
                    else
                    {
                        dlgResult = MessageBox.Show("There are multiple boards in this project. PCB outjobs will only run on the first board :" + BoardName + "\nDo you wish to continue?", "Multiple PCBs", MessageBoxButtons.YesNo);
                        if (dlgResult == DialogResult.No)
                        {
                            return(null);
                        }
                    }
                }
                //Add outjob path to list.
                if (CurrentSheet.DM_DocumentKind() == "OUTPUTJOB")
                {
                    DirList.Add(CurrentSheet.DM_FullPath());
                }
            }
            return(DirList);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(null);
        }
    }
Пример #16
0
 /// <summary>
 /// Allows for the user to select for multiple outjobs to be run in a batch process.
 /// </summary>
 public void StartOutjobBatch()
 {
     try
     {
         //Initialize the form.
         frmBatchOutjob frmOutjobForm = new frmBatchOutjob();
         frmOutjobForm.Show();
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
     }
 }
Пример #17
0
 /// <summary>
 /// Selects all objects on current schematic page then runs the AlignObjects process.
 /// </summary>
 void AlignToGrid()
 {
     try
     {
         SelectAll();
         DXP.Utils.RunCommand("Sch:AlignObjects", "Action=Grid");
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
         return;
     }
 }
Пример #18
0
    /// <summary>
    /// Class entry that will decode the provided parameters
    /// and run ChangeGridSize().
    /// </summary>
    /// <param name="parameters">Altium provided parameter string.</param>
    public void GridChange(string parameters)
    {
        try
        {
            int  GridSize = 0;
            bool Align    = false;
            Dictionary <string, string> Params = new Dictionary <string, string>()
            {
                { "relative", "" }, { "filename", "" }, { "template", "" }
            };

            //Populate parameter list.
            foreach (string Param in parameters.Split(','))
            {
                if (Param.Split('=')[0].ToLower() == "size")
                {
                    GridSize = Int32.Parse(Param.Split('=')[1].ToString());
                }
                else if (Param.Split('=')[0].ToLower() == "align")
                {
                    if (Param.Split('=')[1].ToLower() == "false")
                    {
                        Align = false;
                    }
                    else if (Param.Split('=')[1].ToLower() == "true")
                    {
                        Align = true;
                    }
                }
            }

            if (GridSize != 0)
            {
                DXP.Utils.StatusBarSetState(2, "Updating Grid");

                ChangeGridSize(GridSize, Align);

                DXP.Utils.StatusBarSetStateDefault();
            }
            else
            {
                DXP.Utils.ShowError("Parameters are incorrect. Please correct and try again.", "Parameter Error");
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #19
0
    public void GetCompData()
    {
        try
        {
            IPCB_Board           Board;
            IPCB_BoardIterator   BoardIterator;
            IPCB_ServerInterface PCBServer = PCB.GlobalVars.PCBServer;
            IPCB_Net             Net;
            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return;
            }

            //Iterate theough all components on the board.
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            //Filter for components only.
            FilterSet.Add(PCB.TObjectId.eNetObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            //Component.GetState_ObjectID().ToString()
            //Component.GetState_ObjectIDString()
            int l = 0;
            Net = (IPCB_Net)BoardIterator.FirstPCBObject();
            //Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Net != null)
            {
                LogFile[l] = Net.GetState_ObjectIDString() + " " + Net.GetState_ObjectID().ToString();
                l++;
                //Component.BeginModify();
                //Component.SetState_NameOn(NameOn); //Show or hide refdes.
                //Component.EndModify();

                Net = (IPCB_Net)BoardIterator.NextPCBObject();
                //Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref BoardIterator);
            //Board.GraphicalView_ZoomRedraw();
            log(LogFile);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #20
0
    /// <summary>
    /// Will show or hide reference designators based on NameOn parameter.
    /// </summary>
    /// <param name="NameOn">true = show refdes', false = hide refdes'</param>
    public void ShowHide(IPCB_Board Board, bool NameOn, bool Discretes = false)
    {
        try
        {
            IPCB_BoardIterator BoardIterator;
            IPCB_Component     Component;

            if (Board == null)
            {
                return;
            }
            //Iterate theough all components on the board.
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            //Filter for components only.
            FilterSet.Add(PCB.TObjectId.eComponentObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Component != null)
            {
                if (!Discretes)
                {
                    Component.BeginModify();
                    Component.SetState_NameOn(NameOn); //Show or hide refdes.
                    Component.EndModify();
                }
                else
                {
                    if (Component.GetState_Name().GetState_Text().StartsWith("R") || Component.GetState_Name().GetState_Text().StartsWith("C"))
                    {
                        Component.BeginModify();
                        Component.SetState_NameOn(NameOn); //Show or hide refdes.
                        Component.EndModify();
                    }
                }
                Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
            //Iterator clean-up
            Board.BoardIterator_Destroy(ref BoardIterator);
            Board.GraphicalView_ZoomRedraw();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #21
0
    /// <summary>
    /// Sets the grid snap size for the current schematic page.
    /// </summary>
    /// <param name="SizeInMils">Desired grid size in mils.</param>
    void SetGrid(int SizeInMils)
    {
        try
        {
            ISch_Document SchDoc = SCH.GlobalVars.SchServer.GetCurrentSchDocument(); //Get current SC document.

            SchDoc.SetState_SnapGridSize(EDP.Utils.MilsToCoord(SizeInMils));         //Change document grid size.
            SchDoc.UpdateDocumentProperties();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #22
0
    /// <summary>
    /// Gets the focused projects output path.
    /// </summary>
    /// <returns>Path as string</returns>
    public static string OutputPath()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject   = CurrentWorkspace.DM_FocusedProject();

            return(CurrentProject.DM_GetOutputPath());
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return("");
        }
    }
Пример #23
0
    //void GetNets()
    //{
    //    try
    //    {
    //        IPCB_Board Board;
    //        IPCB_BoardIterator BoardIterator;
    //        IPCB_ServerInterface PCBServer = PCB.GlobalVars.PCBServer;
    //        IPCB_Net Net;
    //        Board = Util.GetCurrentPCB();
    //        if (Board == null)
    //            return;

    //        //Iterate theough all nets on the board.
    //        BoardIterator = Board.BoardIterator_Create();
    //        PCB.TObjectSet FilterSet = new PCB.TObjectSet();

    //        //Filter for nets only.
    //        FilterSet.Add(PCB.TObjectId.eNetObject);
    //        BoardIterator.AddFilter_ObjectSet(FilterSet);
    //        BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet); //Filter all layers.
    //        BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

    //        cboNets.Items.Clear();
    //        Net = (IPCB_Net)BoardIterator.FirstPCBObject();
    //        while (Net != null)
    //        {
    //            //Net.GetState_ReliefConductorWidth()
    //            //    Net.GetState_LayerUsed
    //            //Net.GetState_ReliefEntries()
    //            string netname = Net.GetState_Name();
    //            int cnt = 0;
    //            cboNets.Items.Add(Net.GetState_Name());
    //            foreach (TV6_Layer layer in PCBConstant.V6InternalPlanes)
    //            {
    //                if (Net.GetState_LayerUsed(layer))
    //                    cnt++;
    //            }
    //            Net = (IPCB_Net)BoardIterator.NextPCBObject();
    //        }
    //        //Iterator clean-up
    //        Board.BoardIterator_Destroy(ref BoardIterator);
    //    }
    //    catch (Exception ex)
    //    {
    //        ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);

    //    }

    //}

    void LoadData()
    {
        IPCB_Board Board = Util.GetCurrentPCB();

        if (Board == null)
        {
            return;
        }

        try
        {
            //PCB.IPCB_BoardHelper.GetState_InternalPlaneNetName(this PCB.IPCB_Board, PCB.V7_LayerBase)
            IPCB_LayerStack_V7  tmpLayerstack = Board.GetState_LayerStack_V7();
            IPCB_LayerObject_V7 objLayer;
            objLayer = tmpLayerstack.FirstLayer();
            IPCB_InternalPlane IPlane;
            while (objLayer != null)
            {
                if (objLayer.LayerID().ToString().Contains("InternalPlane"))
                {
                    IPlane = (IPCB_InternalPlane)objLayer;

                    //if (IPlane.GetState_NetName() == "(Multiple Nets)")
                    //{

                    //}
                    //else
                    //{
                    if (!Nets.ContainsKey(IPlane.GetState_NetName()))
                    {
                        Nets.Add(IPlane.GetState_NetName(), new LayerValues(1, EDP.Utils.CoordToMils(objLayer.GetState_CopperThickness())));
                    }
                    else
                    {
                        cboNets.Items.Add(IPlane.GetState_NetName());
                        Nets[IPlane.GetState_NetName()].Thickness += EDP.Utils.CoordToMils(objLayer.GetState_CopperThickness());
                        Nets[IPlane.GetState_NetName()].Count++;
                    }
                    //}
                }
                objLayer = tmpLayerstack.NextLayer(objLayer);
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #24
0
    /// <summary>
    /// Generate CSV height report.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    private void GenerateCSV(ref Dictionary <string, Heights> argHeights)
    {
        try
        {
            DXP.Utils.PercentInit("Generating CSV", argHeights.Count);
            int       i      = 4;
            ArrayList report = new ArrayList();
            report.Add("Excel Component Heights Report");
            report.Add("========================");
            report.Add("Ref,Footprint,Symbol Height (mils),Body Height (mils),Difference (Sym-Body),Library");
            foreach (KeyValuePair <string, Heights> item in argHeights)
            {
                report.Add(item.Key + "," +
                           item.Value.Footprint + "," +
                           ((item.Value.ParameterHeight < 0) ? "N/A" : item.Value.ParameterHeight.ToString()) + "," +
                           ((item.Value.BodyHeight < 0) ? "N/A" : item.Value.BodyHeight.ToString()) + "," +
                           ("=C" + i + "-D" + i) + "," +
                           item.Value.Library);
                i++;

                DXP.Utils.PercentUpdate();
            }

            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject   = CurrentWorkspace.DM_FocusedProject();

            string fileName = CurrentProject.DM_GetOutputPath() + "\\HeightReport.csv";
            if (!Directory.Exists(Path.GetDirectoryName(fileName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(fileName));
            }
            File.WriteAllLines(fileName, (string[])report.ToArray(typeof(string)));
            IServerDocument reportDocument = DXP.GlobalVars.Client.OpenDocument("Text", fileName);
            if (reportDocument != null)
            {
                CurrentProject.DM_AddGeneratedDocument(fileName);
                DXP.GlobalVars.Client.ShowDocument(reportDocument);
            }

            DXP.Utils.PercentFinish();
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #25
0
    private void chkReportList_MouseUp(object sender, MouseEventArgs e)
    {
        ArrayList Output = new ArrayList();

        CheckedListBox.CheckedItemCollection CheckedItems = chkReportList.CheckedItems;
        try
        {
            foreach (object item in CheckedItems)
            {
                switch (item.ToString())
                {
                case "xSignals":
                    Output.AddRange(new Export().xSignalDoReport());
                    break;

                case "Rules":
                    Output.AddRange(new Export().RuleDoReport());
                    break;

                case "Layer Select":
                    Output.AddRange(new Export().LayerSelectDo());
                    break;

                case "Layer Orientation":
                    Output.AddRange(new Export().LayerDirectionDo());
                    break;

                case "Same Net Checking":
                    Output.AddRange(new Export().SameNetDo());
                    break;

                case "Diff Pairs":
                    Output.AddRange(new Export().DiffPairDoFile());
                    break;
                }

                //MessageBox.Show(item.GetType().ToString());
            }
            txtOutput.Lines = (string[])Output.ToArray(typeof(string));
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
        }
    }
Пример #26
0
    /// <summary>
    /// Get the body heights of all the footprints on the PCB.
    /// </summary>
    /// <param name="argHeights">Reference to the dict storing report info.</param>
    void GetBodyHeights(ref Dictionary <string, Heights> argHeights)
    {
        try
        {
            IPCB_Component     Component; // component object
            IPCB_BoardIterator BoardIterator;
            IPCB_Board         Board;     // document board object

            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return;
            }
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            //Filter for components only
            FilterSet.Add(PCB.TObjectId.eComponentObject);
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);

            //Iterate through all components looking for components.
            Component = (IPCB_Component)BoardIterator.FirstPCBObject();
            while (Component != null)
            {
                if (Component.GetState_SourceDesignator() == "U18")
                {
                    System.Diagnostics.Debug.WriteLine(Component.GetState_SourceDesignator());
                }
                ObtainBodyHeight(ref argHeights, Component);
                if (argHeights == null)
                {
                    return;
                }
                Component = (IPCB_Component)BoardIterator.NextPCBObject();
            }
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Пример #27
0
 /// <summary>
 /// Create a new component variant.
 /// </summary>
 /// <param name="Dest">Component to create variant for.</param>
 /// <param name="Source">Parameter data.</param>
 /// <param name="RefDes">Refdes of component being modified.</param>
 void CreateCompVar(ref IComponentVariation Dest, VarParam <string, string> Source, string RefDes)
 {
     try
     {
         IParameterVariation tmpParam;
         Dest.DM_SetPhysicalDesignator(RefDes);
         foreach (string key in Source.Keys)
         {
             tmpParam = Dest.DM_AddParameterVariation();
             tmpParam.DM_SetParameterName(key);
             tmpParam.DM_SetVariedValue(Source[key] + "_$");
         }
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
         return;
     }
 }
Пример #28
0
    /// <summary>
    /// Get the path of the project for the selected document.
    /// "T:\\users\\RLYNE\\test projects\\OMAP_L138_SOM (2-17-2020 9-04-00 AM)\\"
    /// </summary>
    /// <returns>Path of project.</returns>
    public static string ProjPath()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;

            IDXPProject CurrentProject;
            CurrentProject = CurrentWorkspace.DM_FocusedProject();
            if (CurrentProject == null)
            {
                return("");
            }
            return(System.IO.Path.GetDirectoryName(CurrentProject.DM_ProjectFullPath()) + "\\");
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return("");
        }
    }
Пример #29
0
 /// <summary>
 /// Add text to the progress bar.
 /// </summary>
 /// <param name="Text">Text to display on the progress bar.</param>
 public void UpdateLabel(string Text)
 {
     try
     {
         string myString = "N/A";
         if (pbProgress.Maximum != 0) //Stops a divide by 0 error.
         {
             myString = ((pbProgress.Value * 100) / pbProgress.Maximum).ToString();
         }
         myString = Text + " " + myString + "%";
         Graphics canvas = pbProgress.CreateGraphics();
         canvas.DrawString(myString, new Font("Verdana", 8, FontStyle.Bold), new SolidBrush(Color.Black), 20, 4);
         canvas.Dispose();
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
         return;
     }
 }
Пример #30
0
    /// <summary>
    /// Get rule based on name.
    /// </summary>
    /// <param name="RuleName">Name of the rule</param>
    /// <returns>Returns rule object matching RuleName or null.</returns>
    private IPCB_Rule GetRule(string RuleName)
    {
        try
        {
            IPCB_Board         Board;
            IPCB_Rule          Rule;
            IPCB_BoardIterator BoardIterator;

            Board = Util.GetCurrentPCB();
            if (Board == null)
            {
                return(null);
            }

            //Iterate through all rules
            BoardIterator = Board.BoardIterator_Create();
            PCB.TObjectSet FilterSet = new PCB.TObjectSet();
            FilterSet.Add(PCB.TObjectId.eRuleObject); //Filter for rules only
            BoardIterator.AddFilter_ObjectSet(FilterSet);
            BoardIterator.AddFilter_LayerSet(PCBConstant.V6AllLayersSet);
            BoardIterator.AddFilter_Method(TIterationMethod.eProcessAll);
            Rule = (IPCB_Rule)BoardIterator.FirstPCBObject();
            //Step through all rules to find one matching RuleName.
            while (Rule != null)
            {
                if (Rule.GetState_Name() == RuleName)
                {
                    Board.BoardIterator_Destroy(ref BoardIterator); //Iterator clean-up
                    return(Rule);                                   //Return matching rule.
                }
                Rule = (IPCB_Rule)BoardIterator.NextPCBObject();
            }

            return(null); //No match found.
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(null);
        }
    }