Пример #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;
        }
    }
Пример #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;
        }
    }