Dynamic Object Creation And Deletion

From Planimate Knowledge Base
Revision as of 00:30, 13 January 2008 by Rick (talk | contribs)
Jump to navigation Jump to search

A model can modify its own structure by adding portals (copying a master) and deleting portals from itself.


This is achieved using a table to provide a series of commands to the edit environment. The dispatcher "Restart Engine/Continue" mode is used to perform the edits. This mode is only available for dispatchers in an Application Panel.


Dispatchers in this mode restart the model engine whilst retaining the item within them. ALL OTHER ITEMS in the model are deleted - the run is
stopping and restarting at time = 0, but the item at the dispatcher "survives" the restart and can continue through its flow.


To enable the dynamic object mode, the Dispatcher "Enable Edit Command Table" option must be selected. This option is only available once the dispatcher is in "Restart Engine/Continue" mode. A new object option will enable the dispatcher to be associated with a table, via the familiar Attribute Reference.


The following columns MUST exist in the table. The order doesn't matter and other columns can exist (and will be untouched) by the dynamic object system.


_command
_original_id
_new_id
_new_panel
_x
_y
_result


Each row is processed according to its _command. The following codes are now implemented:


_command = 1: COPY Object


_original_id is the object label of the original object to copy


_new_id will be set to the new id of the object. If non zero,
Planimate will attempt to use the index specified but if it is in
use, a new index will be allocated and _new_id will be set to it


_new_panel is the target panel where the object will be placed. This
must be a dynamic panel


_x,_y specify the lower left co-ord that the object will be placed at
[this may change soon to centre co-ord - feedback please]


_result will be set to a result code by Planimate.


_command = 2: DELETE Object


_original_id is the object label of the object to delete


_result will be set to the result code of the delete operation


All other columns must be present as for Add, but will be ignored


IF a row attempts to delete the panel (or an owner of the panel) that
is currently visible, the delete will fail.


If a row attempts to delete an object which would cause the deletion
of the dispatcher executing the table, the delete will fail.


_command = 3 REPLACE object


In this mode, _original_id specifies the object ID of the original to copy and _new_id must be set to specify the object ID of the object that will
be replaced. The new object will hence get the ID _new_id.


The _x,_y and _new_panel columns are ignored in this mode.


Currently Defined _Result Codes (may be extended)


0: No Error / Nothing to report. The operation was successful
1: Something unexpected happened (coding error)
2: The panel id provided was not for a dynamic panel
3: The panel id provided was not for any kind of panel
4: No source object was provided for copy/delete
5: The command code was not a recognised value, the row was ignored
6: An attempt was made to delete an object which cannot be deleted
for reasons outlined above or because it is part of a network
structure.





idkbase note 130