Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - skranenburg

Pages: [1] 2
1
Hi,

I am working through automating parametric diagrams and currently have a script that will use the Matlab solver to execute the constraint block equation and populate the result in a PhsVariable. Is there a way to export that result value to an external tool, like Excel, without doing it manually?

Thanks!

2
Hi,

I have a imported package in my model that has a large number of systems represented as blocks with numeric tagged values. Is it possible to use these specific values within a parametric diagram for certain calculations? I have having trouble finding a way to "pull out" these values to use them elsewhere in the model. Any help on this would be much appreciated.

Thanks!

3
Hi,

In our project, we are trying to streamline report generation based on customized input. To clarify, we are assigning different requirements to a block based on a user's input and outputting those requirements. We have successfully written scripts to take in a csv file and create new "satisfies" connectors to all the necessary requirements, but have now run into the problem that those requirements are not included in the requirement section of the element's properties and thus, aren't outputted along with the rest of the report.

This is the connector script:

function SetGen(target /* ea element*/)
{
   var source as EA.Element;

   source = Repository.GetElementByGuid("{GUID}");
      
   //Instantiate new Connector
   var genConn as EA.Connector;
   var Connectors as EA.Collection;
   tarConn = target.Connectors;
   genConn = tarConn.AddNew("","Generalization");
   
   genConn.SupplierID = target.ElementID;
   genConn.ClientID = source.ElementID;
   
   var soConn as EA.Collection;
   var tarConn as EA.Collection;
   soConn = source.Connectors;

   
   for(i=0;i < tarConn.Count; i++)
   {
      if(tarConn.GetAt(i).Stereotype == "satisfy"){
            var localReq as EA.Element;
            localReq = Repository.GetElementByID(tarConn.GetAt(i).SupplierID);
            Session.Output(localReq.Name + " Applied from " + target.Name);
         
            var newReq as EA.Connector;
            newReq = soConn.AddNew("","Satisfy");
            newReq.SupplierID = source.ElementID;
            newReq.ClientID = localReq.ElementID;
            
            newReq.Update();
            soConn.Refresh();
            tarConn.Refresh();
            

      }
   }
   
   genConn.Update();
   source.Connectors.Refresh();
   target.Connectors.Refresh();

Any input on how to fix this would be greatly appreciated.

Thank you.

4
Awesome. Thank you Geert!

5
Hi,

I was wondering if anyone knew of a good, efficient way of adding tables or figures into part of a requirement's text. I am in the process of taking sections of specification documents and creating requirement elements for them, but many of these sections refer to various tables and figures throughout the text. The end goal for these requirements is for them to be included in a report based on the model.

Thanks!
Stefan

6
Hi Geert!

Thanks for the help! The InvokeFileDialog is definitely something I needed.

Seems like the RunReport method is liking the normal version of the GUID more than the XML version. I got the same errors at the report generation window. My issue is that the report that it outputs is not including any part of the template that includes the individual elements of the package. The diagrams in the package are included, though. I'm confused because going the manual route to output a report includes everything that I want.

Best,
Stefan

7
Also, if there is a way to write the file path so that it doesn't have to specific to one's computer, I would appreciate advice on how to do so.

8
Hi,

I've been attempting to write a small script (that will be added to another one later) that generates a report using RunReport. After several attempts, I finally got past the errors that would appear as the report generation window pops up, but the report I get does not include the elements and their requirements (the main reason for the report). Going the normal route in generating a report with the same template does, however. This is my script. I have edited the GUID and the file path for this post.

var prj = Repository.GetProjectInterface();
var pkge as EA.Package;

function main()
{
   pkge = Repository.GetPackageByGUID("{GUID}");
   pkge.Update();
   prj.RunReport(pkge.PackageGUID, "Requirement Test", "C:\\Users\\...\\Report Generation\\3.docx");
}

main();

I'm not sure if the is a problem is with this little block of script, but if anyone could give me some insight, I would greatly appreciate it!

Thank you!
Stefan

9
Hi Geert.

Thank you for the quick reply and apologies for the extended delay. I have been thinking of how to readdress this problem and how to organize our model around it. What I need in my report now is a few specific diagrams from different packages, and the details of one block including all the requirements that are connected to it with the satisfies connector. This may be a trivial question, but I have not been able to find the answer to it. How do I make the report only include those specific diagrams and block without including everything else in the packages?

Thanks,
Stefan

10
That worked! Thank you!

11
Thank you Qwerty!

Ya, I'm new to scripting and Sparx so that was definitely a rookie mistake. I don't have any errors anymore but I don't see the connector on the diagram or in the properties of the blocks that were called.

12
Hi,

As the title says, I am trying to create connectors using the Sparx scripting feature (specifically Javascript), and keep running into errors that I haven't been able to fix. This is what I have so far:

function OnDiagramScript()
{
   // Get a reference to the current diagram
   var currentDiagram as EA.Diagram;
   currentDiagram = Repository.GetCurrentDiagram();
   m_repository = new COMObject("Scripting.FileSystemObject");

   if ( currentDiagram != null )
   {
      var source as EA.Element;
      var target as EA.Element;
      source = Repository.GetElementByGuid("{E4AF64F9-3720-4b89-97CS-93D90C3CF192}");
      target = Repository.GetElementByGuid("{E1FCC866-9DBE-4fc1-872E-A66D3F5845D5}");
      
      // Get a reference to any selected connector/objects
      
      var genConn as EA.Connector
      var Connectors as EA.Collection;
      Connectors = theElement.Connectors;
      genConn = Connectors.AddNew("", "Generalization");
      genConn.SupplierID = target.ElementID;
      genConn.ClientID = source.ElementID;
      
      genConn.Update;
      source.Connectors.Refresh;
      target.Connectors.Refresh;

      
   }
   else
   {
      Session.Prompt( "This script requires a diagram to be visible.", promptOK)
   }
}

OnDiagramScript();

I am not very experienced with this so I have been trying to patch scripts that I've found on the internet together. The error right now is that "TheElement" isn't defined. Can someone help me find what is wrong?

Thanks!

13
Hi,

I know that there is a way to have only specific requirements populate a generated document with an SQL query, but since I am new to Sparx and SQL, I have having trouble finding the correct way to do it. I have a bunch of blocks with requirements tied to them using the "satifies" connector and need to have sections of a document allocated to specific block's requirements. What would a document template that accomplishes this look like?

Thank you for your help!

14
Hi Geert,

Thank you for your response! I think this could help me a ton. Is it possible for these elements that are selected to be part of the report to be in different diagrams?

15
Thank you for the quick response, qwerty. Ya, it seems as if my best course of action is to continue to add substance to the model, but explain to my manager that what he is asking for is unrealistic. Hopefully, we will add more people to the team. I really like MBSE and can see my career headed in that direction, but it is frustrating that I am having to do a lot of learning on my own and not much access to experts even at my own company.

Pages: [1] 2