22.1 Attaching Files to the Origin Project
Use Code Builder to attach or retrieve third-party files stored with the Origin project file.
Attaching files to the OPJ
To attach files to the OPJ:
- Click the Code Builder button on the Standard toolbar.
- Right-click on the Project subfolder in the Origin C Workspace tree and choose Add Files.
- Browse to and select the file(s) that you want to attach to the OPJ file (Note that you can also drag-and-drop files from the User and Temp folders to the Project folder).
- When you save the Origin project file, all files in the Project folder are appended and saved inside the OPJ. The Project folder tracks with the OPJ; the contents of this folder do not change when you change your workspace in Code Builder.
Locating and opening attached third-party files
When you open an OPJ file to which files have been attached, support files are extracted and stored in a temporary subfolder.
To show the path to that subfolder and open the files:
- Right-click on the Project folder in Origin C Workspace tree, and select Show Full Path.
- The attached files can be opened by double-clicking on the file name:
- If the file type is recognized by Code Builder (Origin C and OGS files are specially handled), these files are opened in new windows in the Code Builder Multiple Document Interface (MDI).
- If the file type is not recognized by Code Builder, Origin passes the file to the Windows OS for opening. For instance, if a Microsoft Word file were attached and you were to double-click on this file, the file would open in the Microsoft Word application.
Alternately, you could navigate to the temporary subfolder and launch the file through Windows Explorer. Note that when the project is closed, this subfolder is removed from the system.
Special Handling of Origin C and OGS files
Special handling of OC and OGS files makes it possible to attach custom code to OPJ files and create custom solutions that are easily delivered to other Origin users.
Origin C files that are attached to the project are compiled and loaded when the project to which they are attached is opened. All functions defined in the OC files are accessible to the user from the Origin interface, upon project opening.
With OGS files, you can access script sections in the attached OPJ from the interface when the project is open. For example, if you had attached a file named MyScripts.OGS, once the OPJ file was opened, you could issue this command in the Script Window:
Origin will look to see whether there is a file called MyScripts.OGS that is attached to the open OPJ, then will look to see if MySection exists within the OGS file. If found, this section is run. If no such attached file is found, Origin searches your User Files folder, then finally the EXE path for the named OGS file.
How attached third-party files are handled when appending OPJ files
You can append an Origin project file to the open project file. This adds the contents of the appended project to the current project. When appending projects, Origin handles attached third-party files in this way:
- If a third-party file of the same name is not attached to the open project, the third-party file is attached to the open project.
- If a third-party file of the same name is attached to the open project, the file contents are compared. If the contents are identical, the second third-party file is discarded.
- If attached file names are the same but the file contents differ, the filename of the second file is enumerated (e.g. "TestData.txt" becomes "TestData1.txt"), and the file is attached.