예제 #1
0
    private void CleanUpSamtecSymbols()
    {
        ISch_ServerInterface SchServer = SCH.GlobalVars.SchServer;

        if (SchServer == null)
        {
            return;
        }

        ISch_Lib currentLib = SchServer.GetCurrentSchDocument() as ISch_Lib;

        if (currentLib == null)
        {
            return;
        }

        if (currentLib.LibIsEmpty())
        {
            DXP.Utils.ShowWarning("SCH library is empty");
            return;
        }

        ISch_Iterator LibIterator = currentLib.SchLibIterator_Create();

        LibIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

        ISch_Component LibCmp = LibIterator.FirstSchObject() as ISch_Component;

        while (LibCmp != null)
        {
            LibCmp.SetState_ComponentDescription("");

            ISch_Iterator       ObjIterator = LibCmp.SchIterator_Create();
            ISch_BasicContainer SchObj      = ObjIterator.FirstSchObject();
            while (SchObj != null)
            {
                switch (SchObj.GetState_ObjectId())
                {
                case SCH.TObjectId.ePin: CleanUpPin(SchObj as ISch_Pin); break;

                case SCH.TObjectId.eParameter: RemoveParameter(SchObj as ISch_Parameter, LibCmp); break;

                case SCH.TObjectId.eImplementation: RemoveLinkedModel(SchObj as ISch_Implementation, LibCmp); break;
                }

                SchObj = ObjIterator.NextSchObject();
            }

            LibCmp.SchIterator_Destroy(ref ObjIterator);

            LibCmp = LibIterator.NextSchObject() as ISch_Component;
        }

        currentLib.SchIterator_Destroy(ref LibIterator);
    }
예제 #2
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);
        }
    }
예제 #3
0
    private void CleanUpSamtecSymbols()
    {
        OpenFileDialog openDialog = InitFileOpenDialog("SCHLIB");

        if (openDialog == null)
        {
            return;
        }

        IClient client = DXP.GlobalVars.Client;

        string[] SchFiles = openDialog.FileNames;
        foreach (string SchFile in SchFiles)
        {
            IServerDocument SchDocument = client.OpenDocument("SCHLIB", SchFile);
            if (SchDocument == null)
            {
                return;
            }

            client.ShowDocumentDontFocus(SchDocument);
            ISch_ServerInterface SchServer  = SCH.GlobalVars.SchServer;
            ISch_Lib             currentLib = SchServer.GetCurrentSchDocument() as ISch_Lib;

            if (currentLib.LibIsEmpty())
            {
                DXP.Utils.ShowWarning("SCH library is empty");
                return;
            }

            ISch_Iterator LibIterator = currentLib.SchLibIterator_Create();
            LibIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

            ISch_Component LibCmp = LibIterator.FirstSchObject() as ISch_Component;
            while (LibCmp != null)
            {
                LibCmp.SetState_ComponentDescription("");

                ISch_Iterator       ObjIterator = LibCmp.SchIterator_Create();
                ISch_BasicContainer SchObj      = ObjIterator.FirstSchObject();
                while (SchObj != null)
                {
                    switch (SchObj.GetState_ObjectId())
                    {
                    case SCH.TObjectId.ePin: CleanUpPin(SchObj as ISch_Pin); break;

                    case SCH.TObjectId.eParameter: RemoveParameter(SchObj as ISch_Parameter, LibCmp); break;

                    case SCH.TObjectId.eImplementation: RemoveLinkedModel(SchObj as ISch_Implementation, LibCmp); break;
                    }

                    SchObj = ObjIterator.NextSchObject();
                }

                LibCmp.SchIterator_Destroy(ref ObjIterator);

                LibCmp = LibIterator.NextSchObject() as ISch_Component;
            }

            currentLib.SchIterator_Destroy(ref LibIterator);
        }
    }