FileManagement Class — NXOpen Python API Reference 12.0.0 documentation

# FileManagement Class

class `NXOpen.PDM.``FileManagement`

  Bases: `NXOpen.TransientObject`

  This class is responsible for Teamcenter file management related activities.

  Use `PDM.PdmSession.NewFileManagement()` to get the instance of this class.

  New in version NX6.0.3.

# Methods

Method | Description
--- | ---
Dispose | Frees the object from memory.
DownloadAssociatedFiles | Download the specified named reference files for NX use.
ExportFiles | Exports all associated files for the specified dataset(s) to a directory.
GetAssociatedFiles | Given an NX part, this method will return a list of named reference files in the corresponding Teamcenter dataset.
ImportFiles | Imports all associated files for the specified dataset(s) into the Teamcenter database.
ImportFilesAndCreateDatasets | Import files for datasets while creating the datasets also.

# Enumerations

FileManagementFileType Enumeration | PDM file types

# Method Detail

## Dispose

`FileManagement.``Dispose`

  Frees the object from memory.

  After this method is called, it is illegal to use the object. In .NET, this method is automatically called when the object is deleted by the garbage collector.

  Signature `Dispose()`

  New in version NX6.0.3.

  License requirements: None.

## DownloadAssociatedFiles

`FileManagement.``DownloadAssociatedFiles`

  Download the specified named reference files for NX use.

  Signature `DownloadAssociatedFiles(parts, files)`

  Parameters:

  - parts (list of `NXOpen.BasePart`) –
  - files (list of `NXOpen.PDM.PdmFile`) –

  New in version NX11.0.0.

  License requirements: None.

## ExportFiles

`FileManagement.``ExportFiles`

  Exports all associated files for the specified dataset(s) to a directory.

  The dataset(s) are identified by their Teamcenter item id, Teamcenter item revision id, Teamcenter dataset name, NX dataset type, and NX dataset relation type. A base export directory name must be specified for each dataset along with the tool name that is requesting the export. The full path to the exported files is returned in an output array. The full path will be NX_default_directory or export_directory. Additionally, an array of PDI result codes is returned indicating the success (0) or failure (non-zero) of each export. The dataset types for FOREIGN_MODEL are the ones included in the Teamcenter preference “TC_NX_Foreign_Datasets”. In such a case the input relation type should be “Foreign”. The exporting of the associated file is governed by following conditions: The associated filetype should be exportable for combination of the Tool used and the Open action for operation. The associated file should not be in the excluded named reference list. For Foreign Datasets it will not export file types included in the Teamcenter preference “TC_NX_Foreign_Datasets”. NX Clone can be used for exporting Foreign datasets. In case of NX CAM dataset type like “UGCAMCLSF”, “UGCAMPTP”, “UGCAMShopDoc”, all the associated files will be exported irrespective of above conditions.

  > 1. Excluded Named Reference List:
  > 2. “UGPART”
  > 3. “UGPART-MASSPR
  > 4. “UGPART-BBOX
  > 5. “UGPART-ATTRIBUTES
  > 6. “UGPART-ATTR
  > 7. “Trushape-Data
  > 8. “BVRSYNCINFO
  > 9. “UG-QuickAccess-Binary
  > 10. “UG-QuickAccess-Text
  > 11. NX dataset types and relation names
  > 12. NX Model Type NX Relation Type NX Dataset Type
  > 13. MASTER_MODEL “has shape” “UGMASTER”
  > 14. SPEC_MODEL “has specification” “UGPART”
  > 15. MAN_MODEL “has manifestation” “UGPART”
  > 16. ALTREP_MODEL “has altrep” “UGALTREP”
  > 17. SCENARIO_MODEL “UG_scenario” “UGSCENARIO”
  > 18. SIMULATION_MODEL “NX_simulation” “NXSimulation”
  > 19. MOTION_MODEL “NX_simulation” “NXMotion”
  > 20. CAE_SOLN_MODEL “NX_simulation” “CAESolution”
  > 21. CAE_MESH_MODEL “NX_simulation” “CAEMesh”
  > 22. CAE_GEOM_MODEL “NX_simulation” “CAEGeom”
  > 23. FOREIGN_MODEL “Foreign” “*”
  > 24. MOTION_MODEL_SPEC “has specification” “MotionSim”

  For the input itemIds: In case of Default Domain: it is Teamcenter item ID. In case of non-Default Domain: it is the multifield key. e.g. %#MFK#%,=item_id=001, object_type=SupplierPart, supplier_code=x And the encoded part filename would be containing the MFK.

  Signature `ExportFiles(itemIds, itemRevisionIds, datasetNames, datasetTypeNames, datasetRelationTypeNames, baseDirectoryNames, toolNames)`

  Parameters:

  - itemIds (list of str) – Multifield Key.
  - itemRevisionIds (list of str) – Teamcenter item revision ids.
  - datasetNames (list of str) – Teamcenter dataset names.
  - datasetTypeNames (list of str) – NX dataset type names.
  - datasetRelationTypeNames (list of str) – NX dataset relation type names.
  - baseDirectoryNames (list of str) – Base export directory name.
  - toolNames (list of str) – Tool names (“UGII V10-ALL”).

  Returns: | a tuple
  Return type: | A tuple consisting of (resultCodes, exportDirectoryNames) resultCodes is a list of int. Result codes. Success (0), failure (non-zero) exportDirectoryNames is a list of str. Resulting location of export directory

  New in version NX6.0.3.

  License requirements: None.

