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
    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);
    }
Ejemplo n.º 3
0
    private void RemoveSymbolVaultLink()
    {
        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;

            currentLib.SetState_FolderGUID("");
            currentLib.SetState_LifeCycleDefinitionGUID("");
            currentLib.SetState_ReleaseVaultGUID("");
            currentLib.SetState_RevisionNamingSchemeGUID("");

            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("");
                LibCmp.SetState_SymbolItemGUID("");
                LibCmp.SetState_SymbolRevisionGUID("");
                LibCmp.SetState_SymbolVaultGUID("");
                LibCmp.SetState_VaultGUID("");


                LibCmp = LibIterator.NextSchObject() as ISch_Component;
            }

            currentLib.SchIterator_Destroy(ref LibIterator);
        }
    }
Ejemplo n.º 4
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);
        }
    }
Ejemplo n.º 5
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);
        }
    }
Ejemplo n.º 6
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.º 7
0
    /// <summary>
    /// Get parameter data from the base design.
    /// </summary>
    /// <param name="VarList">Reference to the class that will store the gathered parameter data.</param>
    public void GetBaseVariants(ref Var_Type VarList)
    {
        try
        {
            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.
            VarParam <string, string> Parameters = new VarParam <string, string>();
            string RefDes;

            bool DocOpened = false;
            Progress.Value   = 0;
            Progress.Maximum = LogicalDocumentCount;
            UpdateLabel("Loading Variants");
            //iterate through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Check for schematic documents.
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    //Open documents
                    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;
                    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)
                    {
                        if (Component.GetState_SchDesignator().GetState_Text().Contains("?"))
                        {
                            MessageBox.Show("Detected and un-annotated refdes. Please Annotate the project and try again.");
                            VarList = null;
                            return;
                        }
                        RefDes     = Component.GetState_SchDesignator().GetState_Text();
                        Parameters = new VarParam <string, string>();

                        //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)
                            {
                                //Store specific parameter data.
                                if ("PE_ENG" == Param.GetState_Name().ToUpper() || Param.GetState_Name().ToUpper() == "PE_FLT")
                                {
                                    if (Param.GetState_Text() != "x")
                                    {
                                        Parameters.Add(Param.GetState_Name().ToUpper(), Param.GetState_CalculatedValueString());
                                    }
                                }
                            }
                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }
                        //Add stored parameter data to VarList.
                        if (Parameters.Count > 0)
                        {
                            if (!VarList.Components.ContainsKey(RefDes))
                            {
                                VarList.Components.Add(RefDes, Parameters);
                            }
                        }
                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    //if (ServerDoc.GetModified())
                    //    ServerDoc.DoFileSave("");

                    //Close opend documents.
                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
                Progress.Value += 1;
                UpdateLabel("Loading 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.º 8
0
    /// <summary>
    /// Get component list with library IDs.
    /// </summary>
    /// <returns></returns>
    public void CheckParams()
    {
        try
        {
            ComponentList <string, string> Output = new ComponentList <string, string>();
            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.

            pbProgress.Maximum = LogicalDocumentCount;
            pbProgress.Value   = 0;
            UpdateLabel("Checking Parameters");

            bool DocOpened = false;
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    if (Client.IsDocumentOpen(CurrentSheet.DM_FullPath()))
                    {
                        ServerDoc = Client.GetDocumentByPath(CurrentSheet.DM_FullPath());
                        DocOpened = true;
                    }
                    else
                    {
                        ServerDoc = Client.OpenDocument("SCH", CurrentSheet.DM_FullPath());
                    }

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

                    ISch_Iterator             LibraryIterator, PIterator;
                    ISch_Component            Component;
                    VarParam <string, string> CompVars = new VarParam <string, string>();
                    ISch_Parameter            Param;
                    bool Flt = false, Eng = false;
                    //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)
                    {
                        //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 ("PE_ENG" == Param.GetState_Name().ToUpper())
                                {
                                    Eng = true;
                                }
                                else if (Param.GetState_Name().ToUpper() == "PE_FLT")
                                {
                                    Flt = true;
                                }
                            }

                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }

                        if (!Flt)
                        {
                            Param = Component.AddSchParameter();
                            Param.SetState_Name("PE_FLT");
                            Param.SetState_Text("x");
                        }

                        if (!Eng)
                        {
                            Param = Component.AddSchParameter();
                            Param.SetState_Name("PE_ENG");
                            Param.SetState_Text("x");
                        }
                        Flt       = false;
                        Eng       = false;
                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

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

                    ServerDoc = null;
                }
                pbProgress.Value++;
                UpdateLabel("Checking Parameters");
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));

            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Ejemplo n.º 9
