コード例 #1
0
ファイル: TestClass.cs プロジェクト: RandyLyne/SwRI_Tools
    public void Command_GetAllComponents(IServerDocumentView view, ref string parameters)
    {
        ComponentList <string, string> CompList = new ModBom_IO().GetComponents();

        IClient    client    = DXP.GlobalVars.Client;
        IWorkspace workSpace = client.GetDXPWorkspace() as IWorkspace;
        IProject   project   = workSpace.DM_FocusedProject();

        if (project.DM_NeedsCompile())
        {
            project.DM_Compile();
        }

        List <string> designators = new List <string>();

        IDocument document       = project.DM_DocumentFlattened();
        int       componentCount = document.DM_ComponentCount();

        for (int i = 0; i < componentCount; i++)
        {
            IComponent component = document.DM_Components(i);
            designators.Add(component.DM_PhysicalDesignator());
            //component.DM_NexusDeviceId()
        }

        return;
    }
コード例 #2
0
    public ComponentList <string, string> GetComponents()
    {
        try
        {
            IClient    client    = DXP.GlobalVars.Client;
            IWorkspace workSpace = client.GetDXPWorkspace() as IWorkspace;
            IProject   project   = workSpace.DM_FocusedProject();
            if (project.DM_NeedsCompile())
            {
                project.DM_Compile();
            }

            ComponentList <string, string> Output = new ComponentList <string, string>();

            IDocument document       = project.DM_DocumentFlattened();
            int       componentCount = document.DM_ComponentCount();

            pbProgress.Maximum = componentCount;
            pbProgress.Value   = 0;
            UpdateLabel("Getting Comp List");

            for (int i = 0; i < componentCount; i++)
            {//TODO: what to do when multiple keys
                IComponent component = document.DM_Components(i);
                if (!Output.ContainsKey(component.DM_PhysicalDesignator()))
                {
                    Output.Add(component.DM_PhysicalDesignator(), component.DM_NexusDeviceId());
                }
                pbProgress.Value++;
                UpdateLabel("Getting Comp List");
            }

            return(Output);
        }
        catch (Exception ex)
        {
            ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
            return(null);
        }
    }
コード例 #3
0
    //create alternate part. Need to make functional.
    public void Command_CreateComponentVariantion(IServerDocumentView view, ref string parameters)
    {
        IWorkspace workspace = DXP.GlobalVars.DXPWorkSpace as IWorkspace;
        IProject   project   = workspace.DM_FocusedProject();

        if (project.DM_NeedsCompile())
        {
            project.DM_Compile();
        }

        // Get or create "Test" Project Variant
        IProjectVariant projectVariant = null;

        for (int i = 0; i < project.DM_ProjectVariantCount(); i++)
        {
            if (project.DM_ProjectVariants(i).DM_Description().Equals("Test", StringComparison.OrdinalIgnoreCase))
            {
                projectVariant = project.DM_ProjectVariants(i);
                break;
            }
        }

        if (projectVariant == null)
        {
            projectVariant = project.DM_AddProjectVariant();
            projectVariant.DM_SetName("Test");
            projectVariant.DM_SetDescription("Test");
        }

        // Create alternate part for each component in the project, using "Bridge2" in "Miscellaneous Devices.IntLib".
        project.DM_BeginUpdate();
        try
        {
            IDocument documentFlattened = project.DM_DocumentFlattened();
            for (int i = 0; i < documentFlattened.DM_ComponentCount(); i++)
            {
                IComponent component = documentFlattened.DM_Components(i);
                if (component.DM_IsInferredObject())
                {
                    continue;
                }

                IComponentVariation componentVariation = projectVariant.DM_FindComponentVariationByUniqueId(component.DM_UniqueId());
                if (componentVariation == null)
                {
                    componentVariation = projectVariant.DM_AddComponentVariation();
                }

                componentVariation.DM_SetUniqueId(component.DM_UniqueId());
                IComponentLibraryLink componentLibraryLink = componentVariation.DM_AlternateLibraryLink();
                componentLibraryLink.DM_SetUseLibraryName(true);
                componentLibraryLink.DM_SetLibraryIdentifier("Miscellaneous Devices.IntLib");
                componentLibraryLink.DM_SetSourceLibraryName("Miscellaneous Devices.IntLib");
                componentLibraryLink.DM_SetDesignItemID("Bridge2");
                componentVariation.DM_SetVariationKind(TVariationKind.eVariation_Alternate);
            }
        }
        finally
        {
            project.DM_EndUpdate();
        }
    }