Ejemplo n.º 1
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;
        }
    }
Ejemplo n.º 2
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;
        }
    }
Ejemplo n.º 3
0
    private void CountPinsOfSymbol()
    {
        SCH.TObjectSet DontCountObject = new SCH.TObjectSet(SCH.TObjectId.eParameter, SCH.TObjectId.eDesignator);

        OpenFileDialog openDialog = InitFileOpenDialog("SCHLIB");

        if (openDialog == null)
        {
            return;
        }
        IClient client = DXP.GlobalVars.Client;

        string[] SymbolFiles = openDialog.FileNames;
        foreach (string SymbolFile in SymbolFiles)
        {
            //IServerDocument SymbolDocument = OpenDocuemnt(SymbolFile, "SCHLIB");
            IServerDocument      SymbolDocument = client.OpenDocumentShowOrHide("SCHLIB", SymbolFile, false);
            ISch_ServerInterface SchServer      = SCH.GlobalVars.SchServer;
            ISch_Lib             SchLib         = SchServer.GetSchDocumentByPath(SymbolFile) as ISch_Lib;
            //ISch_Lib SchLib = SchServer.GetCurrentSchDocument() as ISch_Lib;

            ISch_Iterator LibItera = SchLib.SchLibIterator_Create();
            LibItera.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));
            ISch_Component LibComp = LibItera.FirstSchObject() as ISch_Component;

            while (LibComp != null)
            {
                string SymbolName = LibComp.GetState_SymbolReference();

                ISch_Iterator       ObjIterator = LibComp.SchIterator_Create();
                ISch_BasicContainer SchObj      = ObjIterator.FirstSchObject();

                int PinCount       = 0;
                int PrimitiveCount = 0;

                while (SchObj != null)
                {
                    bool CountIt = true;

                    foreach (SCH.TObjectId ObjectKind in DontCountObject)
                    {
                        if (ObjectKind == SchObj.GetState_ObjectId())
                        {
                            CountIt = false;
                        }
                    }

                    if (SchObj.GetState_ObjectId() == SCH.TObjectId.ePin)
                    {
                        PinCount++;
                    }

                    if (CountIt)
                    {
                        PrimitiveCount++;
                    }

                    SchObj = ObjIterator.NextSchObject();
                }

                LibComp.SchIterator_Destroy(ref ObjIterator);

                System.IO.File.AppendAllText(@"G:\report.txt", SymbolName + "|" + PinCount.ToString() + "|" + PrimitiveCount.ToString() + "\r\n");

                LibComp = LibItera.NextSchObject() as ISch_Component;
            }

            SchLib.SchIterator_Destroy(ref LibItera);

            CloseDocument(SymbolDocument);
        }
    }