danieladubois
Computer
- Sep 4, 2012
- 6
Hi,
I’m trying to export some assemblies form Teamcenter to a local directory C:\. I’m using the example form the NX Open Programmer's Guide but I doesn’t work. I don’t really understand how does it work, do I have to be in a NX managed session or to have Teamcenter open?
I’m trying to export some assemblies form Teamcenter to a local directory C:\. I’m using the example form the NX Open Programmer's Guide but I doesn’t work. I don’t really understand how does it work, do I have to be in a NX managed session or to have Teamcenter open?
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Module Import_Export_Test
Dim theSession As Session
Dim pdmSession As PDM.PdmSession
Dim fileMgt As PDM.FileManagement
Sub Main
theSession = Session.GetSession()
pdmSession = theSession.PdmSession()
fileMgt = pdmSession.NewFileManagement()
Dim itemIds(0) As String
Dim itemRevIds(0) As String
Dim datasetNames(0) As String
Dim datasetTypeNames(0) As String
Dim datasetRelationTypeNames(0) As String
Dim baseDirectoryNames(0) As String
Dim toolNames(0) As String
Dim exportDirectoryNames(0) As String
Dim importDirectoryNames(0) As String
Dim exportResults(0) As Integer
Dim importResults(0) As integer
' Set the TC item id
itemIds(0) = "001126"
' Set the TC item revision id
itemRevIds(0) = "A"
' Set the TC dataset name
datasetNames(0) = "001126-A"
' Set the NX dataset type name
datasetTypeNames(0) = "UGMASTER"
' Set the NX dataset relation type name
datasetRelationTypeNames(0) = "has shape"
' Set the export directory. This will be appended to the NX
' default directory
baseDirectoryNames(0) = "Export"
' Set the tool name.
toolNames(0) = "UGII V10-ALL"
' NX dataset types and relation names
' NX Model Type NX Relation Type NX Dataset Type
' MASTER_MODEL "has shape" "UGMASTER"
' SPEC_MODEL "has specification" "UGPART"
' MAN_MODEL "has manifestation" "UGPART"
' ALTREP_MODEL "has altrep" "UGALTREP"
' SCENARIO_MODEL "UG_scenario" "UGSCENARIO"
' SIMULATION_MODEL "NX_simulation" "NXSimulation"
' MOTION_MODEL "NX_simulation" "NXMotion"
' CAE_SOLN_MODEL "NX_simulation" "CAESolution"
' CAE_MESH_MODEL "NX_simulation" "CAEMesh"
' CAE_GEOM_MODEL "NX_simulation" "CAEGeom"
' FOREIGN_MODEL "Foreign" "*"
' Set the import directory. This directory should contain the
' files that will be added as named references to the specified
' dataset.
importDirectoryNames(0) = "D:\workdir\Import"
' Import the files.
importResults = fileMgt.ImportFiles(itemIds, itemRevIds,
datasetNames, datasetTypeNames,
datasetRelationTypeNames,
importDirectoryNames)
' Export the files.
exportResults = fileMgt.ExportFiles(itemIds, itemRevIds,
datasetNames, datasetTypeNames,
datasetRelationTypeNames,
baseDirectoryNames, toolNames,
exportDirectoryNames)
End Sub
End Module