2 Replies Latest reply on Jan 15, 2010 11:26 AM by Fred Rasmussen

    API Example of User Defined References Needed

    Fred Rasmussen

      The Programmers Reference Guide describes some great functionality of the Enterprise PDM API.


      It is a Windows help file located at C:\Program Files\SolidWorks Enterprise PDM\API_GB.chm


      I would like to know if anyone has successfully used the IEdmAddCustomRefs interface? It gives access to the User Defined References AKA "Pasted References"


      Any examples of code would be appreciated. I prefer examples of VB, but C++ may be useful for someone else.

        • Re: API Example of User Defined References Needed

          Here is some code, which may help you. It may be a little unclear but it should get you started.

           

          private void SaveReferences()
          {     
              IEdmAddCustomRefs addRefs = (IEdmAddCustomRefs)m_vault.CreateUtility(EdmUtility.EdmUtil_AddCustomRefs);
              //create a selected item
              EdmSelItem selItem;
              // current change notice
              selItem.mlDocID = m_templates.ChangeNoticeFile.ID;
              selItem.mlProjID = m_templates.ChangeNoticeFolder.ID;
              
              Array myArray = Array.CreateInstance(typeof(EdmSelItem), 0);
              myArray.SetValue(selItem, 0);
              string[] fileList = new string[m_data.Length];
              // all files that should reference this ecn
              // m_data is passed from EdmCmd struct
              foreach (EdmCmdData cmdData in m_data)
              {
                  addRefs.AddReferencesID(cmdData.mlObjectID1, ref myArray);
              }    
              bool treeCreated = addRefs.CreateTree(0);
              bool dialogShown = addRefs.ShowDlg(m_owner.Handle.ToInt32());
              bool successful = addRefs.CreateReferences();
          }