I have created a drag-and-drop workflow builder where all of the shapes are complex (i.e. non-standard shapes comprised of several appended SVG commands). Each of these shapes was created using one of six (6) custom visual templates ("Author", "Transmittal", "Review", "Print", "Publish" and "Email"). Unfortunately, I cannot rely on the built-in diagram.save method to store the finished diagrams as complex shapes reference visual templates which are functions and the JSON serialization process strips out all non-data (i.e. no functions). When I attempt to reload the diagram from the file system, the diagram is correctly recreated but the complex shapes are replaced by squares.
The solution to this problem recommended to me was to include a "type" property with each complex shape and then interrogate this property after diagram.load to reinstantiate the correct visual template for each shape. At a high level, this sounds very logical and straight-forward. While I have successfully assigned a "type" to each shape and have encountered no problems saving and subsequently re-loading a diagram, I have yet to figure out the correct way change existing shapes after re-load per the visual template functions originally used to create them. The approach I envision (but have yet to figure out the specifics) goes something like this:
- Re-load the diagram using the diagram.load method.
- Enumerate all of the shapes in a diagram by looping through the ShapesCollection.
- For each shape in the collection, somehow assign the correct visual template to the shape based on its "type" property.
Any help you can provide me with with either of the two approaches above would be very much appreciated. Thanks.