Showing results for 
Search instead for 
Do you mean 
Reply

Create Teamcenter Datasets and import Files

Hello,

ist there any chance to create a Teamcenter dataset with relation to a item revision and import a file as named reference to it with NXOpen.

 

NXOpen.PDM.FileManagement.ImportFiles() looks right, but is limited to existing datasets.

 

Any ideas how to this with NXOpen in the current NX session?

 

Thanks in advance.

 

1 REPLY

Re: Create Teamcenter Datasets and import Files

I found a way to do this within our Teamcenter installation. In our installation there is a pdm server call that creates a dataset. I invoked this call in NX Open, then I followed it up with the method to import the file as a named reference under the new dataset.

 

This method is dependent on the availability of the pdm server call, or one that is similar in your installation. You would need to figure that out, but this approach worked for me:

 

 

        Dim fileNumber = "1234"
        Dim fileRevision = "A"

        Dim szDatasetName = fileNumber & "_" & fileRevision & "_MyDataSet"
        Dim datasetTypeName = "MyDataSetType"
        Dim datasetRelationTypeName = "Foreign"
        Dim datasetRelation = "MyPsuedoFolderRel"
        Dim datasetRefType = "MyNamedReferenceType"
        Dim datasetFileType = "TEXT"

        Dim importDir = "D:\Users\ImportDir"

        Dim szCreateDatasetInput As String
        szCreateDatasetInput = fileNumber & "/" & fileRevision & "/" & datasetTypeName & "/" & szDatasetName & "/" & datasetRelation & "/" & datasetRefType & "/" & datasetFileType
        Dim iOutputCode As Integer = 0
        Dim szOutputString As String = Nothing
        Dim success = True
        Try
            theUfSession.Ugmgr.InvokePdmServer(210, szCreateDatasetInput, iOutputCode, szOutputString)
            If iOutputCode <> 0 Then
                MsgBox("Failed to create dataset in Teamcenter" & vbNewLine & iOutputCode & ":  " & szOutputString, MsgBoxStyle.Information, "Teamcenter push failed")
                success = False
            End If
        Catch ex As Exception
            MsgBox("Failed to create dataset in Teamcenter" & vbNewLine & ex.ToString, MsgBoxStyle.Information, "Teamcenter push failed")
            success = False
        End Try

        If success Then
            Try
                Dim pdmSession = theSession.PdmSession()
                Dim fileMgt = pdmSession.NewFileManagement()
                fileMgt.ImportFiles({fileNumber}, {fileRevision}, {szDatasetName}, {datasetTypeName}, {datasetRelationTypeName}, {importDir})
            Catch ex As Exception
                Console.WriteLine(ex)
                MsgBox("Failed to import to Teamcenter" & vbNewLine & ex.ToString, MsgBoxStyle.Information, "Teamcenter push failed")
            End Try
        End If