Project Files
This container holds Files registered with the File Manager.
Gets all the File References that are associated with the specified container.
Return
The set of file references associated with the container.
This example prints the location of files for two different components of a system.
system1 = GetSystem(Name="Static1")
geometry1 = system1.GetContainer(ComponentName="Geometry")
for fileRef in geometry1.GetFiles():
print fileRef.Location
>>> C:\Users\myUser\Projects\static1_files\dp0\SYS\DM\SYS.agdb
>>> E:\data\Models\pipe.x_t
model1 = system1.GetContainer(ComponentName="Model")
for fileRef in model1.GetFiles():
print fileRef.Location
>>> C:\Users\myUser\Projects\static1_files\dp0\global\MECH\SYS.engd
>>> C:\Users\myUser\Projects\static1_files\dp0\global\MECH\SYS.mechdb
The data entity that represents a file that is part of the project.
A string that contains the path to the directory containing the file.
The general property that defines the user-visible name of an entity. This property is defined for all data entities but is used only in those entities that present a label in the user interface.
The full path to the local file including the directory and file name.
Copies a file to a target directory.
Return
A reference to the created file is returned in this argument.
Required Arguments
The following example illustrates proper CopyFileByReference command invocation:
fileRef = GetRegisteredFileQuery(FilePath=r"path_to_file")
fileRefCopy = fileRef.Copy(DestinationDirectoryPath=r"path_to_copy_file", Overwrite=True, CopyReferenceCount=False)
Deletes the specified file
Optional Arguments
The following example illustrates a deletion of a registered file via a file reference. The file will be deleted if even if it is still in use. Note that the file will be backed up.
fileRef = GetRegisteredFile(FilePath=r"C:\Users\anyuser\path-to-file.extension")
fileRef.Delete(DeleteIfShared=True,
BackUp=True)
The next example illustrates a deletion of a registered file via a file reference without a forced deletion. If the file is shared, an error will not occur, and the file reference count will be decremented.
fileRef = GetRegisteredFile(FilePath=r"C:\Users\anyuser\path-to-file.extension")
fileRef.Delete(ErrorIfShared=False)
Moves a file to a new directory.
Required Arguments
Optional Arguments
The following example illustrates proper MoveFileByReference command invocation:
fileRef = GetRegisteredFileQuery(FilePath=r"path_to_file")
fileRefCopy = fileRef.Move(NewDirectoryPath=r"path_to_move_file", Backup=False)
Renames a file.
Required Arguments
Optional Arguments
The following example illustrates proper RenameFileByReference command invocation:
fileRef = GetRegisteredFileQuery(FilePath=r"path_to_file")
fileRefCopy = fileRef.Rename(NeName="new_file_name", BackUp=True)
Repairs a file that is referenced in the project but cannot be found on disk. If the file is expected to be found under the project directory, then this command will copy the new file to the expected location rather than link to the new file in its current location. Use SetFilePathCommand to link to a file in a new location.
Required Arguments
RepositoryFileSourceEntity defines repository file information including a server, workspace and filepath
The general property that defines the user-visible name of an entity. This property is defined for all data entities but is used only in those entities that present a label in the user interface.
A value indicating whether the file exists on repository server
Modifed time stamp of file at the download time
String representation of local path to specify the local copy of repository file