1 Reply Latest reply on Apr 20, 2016 6:32 PM by Ivana Kolin

    API add configuration specific properties

    Richard Anthony

      Is it possible to add configuration specific properties to a file without opening the file.  I have tried the following code and it appears to be adding the property but it is not saving it when I save the file.  I have hundreds of files to do this too and don't want to open each file.

       

      private void UpdateConfigProperties(string vCfgName)

              {

                  // Initialize various document configuration objects

                  SwDMConfigurationMgr swCfgMgr = default(SwDMConfigurationMgr);

                  swCfgMgr = dmDoc.ConfigurationManager;

                  string[] vCfgNameArr = null;

                  SwDMConfiguration14 swCfg = default(SwDMConfiguration14);

                  vCfgNameArr = (string[])swCfgMgr.GetConfigurationNames();

       

       

                  swCfg = (SwDMConfiguration14)swCfgMgr.GetConfigurationByName(vCfgName);

       

       

                  string[] vCustSpecificNameArr = null;

                  string sCustSpecificStr = null;

                  SwDmCustomInfoType nSpecificType = 0;

       

       

                  vCustSpecificNameArr = (string[])swCfg.GetCustomPropertyNames();

       

       

                  if (vCustSpecificNameArr != null)

                  {

                      foreach (string vCustSpecificName in vCustSpecificNameArr)

                      {

                          sCustSpecificStr = swCfg.GetCustomProperty(vCustSpecificName, out nSpecificType);

       

       

                          if (vCustSpecificName == "Part Name")

                          {

                              int propCount = dmDoc.GetCustomPropertyCount();

                              string[] propNames = null;

                              propNames = (string[])dmDoc.GetCustomPropertyNames();

                             

                              // Initialize the document manager class

                              dmClassFact = new SwDMClassFactory();

                              // Initialize the document manager application

                              dmDocMgr = (SwDMApplication4)dmClassFact.GetApplication(GM.LicenseKey());

                              // Read the selected document

                              dmDoc = (SwDMDocument18)dmDocMgr.GetDocument(docPath, dmDocType, true, out dmOpenError);

                              propCount = dmDoc.GetCustomPropertyCount();

                              propNames = dmDoc.GetCustomPropertyNames();

                              swCfg.AddCustomProperty("BOM Description", SwDmCustomInfoType.swDmCustomInfoText, swCfg.GetCustomProperty("Part Name", out nSpecificType));

                              MessageBox.Show(swCfg.GetCustomProperty("BOM Description", out nSpecificType));

                              dmDoc.Save();

                          }

                      }

                  }

              }