User Tools

Site Tools


tutorials:import-object-in-groimp

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:import-object-in-groimp [2025/11/01 04:22] – [Importing though RGG code] Timtutorials:import-object-in-groimp [2025/11/01 08:24] (current) – [Importing though RGG code] Tim
Line 39: Line 39:
 === Import to the root === === Import to the root ===
  
-After downloading the dtd file+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>
  
-importNodeFromFile("path","memeType")+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 "Diaplay all Plugins"** 
 + 
 +To make sure you also search the auto generated documentation, add the checkbar to the option "Display all Plugins" 
 + 
 +{{:tutorials:help_all_plugins.png?200|}} 
 + 
 + 
 +**3. Search for the file extension** 
 + 
 +Type the extension (in our case "dtd") with an additional dot up front: (e.g. ".dtd"). 
 + 
 +** 4. Find the file named "Import" ** 
 + 
 +{{:tutorials:find_import_help.png?200|}} 
 + 
 + 
 +** 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: 
 + 
 +{{:tutorials:find_mimetype.png?400|}} 
 + 
 + 
 +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. 
 +</hidden> 
 + 
 + 
 +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()+"\\Downloads\\cherry_new.dtd","model/x-grogra-dtd"); 
 +  } 
 +</code> 
 + 
 + 
 +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 ''Object > New > Add File''. Make sure to choose "all files" as data type. After selecting the file choose add file.  
 + 
 +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("cherry_new.dtd"),"model/x-grogra-dtd")
 +}   
 +</code>
  
  
 === Import and return node === === Import and return node ===
  
-loadNodeFromFile("path","memeType")+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. 
  
-loadNodeFromFile(Stream,"memeType")+<code java loadNodeFromFile.rgg> 
 +protected void init()[ 
 + Axiom==> 
 +  loadNodeFromFile(getPathToHomeDirectory()+"\\Downloads\\cherry_new.dtd","model/x-grogra-dtd")  
 +  [ 
 +   Translate(2,0,0)  
 +   loadNodeFromFile(getPathToHomeDirectory()+"\\Downloads\\cherry_new.dtd","model/x-grogra-dtd") 
 +  ]; 
 +]
  
-e.g. +</code>
  
-A ==> loadNodeFromFile("path","memeType"); 
  
 ==== Using the Object explorer ==== ==== Using the Object explorer ====
tutorials/import-object-in-groimp.1761967336.txt.gz · Last modified: 2025/11/01 04:22 by Tim