![]() |
Telelogic System Architect (steve huntington) | ![]() |
Topic Title: ISAIMF and SA2001.Application with COM Topic Summary: Problems using both the ISAIMF interface and SA2001.Application objects with COM Created On: 3-Aug-2006 18:33 Status: Read Only |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I've been using the COM interface of SA for quite some time now to handle my SA interfacing needs and have had problems with this repeatedly. There are two methods to get
information out of SA using COM - using the ISAImf object's methods, or using SA2001 namespace objects themselves. For example: ----------------------------------------------------------------------------- To open a diagram using SA2001 namespace objects: SA2001.Application appSA; SA2001.ISAImf imfISA; SA2001.SAObjects oSAObjects; SA2001.Diagram oDiag; string strWildCard = "*"; int nDiagType = 0; object o; // Initiate the interface objects appSA = new SA2001.Application(); imfSA = (SA2001.ISAImf)appSA.Interface("ISAImf"); // Get a collection of all the diagrams oSAObjects = appSA.Encyclopedia.GetFilteredDiagrams(ref strWildCard, ref nDiagType); oSAObjects.ReadAll(); // Get a diagram item out of the SAObjects collection o = (object)1; oDiag = (SA2001.Diagram)oSAObjects.get_Item(ref o); // Open the diagram if(oDiag.Hidden) oDiag.Show(); ----------------------------------------------------------------------------- ----------------------------------------------------------------------------- To open a diagram using ISAImf: SA2001.Application appSA; SA2001.ISAImf imfISA; SA2001.SAObjects oSAObjects; SA2001.Diagram oDiag; string strWildCard = "*"; int nDiagType = 0; int idPrevDiagram = 0; int idDiagram = 0; int iDiagramHandle = 0; // Initiate the interface objects appSA = new SA2001.Application(); imfSA = (SA2001.ISAImf)appSA.Interface("ISAImf"); // Find a diagram imfISA.SAFindDiagram(ref idPrevDiagram, strWildcard, ref iDiagType, ref idDiagram); // Open the diagram imfISA.SAOpenOrActivateDiagram(ref iDiagram, ref iDiagramHandle); ----------------------------------------------------------------------------- Here's the problem. Not every method or property, etc that is available through the SA2001 namespace objects is available through the IMFIsa methods, and vice versa, there are some things that can only be done via the IMFIsa interface (at least this appears to be true in my experience). Either way, there are some things that are easier to do using one method versus the other. When I try to use a mix of both methods, I get access control problems. For example: ----------------------------------------------------------------------------- To Get the SVG of every diagram a) the diagram has to be open so there is a handle, b) only method to get the SVG is to use the SA2001.ISAImf.SADiagramToSVG(ref int lphDiagramHandle, string bsSVGFileName) function. SA2001.Application appSA; SA2001.ISAImf imfISA; SA2001.SAObjects oSAObjects; SA2001.Diagram oDiag; string strWildCard = "*"; string strPath = "C:\\"; int nDiagType = 0; int idPrevDiagram = 0; int idDiagram = 0; int iDiagramHandle = 0; // Initiate the interface objects appSA = new SA2001.Application(); imfSA = (SA2001.ISAImf)appSA.Interface("ISAImf"); // Get a collection of all the diagrams oSAObjects = appSA.Encyclopedia.GetFilteredDiagrams(ref strWildCard, ref nDiagType); oSAObjects.ReadAll(); // Save the SVG of each diagram for(int i = 1; i <= oSAObjects.Count; i++) { // Get a diagram item out of the SAObjects collection o = (object)i; oDiag = (SA2001.Diagram)oSAObjects.get_Item(ref o); // Get the handle of the diagram if(oDiag.Hidden) imfISA.SAOpenOrActivateDiagram(ref iDiagram, ref iDiagramHandle); // by opening the diagram in the background else iDiagramHandle = oDiag.Handle; // or from the SA2001.Diagram object if its already open // Save the svg file imfISA.SADiagramToSVG(ref iDiagramHandle, strPath + oDiag.Name + ".svg"); } ----------------------------------------------------------------------------- Now, what happens is when the SAOpenOrActivateDiagram function is called, you get an error saying that the object is already in use. This is because you also have a reference to the object in oDiag. You probably cannot do the above routine in ISAimf exclusively because I don't think you can check to see if the diagram is open using only teh ISAimf interface. Even if you can, it will involve a number of calls versus a single property in the SA2001 namespace diagram object. This is just an example of how this problem occurs. Even if this particular routine can be done exclusively in IMFIsa, it doesn't *solve* my problem because there are other instances where you cannot or where it is much more cumbersome to exclusively use one method over another; I've seen VBA code on the forums here and code I've written in the past that does not run into this problem but I don't really understand why. Is it possible to use a mix of the two methods when interfacing via COM? How does one avoid access problems like I am having above? I know this was long, but I felt it necessary to completely explain the issue at hand with as little ambiguity as possible. Thank you for helping! -Zach (P.S. I wrote the above code as an example and have not compiled or tested it to verify that it works 100%, just incase some is trying to reuse that code and runs into a problem) Edited: 3-Aug-2006 at 18:40 by Jonathan Burlingame |
|
![]() |
|
![]() |
|
Have you tried setting the oDiag objects ReadOnly property to True?
Another options is the Encyclopedia's object OpenObjectsAsReadOnly. Set this before loading the oDiag object. For a real die hard option you can always output the diagram to SVG format by creating your own parser (if you have time and energy). There is a great tutorial on the SVG format that covers everything. www.w3.org/2002/Talks/www2002-svgtut-ih/hwtut.pdf Here's a quicky from freeskills.com http://tutorials.freeskills.com/an-introduction-to-svg.htm |
|
![]() |
|
![]() |
|
Thanks Duane, I'll have to check into the ReadOnly option tomorrow when I get into work.
I have considered converting the data into SVG myself, but not only does that require quite a bit of (re-)work over the current built-in method but I also don't want to have to implement something myself everytime I would like to inter-mix the methods. There may be some things that I couldn't even implement myself because the necessary methods or information may not be visible. |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.