![]() |
Telelogic System Architect (steve huntington) | ![]() |
Topic Title: Method for Diagram Duplication? Topic Summary: How to create a new diagram with new definitions from an existing diagram Created On: 13-Sep-2006 14:01 Status: Read Only |
Linear : Threading : Single : Branch |
|
![]() |
![]()
|
![]() Answer: Haha, sorry Matt! This is what I ended up doing to duplicate diagrams and all their symbols and definition. I put an "instance identifier" in the name of everything. For instance, let's say that one of the original diagrams is "Diagram 1" with symbols "Symbol 1" "Symbol 2", etc. The original is going to be "instance A". I want to create 7 total instances, so I have "instance A" through "instance G". I named everything in the original like this: "Name - Instance A". Every diagram, every symbol, everything has an instance identifier in the name. Next I exported the XML of every diagram that I wanted to duplicate and opened it up in a text editor. I did a find and replace on the instance identifier (be sure to use an editor that supports find and replace!). For instance, I found every occurence of "instance A" and replaced it with "instance B". Then I simply re-imported the XML and had a second instance of everything. Repeating this 5 more times using "instance C" and so forth, I ended up with all 7 instances that I needed. You do not have to worry about SAObjID values overlapping and such, which is great. When SA imports something from XML (and you select never replace in the dialog - I've never tried it any other way) it only uses the SAObjID to understand relationships within the XML file. You can make the SAObjIDs anything practically (0-65535 is my guess on the valid range) as long as they are unique within the file. When the objects are created within SA, they are assigned new SAObjIDs according to what is next in that SQL DB. Also, you can make the instance identifier something reasonable. If say, you are modeling 7 different locations which all have the same processes, you may use the cityname as the identifier or something. At least then it doesn't look like you have things named wierd. This method was less than ideal because it forces you to name things certain way to make it feasible but it's certainly better than duplicating scores of diagrams and hundreds of symbols by hand. | |
![]() |
|
I need to create an OV-05 Node Tree that at the top level has 7 children. Each child is decomposed into about 10 child diagrams which each contain 3-25 symbols. Each of the 7 children are Identical save for one thing, they each represent a different instance of that hierarchy.
For example, the top level looks like this: root a b c d e f g The symbol 'a' has a child diagram that further decomposes it, and this continues so that there are about 10 diagrams under object 'a' totaling about 100 objects. Each object is named "a - XXXXX" where 'a' indicates that the object belongs to the 'a' instance and XXXX is the rest of the name. What I need is to have all the other children (b-g) have the same structure underneath them, except their diagram and object names would be "b - XXXXX", "c- XXXXX", so forth. Creating the new duplicate objects is a cinch, I just exported the definitions to a CSV, copy and pasted them, did a find and a replace, and re-imported all the objects. However, the problem arises when I want to copy the Diagrams. Initially I thought I would do all this by creating the structure once, exporting the XML, doing a find and replace to replace 'a' with 'b', and re-importing the XML. The problem there is that there are all kinds of unique fields in the XML (like SAObjID) that must be Different and unique. You can't simply do a find and replace in the XML and end up with a second copy of the diagram (at least I don't think). It would require you to manually edit every object (SADefinition, SADiagram, SASymbol) in the XML to remove the unique fields and such. So my question is, have any of you had a similar situation and how did you handle it? Certainly I could just create all the new diagrams and reconnect all the symbols that I imported from the CSV file but this will be extremely tedious (over 600 objects). The only thing I could think of was to create it Visio, do a find and replace in Visio each time, and re-import the Visio diagrams. Unfortunately, since there are 10 diagrams x 6 and the Visio import isn't the fastest, that wouldn't save much time. In the meantime, I guess I'll write a VBA script to address this specific issue. Thanks! Edited: 13-Sep-2006 at 14:05 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
Jonathan, ------------------------- Thanks, MattS |
|
![]() |
|
![]() |
|
I just started writing an application to handle duplication of a diagram, so I may have an answer soon for the relation question. One thing you might look at is the Visio Mapper as they do create links there (however, those are actual link objects, not a relation).
You're right, you cannot actually Import/Export symbols through CSV (you can through XML). What you are actually doing is importing and exporting the definitions. However, once I created all 700+ definitions in the CSV file and imported them, they are in the "choices" menu to be dropped on to the diagram. The application I am writing is in C# using the COM interface. I really don't like writing things in VBA for a number of reasons and I have a lot of utilities and such that I have built in class libraries that I reuse all the time in .NET, so I prefer going this route. I am not at liberty to share those, however if I get the C# application to duplicate the diagrams, I'll paste what code I can for reference. Oh, and the problem with using the XML for the symbols/definitions is the same as what I had previously mentioned - the unique field values that are present like SAObjID and such. Since SAXML isn't very nice, doing a transformation on it to create a duplicate is sortof out of the question given my current level of effort. |
|
![]() |
|
![]() |
|
Jonathan, ------------------------- Thanks, MattS Edited: 14-Sep-2006 at 19:02 by Matt Sheranko |
|
![]() |
|
![]() |
|
Sure thing, I'll post any solution to creating a relation if and when I find it.
|
|
![]() |
|
![]() |
|
Hrmn, I beginning to wonder if the "link" symbol is stored ONLY in the DGX file. I've found out what relationships have to be created in order to make the hiearchy for the OV-05 NT and my code is matching the results of me doing it through the SA GUI exactly when I check in the DB tables. This makes me think that the SA GUI may also programmatically add the appropriate lines in the DGX file of the diagram and not draw that line based on the presence of the proper relationship entries. This will disgust me if this is indeed the case.
|
|
![]() |
|
![]() |
|
I looks like I may be able to generate the links without generating the relationships directly in the DB. There are a number of functions in the ISAIMF object that deal with trees (such as SACreateTreeSymbol and SACreateTree, SAInsertNodeAfter, etc.). I need to play around with these for abit because I can't seem to get them to display on a diagram.
|
|
![]() |
|
![]() |
|
Jonathan, ------------------------- Thanks, MattS Edited: 16-Sep-2006 at 13:59 by Matt Sheranko |
|
![]() |
|
![]() |
|
Take a look at these attributes for an SASymbol object in the XML. I think they some, if not all the attributes necessary to define the hierarhical relationship for a symbol:
UPDATE: These below are not entirely correct. Look further in the thread for the Updated Property Definitions post that has the most up to date definitions and the necessary fields. SASymArrangement="0" SASymOrder="0" SASymXPEntity="3" SASymXPLink="65535" SASymXPGroup="65535" SASymXPSibling="2" SASymXPSubordinate="65535" SASymArrangement: I think this attribute determines how to arrange the children (vertically, horizontally, or as a block). SASymOrder: I'm not exactly sure what this one does. It does change and the root node has a value of 0 but I've not yet figured out what this value does. SASymXPEntity: I believe this is the entity number of the symbol. It's used by other objects in the hierarchy to reference to them. SASymXPLink: I *think* this links to a child diagram or something (which would be kind of odd since I think there is another property or attribute that links to child diagrams). It's always INT MAX (65535) in all my diagrams which I believe is the "Undefined" value. SASymXPGroup: This basically says who the parent is. It's the SASymXPEntity value of the parent object.It's 65535 (int max) if it's the root of the tree on that diagram. SASymXPSibling: This is the SASymXPEntity value of the sibling on the right of the symbol. A symbol may have 0 or more siblings to it's left or 0 or more to it's right, but this just points to the next one to it's right. It's 65535 (int max) if there is no sibling SASymXPSubordinate: This is the SASymXPEntity value of the left most child of the symbol. A symbol can have 0 or more children, but this points to the leftmost child on the diagram. It's 65535 (int max) if there are no children. As far as the Visio mapper goes, yeah it only creates the nodes not the hierarchical relationships. I may do it via XML but I have to determine if it's easier to mangle the XML programmatically to create the duplicates or to do the entire thing programmatically. I'm working on something else right now and have a question submitted to tech support, so maybe they'll answer it in the interim. I'll be revisiting this issue this coming week and I'll let you know what I find. Edited: 20-Sep-2006 at 12:31 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
Jonathan, ------------------------- Thanks, MattS |
|
![]() |
|
![]() |
|
Hrmn, I had speculated that the relational link lines were only contained within the DGX and were created programmatically and what are saying seems to support that. If that's true, I wonder if the methods I was trying earlier would work if I just delete the DGX when I was done so that it had to be re-generated.
Btw, are the attributes that I spelled out the ones you need to create the hierarchy or did you need additional/fewer ones? Thanks. |
|
![]() |
|
![]() |
|
Jonathan, ------------------------- Thanks, MattS |
|
![]() |
|
![]() |
|
Good deal. I have noticed that you need to specify nearly everything as well.
Dunno why you are double posting, but like you said - several others do as well. |
|
![]() |
|
![]() |
|
OK, I have some info for the update. I've found that you can create a diagram from very little XML and you can create a symbol from very little as well. I've found that it doesn't really matter what SAObjID you use in your XML so long as it is unique WITHIN the XML document. If you use say, 1 or 2000, and those IDs are not the inline with what IDs should be used next, it just replaces them with valid new ones. It does use IDs within the XML to determine relationships though. If you completely leave the IDs out then you can't establish relationships and if you have more than 1 of the same object type (e.g. SASymbol or SADiagram) then they are considered duplicates.
Minimum Diagram XML Edited: 19-Sep-2006 at 23:37 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
Minimum Symbol XML
|
|
![]() |
|
![]() |
|
duplicate post
Edited: 20-Sep-2006 at 00:00 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
duplicate post
Edited: 19-Sep-2006 at 23:59 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
This is where things get interesting. The XML code below will create an OV-05 Node Tree diagram with 6 nodes. If you import the XML and look at the diagram it creates and the XML itself, you'll notice several things.
UPDATE: These below are not entirely correct. Look further in the thread for the Updated Property Definitions post that has the most up to date definitions. SASymXPEntity - This is the unique ID that other symbols use to reference this symbol SASymXPGroup - The SASymEntity value of the parent symbol or 65535 if it has no parent SASymXPSibling - The SASymEntity value of the symbol's sibling to the immediate right SASymXPSub - The SASymEntity value of the symbol's leftmost child SASymXPLink - I have no idea, its always none (65535) SASymXPOrder - The value of the node if you do a pre-order traversal of the hierarchy starting with 0 for the root node SASymProperties - I have no idea what this does, but it's definitely important. If you look at the diagram and look at the XML, I can't figure out the what the value does or what it should be for any particular node just using the relationships and locations of the node in the tree. If you get this wrong however, at best your diagram is wrong and at worst it crashes SA (make them all 0x0001 for instance). Any ideas? P.S. Don't forget to save the file in the Unicode encoding or change the encoding value to UTF-8 or else it will error when you try and import. Edited: 20-Sep-2006 at 12:30 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
duplicate post
Edited: 20-Sep-2006 at 00:00 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
duplicate post
Edited: 19-Sep-2006 at 23:59 by Jonathan Burlingame |
|
![]() |
|
Telelogic System Architect
» System Architect - General Discussion
»
Method for Diagram Duplication?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.