0
    /// <summary>
    /// Get parameter data from the base design.
    /// </summary>
    /// <param name="VarList">Reference to the class that will store the gathered parameter data.</param>
    public void GetBaseVariants()
    {
        try
        {
            IDXPWorkSpace CurrentWorkspace = DXP.GlobalVars.DXPWorkSpace;
            IDXPProject   CurrentProject;
            int           LogicalDocumentCount;
            int           LoopIterator;
            Dictionary <string, IComponentVariation> FltCompVar, EngCompVar;
            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.
            VarParam <string, string> Parameters = new VarParam <string, string>();
            string RefDes;

            IParameterVariation TempVar;
            int  Matches;
            bool DocOpened = false;

            FltCompVar = Get_Variants("VAR_FLT");
            EngCompVar = Get_Variants("VAR_ENG");

            if (FltCompVar == null || EngCompVar == null)
            {
                return;
            }

            //iterate through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Check for schematic documents.
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    //Open documents
                    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       SchIterator, PIterator;
                    ISch_Component      Component;
                    ISch_Implementation Footprint;
                    ISch_Parameter      Param;
                    if (SchDoc == null)
                    {
                        return;
                    }
                    //Iterate theough all components on the schematic.
                    SchIterator = SchDoc.SchIterator_Create();
                    SchIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eSchComponent));

                    Component = SchIterator.FirstSchObject() as ISch_Component;



                    while (Component != null)
                    {
                        Matches = 0;
                        if (Component.GetState_SchDesignator().GetState_Text().Contains("?"))
                        {
                            MessageBox.Show("Detected and un-annotated refdes. Please Annotate the project and try again.");
                            return;
                        }
                        RefDes = Component.GetState_SchDesignator().GetState_Text();



                        //Iterate theough all parameters in the component.
                        PIterator = Component.SchIterator_Create();
                        PIterator.AddFilter_ObjectSet(new SCH.TObjectSet(SCH.TObjectId.eImplementation));

                        Footprint = PIterator.FirstSchObject() as ISch_Implementation;
                        if (FltCompVar.ContainsKey(RefDes))
                        {
                            if (FltCompVar[RefDes].DM_AlternateLibraryLink().DM_Footprint() != Footprint.GetState_ModelName())
                            {
                                TempVar = FltCompVar[RefDes].DM_FindParameterVariation("ClassName");
                                if (TempVar != null)
                                {
                                    TempVar.DM_SetVariedValue("Stencil_Flt");
                                }
                                Matches++;
                            }
                        }

                        if (EngCompVar.ContainsKey(RefDes))
                        {
                            if (EngCompVar[RefDes].DM_AlternateLibraryLink().DM_Footprint() != Footprint.GetState_ModelName())
                            {
                                TempVar = EngCompVar[RefDes].DM_FindParameterVariation("ClassName");
                                if (TempVar != null)
                                {
                                    TempVar.DM_SetVariedValue("Stencil_Eng");
                                }
                                Matches++;
                            }
                        }

                        //?Param.GetState_ModelName()
                        //"FIDUCIAL_SMD"

                        //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() == "ClassName")
                            {
                                if (Matches == 2)
                                {
                                    Param.SetState_Text("Stencil_Base");
                                }
                                else
                                {
                                    Param.SetState_Text("");
                                }

                                Component.UpdatePart_PostProcess();
                                break;
                            }
                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }

                        Component = SchIterator.NextSchObject() as ISch_Component;
                    }

                    //if (ServerDoc.GetModified())
                    //    ServerDoc.DoFileSave("");

                    //Close opend documents.
                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return;
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return;
        }
    }
Ejemplo n.º 10
0
    /// <summary>
    /// Get parameter data from the base design.
    /// </summary>
    /// <param name="VarList">Reference to the class that will store the gathered parameter data.</param>
    bool GetBaseVariants()
    {
        try
        {
            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.
            string          RefDes;
            CompData        NewComp;

            bool DocOpened = false;
            //iterate through project documents.
            for (LoopIterator = 1; LoopIterator <= LogicalDocumentCount; LoopIterator++)
            {
                CurrentSheet = CurrentProject.DM_LogicalDocuments(LoopIterator - 1);
                //Check for schematic documents.
                if (CurrentSheet.DM_DocumentKind() == "SCH")
                {
                    DocOpened = false;
                    //Open documents
                    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;
                    if (SchDoc == null)
                    {
                        return(false);
                    }
                    //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)
                    {
                        NewComp = new CompData("");
                        if (Component.GetState_SchDesignator().GetState_Text().Contains("?"))
                        {
                            MessageBox.Show("Detected and un-annotated refdes. Please Annotate the project and try again.");
                            return(false);
                        }
                        RefDes              = Component.GetState_SchDesignator().GetState_Text();
                        NewComp.RefDes      = RefDes;
                        NewComp.Base_LibRef = Component.GetState_DesignItemId();
                        NewComp.UniqueID    = Component.GetState_UniqueId();
                        //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)
                            {
                                //Store specific parameter data.
                                if ("PARTNUMBER" == Param.GetState_Name().ToUpper())
                                {
                                    NewComp.Base_Partnumber = Param.GetState_CalculatedValueString();
                                }
                            }

                            Param = PIterator.NextSchObject() as ISch_Parameter;
                        }


                        AddPart(NewComp);

                        Component = LibraryIterator.NextSchObject() as ISch_Component;
                    }

                    //if (ServerDoc.GetModified())
                    //    ServerDoc.DoFileSave("");

                    //Close opend documents.
                    if (!DocOpened)
                    {
                        Client.CloseDocument(ServerDoc);
                    }

                    ServerDoc = null;
                }
            }

            Client.ShowDocument(Client.GetDocumentByPath(ActiveDoc.DM_FullPath()));
            return(true);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(false);
        }
    }