C# to UML reverse engineering automation in Visio

S

Sarang_MVP

Hi,
I needed some help on visio automation.
When we reverse engineer .Net code from the VS.NET2003 using the
Project --> Visio UML --> Reverse Engineer menu option, it creates a static
structure for all the code in visio but it doesn't create the uml
diagrams. We still have to manually drag all the entities on the static
structure page to get those diagrams.

I am trying to automate this. So far I have been able to create the UML
shapes on the static structure page (e.g. Class, Interface, etc) after
reading the assembly.

But unfortuantely I have no clue, as to how do I set class information
like attributes (fields) and operations (methods) for the shapes that
have been created.

Would appreciate any help / pointers

Thanks in advance.

Sarang S. Datye
[Microsoft MVP - Visual Basic]
 
R

Rich

I have been looking for an answer on this question for several days. Please
also let me know if you got the answer.
Thanks.
rich
 
S

Sarang_MVP

Hi,

I got some clue on how to go about doing this code to uml thing in visio.
Here's how:

1. Use the OpenEx method to open UMLSTR_U.VSS stencil .
2. create a copy of the UMLMOD_U.VST template using Add method of the
Documents collection.
3. Add a page to the Pages collection of the document that was added in step2.
4. Do assembly.GetTypes for iterating through each type.
5. Get the master object from the stencil using the ItemU property of the
Masters collection of the document object. :)
e.g. Document.Masters.ItemU(visClass)
6. Do a for each type in Types retrieved in step 4.
7. Use the Drop method of the Page to drop a copy of the master object
retrieved in step 5. e.g. Page.Drop(objMaster, X, Y)
8. The drop method returns a shape.
9. Iterate through the shapes collection of the shape retrieved in 8 and
trace out the shapes identified by name = "Attributes" and "Operations".
10. We need to set the Text property of the "Attributes" & "Operations"
shape, so that it reflects on the diagram.

So these are the Ten basic steps one needs to follow to create a UML shape
(CLASS) and assign values to Text property of "Attributes" and "Operations"
in order to define the Fields and Methods of the class.

I will post the entire code when i have the prototype ready. If anyone has
more ideas on this, do let me know.

Regards,
Sarang S. Datye
[Microsoft MVP - Visual Basic]
 
M

Mete

Hi all,


Reverse engineering seems to work partially (i.e., C# to UML). The class
relationships (dependency, composition, aggregation etc.. ) are not displayed
after dragging the classes from Navigator to the Static Structure Diagram.
Does anybody know if this feature is available in Visio 2003? If not as I
susspect, additional code development to add this features may be vary
valuable.

Thanks in advance for any answers, opinions.

Thanks in advance


Sarang_MVP said:
Hi,

I got some clue on how to go about doing this code to uml thing in visio.
Here's how:

1. Use the OpenEx method to open UMLSTR_U.VSS stencil .
2. create a copy of the UMLMOD_U.VST template using Add method of the
Documents collection.
3. Add a page to the Pages collection of the document that was added in step2.
4. Do assembly.GetTypes for iterating through each type.
5. Get the master object from the stencil using the ItemU property of the
Masters collection of the document object. :)
e.g. Document.Masters.ItemU(visClass)
6. Do a for each type in Types retrieved in step 4.
7. Use the Drop method of the Page to drop a copy of the master object
retrieved in step 5. e.g. Page.Drop(objMaster, X, Y)
8. The drop method returns a shape.
9. Iterate through the shapes collection of the shape retrieved in 8 and
trace out the shapes identified by name = "Attributes" and "Operations".
10. We need to set the Text property of the "Attributes" & "Operations"
shape, so that it reflects on the diagram.

So these are the Ten basic steps one needs to follow to create a UML shape
(CLASS) and assign values to Text property of "Attributes" and "Operations"
in order to define the Fields and Methods of the class.

I will post the entire code when i have the prototype ready. If anyone has
more ideas on this, do let me know.

Regards,
Sarang S. Datye
[Microsoft MVP - Visual Basic]

Thanks in advance.

Sarang S. Datye
[Microsoft MVP - Visual Basic]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top