Esempio n. 1
0
    /// <summary>
    /// Create a new component variant.
    /// </summary>
    /// <param name="Dest">Component to create variant for.</param>
    /// <param name="Source">Parameter data.</param>
    /// <param name="RefDes">Refdes of component being modified.</param>
    void CreateCompVar(ref IComponentVariation Dest, VarParam <string, string> Source, string RefDes = "")
    {
        IParameterVariation tmpParam;

        if (RefDes != "")
        {
            Dest.DM_SetPhysicalDesignator(RefDes); //Set refdes
        }
        foreach (string key in Source.Keys)        //Set each parameter
        {
            tmpParam = Dest.DM_AddParameterVariation();
            tmpParam.DM_SetParameterName(key);
            tmpParam.DM_SetVariedValue(Source[key] + "_$");
        }
    }
Esempio n. 2
0
 /// <summary>
 /// Create a new component variant.
 /// </summary>
 /// <param name="Dest">Component to create variant for.</param>
 /// <param name="Source">Parameter data.</param>
 /// <param name="RefDes">Refdes of component being modified.</param>
 void CreateCompVar(ref IComponentVariation Dest, VarParam <string, string> Source, string RefDes)
 {
     try
     {
         IParameterVariation tmpParam;
         Dest.DM_SetPhysicalDesignator(RefDes);
         foreach (string key in Source.Keys)
         {
             tmpParam = Dest.DM_AddParameterVariation();
             tmpParam.DM_SetParameterName(key);
             tmpParam.DM_SetVariedValue(Source[key] + "_$");
         }
     }
     catch (Exception ex)
     {
         ErrorMail.LogError("Error in " + System.Reflection.MethodBase.GetCurrentMethod().Name + ".", ex);
         return;
     }
 }
Esempio n. 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();
        }
    }