tutorials:import-object-in-groimp
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| tutorials:import-object-in-groimp [2025/10/30 12:23] – [Importing though RGG code] Tim | tutorials:import-object-in-groimp [2025/11/01 08:24] (current) – [Importing though RGG code] Tim | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Importing objects ====== | ||
| + | |||
| 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. | 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. | ||
| Line 5: | Line 7: | ||
| - | ====== Using the Gui ====== | + | ===== Using the Gui ===== |
| - | ===== Add directly | + | ==== Add directly ==== |
| | | ||
| Line 29: | Line 31: | ||
| - | ===== Importing though RGG code ===== | + | ==== 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. | ||
| - | ==== Import | + | Importing through code gives us two options, adding directly |
| - | importNodeFromFile(" | + | === Import to the root === |
| - | importNodeFromFile(stream," | + | |
| - | ==== Import | + | We can use the importNodeFromFile function with the path to the file as the first and the MimeType as the second parameter. |
| - | loadNodeFromFile(" | + | <hidden finding MimeTypes for extension> |
| - | loadNodeFromFile(Stream," | + | To find the MimeType for an extension, we can use the embedded documentation. For example to find the mimeType for a dtd file: |
| - | e.g. | + | **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,0,0. | ||
| + | |||
| + | <code java loadNodeFromFile.rgg> | ||
| + | protected void init()[ | ||
| + | | ||
| + | loadNodeFromFile(getPathToHomeDirectory()+" | ||
| + | [ | ||
| + | | ||
| + | | ||
| + | ]; | ||
| + | ] | ||
| + | |||
| + | </ | ||
| - | A ==> loadNodeFromFile(" | ||
| - | ===== Using the Object explorer | + | ==== Using the Object explorer ==== |
| A second more reusable way is to add the external objects to the Object explorer. The explorer can be found on the main menu on Panels/ | A second more reusable way is to add the external objects to the Object explorer. The explorer can be found on the main menu on Panels/ | ||
tutorials/import-object-in-groimp.1761823412.txt.gz · Last modified: 2025/10/30 12:23 by Tim
