02_user_tutorials:10_io:import-object-in-groimp
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 02_user_tutorials:10_io:import-object-in-groimp [2025/12/10 15:35] – gaetan | 02_user_tutorials:10_io:import-object-in-groimp [2025/12/10 17:25] (current) – gaetan | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ~~NOTOC~~ | ~~NOTOC~~ | ||
| - | ====== | + | ====== |
| + | With GroIMP it is possible to import objects from several 3d or graph formats into the project graph. The imported objects can then be used similarly to any other part of the graph. | ||
| - | GroIMP can import objects from several 3d or graph formats into the project graph. The imported objects can then be used similar to any other part of the graph. | ||
| - | + | In the following, a different way of adding a file will be shown based on {{ : | |
| - | In the following different way of adding a file will be shown based on {{ : | + | |
| Line 16: | Line 15: | ||
| The easiest way is to add the object directly, using the main menu: Objects, there you can find the options insert File and insert File to RGG. | The easiest way is to add the object directly, using the main menu: Objects, there you can find the options insert File and insert File to RGG. | ||
| - | They both work very similar, starting with a file dialog to choose which file to import and then turning this file into a graph and adding it. The only difference is that ' | + | They both work very similar, starting with a file dialog to choose which file to import and then turning this file into a graph and adding it. The only difference is that ' |
| - | In order to remove | + | In order to remove |
| Line 30: | Line 29: | ||
| < | < | ||
| [f: | [f: | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Importing though RGG code ==== | ||
| + | |||
| + | The same steps are also possible through RGG code. This allows us to automatize the loading of projects or to load at a certain step. | ||
| + | |||
| + | Importing through code gives us two options, adding directly to the root of the graph ( see above), or loading the file and return the node for further usage. | ||
| + | |||
| + | === Import to the root === | ||
| + | |||
| + | We can use the importNodeFromFile function with the path to the file as the first and the MimeType as the second parameter. | ||
| + | |||
| + | <hidden finding MimeTypes for extension> | ||
| + | |||
| + | To find the MimeType for an extension, we can use the embedded documentation. For example to find the mimeType for a dtd file: | ||
| + | |||
| + | **1. Open the help** | ||
| + | |||
| + | by clicking in the main menu on Help > Help | ||
| + | |||
| + | **2. Enable " | ||
| + | |||
| + | To make sure you also search the auto generated documentation, | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | **3. Search for the file extension** | ||
| + | |||
| + | Type the extension (in our case " | ||
| + | |||
| + | ** 4. Find the file named " | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | ** 5. Find MimeType** | ||
| + | |||
| + | On this page you find a table with all import formats supported and their mimeTypes. | ||
| + | The one you searched should be highlighted: | ||
| + | |||
| + | {{: | ||
| + | |||
| + | |||
| + | This should work for all supported format. If you cant find the format you are looking for it might be in a plugin that is not installed. | ||
| + | </ | ||
| + | |||
| + | |||
| + | After downloading the dtd file we can use the code blow to import it by pressing the load button on the rgg toolbar. | ||
| + | |||
| + | |||
| + | <code java importNodeFromFile.rgg> | ||
| + | |||
| + | public void load(){ | ||
| + | //Maybe you have to change the path to fit your file system | ||
| + | importNodeFromFile(getPathToHomeDirectory()+" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | The same function could also be used with an input stream. For example you can add the dtd file to the file explorer by using '' | ||
| + | |||
| + | Afterwards the following code can be used to add the file directly from the GroIMP file system: | ||
| + | |||
| + | <code java importNodeFromStream.rgg> | ||
| + | public void load(){ | ||
| + | importNodeFromStream(getInputStreamFromProject(" | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | === Import and return node === | ||
| + | |||
| + | With the same parameters as above we can also use the loadNodeFromFile and loadeNodeFromStream functions. | ||
| + | These functions return the root of the imported structure and therefore allow us to place it at any position in our graph. For example lats place the dtd tree twice in the graph once at 0,0,0 and once at 2, | ||
| + | |||
| + | <code java loadNodeFromFile.rgg> | ||
| + | protected void init()[ | ||
| + | | ||
| + | loadNodeFromFile(getPathToHomeDirectory()+" | ||
| + | [ | ||
| + | | ||
| + | | ||
| + | ]; | ||
| + | ] | ||
| + | |||
| </ | </ | ||
| Line 38: | Line 124: | ||
| After selecting the file with the file dialog a popup asks "How should the file be added?" | After selecting the file with the file dialog a popup asks "How should the file be added?" | ||
| - | __Add the file:__ the file is copied to a folder | + | __Add the file:__ the file is copied to a folder |
| - | __Link the file:__ only the path to the current file is added, this can be useful in a more complex pipeline where the external file is updated by another | + | __Link the file:__ only the path to the current file is added. This can be useful in a more complex pipeline where the external file is updated by another |
| - | __Embed the file:__ The file is read and added to the meta Graph. Doing so makes it independent from the format, the file or the import process. | + | __Embed the file:__ The file is read and added to the meta graph. Doing so makes it independent from the format, the file or the import process. |
| The choice really depends on the use case, but in our case the easiest is to add the file. | The choice really depends on the use case, but in our case the easiest is to add the file. | ||
| - | After the file was loaded it can be reference | + | After the file has been loaded it can be referenced |
| - | Using this in a XL query will create an instance of the imported object, in the Graph. | + | Using this in a XL query will create an instance of the imported object, in the Graph. |
| - | For example the following code would create three time the same tree in a row: | + | For example the following code would create three times the same tree in a row: |
| < | < | ||
| Line 62: | Line 148: | ||
| </ | </ | ||
| - | It is also possible to access the graph structure of this referenced objects using the code below but it is more recommended to use the GraphExplorer to do so. | + | It is also possible to access the graph structure of these referenced objects using the code below but it is more recommended to use the GraphExplorer to do so. |
| < | < | ||
| { | { | ||
02_user_tutorials/10_io/import-object-in-groimp.1765377338.txt.gz · Last modified: 2025/12/10 15:35 by gaetan
