1234567891011121314151617181920212223242526272829303132333435363738 |
- include "primitives.alh"
- Element function export_node(model_name_ex : String, model_reference : Element):
- Element splitted_ex
- splitted_ex = string_split(model_name_ex, "/")
- Integer length_ex
- length_ex = integer_subtraction(list_len(splitted_ex), 1)
- Integer counter_i_ex
- counter_i_ex = 0
- Element current_ex
- current_ex = dict_read(read_root(), "__hierarchy")
- while(integer_lt(counter_i_ex, length_ex)):
- if (bool_not(dict_in(current_ex, list_read(splitted_ex, counter_i_ex)))):
- // Create it first
- dict_add(current_ex, list_read(splitted_ex, counter_i_ex), create_node())
- current_ex = dict_read(current_ex, list_read(splitted_ex, counter_i_ex))
- counter_i_ex = integer_addition(counter_i_ex, 1)
-
- // current now contains the place where we should add the element
- dict_add(current_ex, list_read(splitted_ex, length_ex), model_reference)
- return model_reference
- Element function import_node(model_name_im : String):
- Element splitted_im
- splitted_im = string_split(model_name_im, "/")
- Integer length_im
- length_im = list_len(splitted_im)
- Integer counter_i_im
- counter_i_im = 0
- Element current_im
- current_im = dict_read(read_root(), "__hierarchy")
- while (integer_lt(counter_i_im, length_im)):
- current_im = dict_read(current_im, list_read(splitted_im, counter_i_im))
- counter_i_im = integer_addition(counter_i_im, 1)
- return current_im
|