## GetAssociatedFiles

`FileManagement.``GetAssociatedFiles`

  Given an NX part, this method will return a list of named reference files in the corresponding Teamcenter dataset.

  Signature `GetAssociatedFiles(parts, fileTypesToExclude)`

  Parameters:

  - parts (list of `NXOpen.BasePart`) –
  - fileTypesToExclude (list of `NXOpen.PDM.FileManagementFileType`) –

  Returns: |
  Return type: | list of `NXOpen.PDM.PdmFile`

  New in version NX11.0.0.

  License requirements: None.

## ImportFiles

`FileManagement.``ImportFiles`

  Imports all associated files for the specified dataset(s) into the Teamcenter database.

  The files will be attached to the dataset(s) as named references. The dataset(s) are identified by their Teamcenter multifield key, Teamcenter item revision id, Teamcenter dataset name, NX dataset type, and NX dataset relation type. An import directory containing the files must be specified for each dataset. An array of PDI result codes is returned indicating the success (0) or failure (non-zero) of each import. The dataset types for FOREIGN_MODEL are the ones included in the Teamcenter preference “TC_NX_Foreign_Datasets”. In such a case the input relation type should be “Foreign”. The named reference information from BMIDE setting will be used for the imported file extension.

  > 1. NX dataset types and relation names
  > 2. NX Model Type NX Relation Type NX Dataset Type
  > 3. MASTER_MODEL “has shape” “UGMASTER”
  > 4. SPEC_MODEL “has specification” “UGPART”
  > 5. MAN_MODEL “has manifestation” “UGPART”
  > 6. ALTREP_MODEL “has altrep” “UGALTREP”
  > 7. SCENARIO_MODEL “UG_scenario” “UGSCENARIO”
  > 8. SIMULATION_MODEL “NX_simulation” “NXSimulation”
  > 9. MOTION_MODEL “NX_simulation” “NXMotion”
  > 10. CAE_SOLN_MODEL “NX_simulation” “CAESolution”
  > 11. CAE_MESH_MODEL “NX_simulation” “CAEMesh”
  > 12. CAE_GEOM_MODEL “NX_simulation” “CAEGeom”
  > 13. FOREIGN_MODEL “Foreign” “*”
  > 14. MOTION_MODEL_SPEC “has specification” “MotionSim”

  For the input itemIds: In case of Default Domain: it is Teamcenter item ID. In case of non-Default Domain: it is the multifield key. e.g. %#MFK#%,=item_id=001, object_type=SupplierPart, supplier_code=x And the encoded part filename would be containing the MFK.

  Signature `ImportFiles(itemIds, itemRevisionIds, datasetNames, datasetTypeNames, datasetRelationTypeNames, importDirectoryNames)`

  Parameters:

  - itemIds (list of str) – Multifield key.
  - itemRevisionIds (list of str) – Teamcenter item revision ids.
  - datasetNames (list of str) – Teamcenter dataset names.
  - datasetTypeNames (list of str) – NX dataset type names.
  - datasetRelationTypeNames (list of str) – NX dataset relation type names.
  - importDirectoryNames (list of str) – Import directories which contain the files to import.

  Returns: | Result codes. Success (0), failure (non-zero).
  Return type: | list of int

  New in version NX6.0.3.

  License requirements: None.

## ImportFilesAndCreateDatasets

`FileManagement.``ImportFilesAndCreateDatasets`

  Import files for datasets while creating the datasets also.

  Signature `ImportFilesAndCreateDatasets(itemIds, itemRevisionIds, datasetNames, datasetTypeNames, datasetRelationTypeNames, datasetToolNames, fileType, namedReferenceNames, importFileNames, importFileDirectoryNames)`

  Parameters:

  - itemIds (list of str) – Multifield key.
  - itemRevisionIds (list of str) – Teamcenter item revision ids.
  - datasetNames (list of str) – Teamcenter dataset names.
  - datasetTypeNames (list of str) – NX dataset type names.
  - datasetRelationTypeNames (list of str) – NX dataset relation type names.
  - datasetToolNames (list of str) – NX dataset tool names. This is not currently supported. For future use only.
  - fileType (list of bool) – Types of files - true = Binary, false = Ascii.
  - namedReferenceNames (list of str) – NX dataset named reference names.
  - importFileNames (list of str) – Import file names which contain the files to import per dataset.
  - importFileDirectoryNames (list of str) – Import file directory names which contain the files to import.

  Returns: | Result codes. Success (0), failure (non-zero).
  Return type: | list of int

  New in version NX11.0.1.

  License requirements: None.