cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Automation Problems

ptc-3171310
1-Visitor

Automation Problems

Hi I am working on an automation tool that will allow users to enter a bunch of design variables into a web app, which then interfaces with Mathcad and returns some answers along with an html copy of the worksheet. The interface uses a custom piece of code to interface with the API, however all commands are driven from an XML file. Essentially the program does the following: Open Worksheet Set Values Save as .xmcd Save as .html Read Val Close Worksheet I would like to be able to hide certain sections of the worksheet from the cody displayed to the users, mainly the sections that read data files and perform lookups etc, but also the section where all input variables are defined. I have done this using 'areas' on the sheet. The automation again works fine when these areas are open, however it fails when the areas are closed, returning an error message saying it cannot find the 1st variable I try to define. I am assuming this is because the software I am using to set the values is essentially doing a 'find and replace' on the variable names, and so if the variable is hidden it cannot find it. Ideally I would like to avoid putting the function definitions etc to the right of my calculation in order to hide it, so is there a way to open / close areas usingthe api, or can anyone think of a better alternative to using areas to hide data? Thanks Jamie
8 REPLIES 8
RichardJ
19-Tanzanite
(To:ptc-3171310)

You can't open or close areas from the API. Based on your description it sounds like you are setting the variables by modifying the XML of the regions. Is there a particular reason you are doing it this way rather than using SetValue? If you were to use SetValue the variable binding wouldn't appear on the worksheet in the first place, so the issue of hiding it would be moot. Richard

Hi Thanks for the info. I didn't write the software I am using to handle the API so I am unsure of how it works exactly, but it takes an input XML in the form: <?xml version="1.0" encoding="utf-8"?> <aj:MathcadJob xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aj="http://easa.chem-drb.dyndns.org/schemas"> <actions> <action xsi:type="aj:OpenFile"> <filename>C:\Projects\EASA\MathCAD\ASME8 Calc\ASME_PED_CALC_EASA.xmcd</filename> </action> <action xsi:type="aj:SetValueByName"> <comment>P</comment> <varName>P</varName> <real>6</real> <units>bar</units> </action> <action xsi:type="aj:SetValueByName"> <comment>Tm</comment> <varName>T</varName> <varNameSubscript>m</varNameSubscript> <real>0</real> </action> <action xsi:type="aj:SetValueByName"> <comment>Td</comment> <varName>T</varName> <varNameSubscript>d</varNameSubscript> <real>100</real> I am assuming it then goes on to search the XMCD file for these names, and sets the value accordingly.However, when look at the xmcd file using a text editior I can see these variables in the code, yet it doesn't seem to set the value if the area is hidden. Also, i have noticed when I run the program it sets the 1st value (P=6 bar) but falls over on the next value (T.m). Output as below: 0:Starting MathCad 1:Opening file:C:\Projects\EASA\MathCAD\ASME8 Calc\ASME_PED_CALC_EASA.xmcd 2:Setting value:P=6bar 3:Could not find variable name "T.m" defined in Mathcad document. --------------------------------------------- Job Summary Info. Start Time: 16/03/2010 08:01:30 End Time: 16/03/2010 08:01:35 The job did not complete successfully. --------------------------------------------- Any Ideas? Cheers Jamie
RichardJ
19-Tanzanite
(To:ptc-3171310)

Sorry, I'm not that familiar with XML. There must be more if it though, such as a definition of what <action xsi:type="aj:SetValueByName"> actually does. I see it sets the units as well as the value. That's why it presumably modifies the worksheet XML rather than using SetValue, which does not handle units. The only thing I can suggest is to set the variables in another worksheet, then reference that worksheet in the main one. You could hide the reference in a collapsed area. If you do that you should be aware that changing the values in the referenced worksheet will not cause the main worksheet to update. Forcing a recalculation of the main worksheet will not update the reference either. Richard
RichardJ
19-Tanzanite
(To:RichardJ)

As far as T.m goes, can't you just ask the person that wrote the software you are using to handle the API? Richard

Thanks Richard. I will try and get in contact with the author, otherwise I will find a way around using areas to hide the data. Jamie

If you are using the automation interface to access and modify regions, regions in collapsed areas are not a part of the regions collection and cannot be found or modified through that interface.

If you are using the automation interface to access and modify regions, regions in collapsed areas are not a part of the regions collection and cannot be found or modified through that interface.

If you are using the automation interface to access and modify regions, regions in collapsed areas are not a part of the regions collection and cannot be found or modified through that interface.
Announcements

Top Tags