4 Replies Latest reply on Feb 21, 2014 9:09 AM by Bryan Jenkins

    Enterprise PDM API

    Bryan Jenkins

      Anyone,

       

      We are trying to get information from our MRP/ERP, Work Order documents and other sources into variables on folder and file data cards.   This information (at the moment) is being processed by a VB.NET/EXE application. So we have the individual data strings separated by VB.NET variables.  But we are having problems setting the variable value for (folder/File Data card a object a  variable input).   Are we looking at this from the wrong direction? Or does someone know of a .dll call that we might not have looked at?

        • Re: Enterprise PDM API
          Artem Taturevych

          Are the files you are trying to set values to are checked out and are the variables you are trying to set are on Data Card. These are the required to make this work.

            • Re: Enterprise PDM API
              Bryan Jenkins

              I have tryed both checked in and checked out just to see.

               

              Try

                          Dim vault2 As IEdmVault7 = Nothing

                          If vault1 Is Nothing Then

                              vault1 = New EdmVault5()

                          End If

                          vault2 = DirectCast(vault1, IEdmVault7)

                          If Not vault1.IsLoggedIn Then

                              'Log into selected vault as the current user

                              vault1.LoginAuto(VaultsComboBox.Text, Me.Handle.ToInt32())

                          End If

               

                          Dim aFile As IEdmFile6

                          aFile = vault2.GetFileFromPath(ListBox.Items(0).ToString())

               

                          'Get card variables only from a file checked into the vault

                          If Not aFile.IsLocked Then

                              aFile.LockFile(vault2.RootFolderID, Me.Handle.ToInt32(), EdmLockFlag.EdmLock_Simple)

               

                              Dim varEnum As IEdmEnumeratorVariable5

                              varEnum = aFile.GetEnumeratorVariable

               

                              Dim valueList() As Object = Nothing

                              varEnum.GetUpdateVars(aFile.LockedInFolderID, valueList)

               

                              Dim idx As Integer = 0

                              idx = LBound(valueList)

                              Dim upper As Integer

                              upper = UBound(valueList)

               

                              Dim msg As String

                              msg = "Card variables for " & aFile.Name & " in configuration, @:" & vbLf & vbLf

               

                              Dim varMgr As IEdmVariableMgr5

                              varMgr = aFile.Vault

               

                              Dim var As IEdmVariable5

                              Dim value As IEdmVariableValue5

                              While idx <= upper

                                  value = valueList(idx)

                                  idx = idx + 1

                                  var = varMgr.GetVariable(value.VariableID)

                                  msg = msg & value.VariableName & " = > " & value.GetValue("@").ToString() & vbLf

                                  msg = msg & "EdmVariableFlags: " & var.Flags & ", EdmVariableType: " & var.VariableType & vbLf & vbLf

                                  'msg = msg & "EdmVariableFlags: " & value.VariableFlags & ", EdmVariableType: " & value.VariableType & vbLf & vbLf

                              End While

               

                              MessageBox.Show(msg)

               

                              aFile.UndoLockFile(Me.Handle.ToInt32())

                          Else

                              'User selected a checked-out file

                              MessageBox.Show("Please select a checked-in file.")

                          End If

               

                      Catch ex As System.Runtime.InteropServices.COMException

                          MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message)

                      Catch ex As Exception

                          MessageBox.Show(ex.Message)

                      End Try

                • Re: Enterprise PDM API
                  Jim Sculley

                  GetUpdateVars is not what you want to use.  It is meant for situations where you are setting attributes (e.g. Custom Properties) in files that EPDM doesn't understand.  It doesn't have anything to do with data cards.

                   

                  Plain vanilla setting of data card variables is done using either IEdmEnumeratorVariable8::SetVar or IEdmBatchUpdate::SetVar.

                   

                  The API documentation for each of these interfaces has examples of how to use them.

                   

                  Jim S.

                    • Re: Enterprise PDM API
                      Bryan Jenkins

                      That worked!!!!

                       

                      Try

                                  Dim enumVariable As IEdmEnumeratorVariable8

                                  enumVariable = aFile.GetEnumeratorVariable(ListBox.Items(0).ToString())

                                  enumVariable.SetVar("ProjectNumber", "@", "12345")

                                  enumVariable.CloseFile(True)

                       

                                  MessageBox.Show("Project Number set to " + "12345" + vbLf)

                       

                              Catch ex As System.Runtime.InteropServices.COMException

                                  MessageBox.Show("HRESULT = 0x" + ex.ErrorCode.ToString("X") + " " + ex.Message)

                              Catch ex As Exception

                                  MessageBox.Show(ex.Message)

                              End Try

                       

                      Thank You Very Much!!!!!!