<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Eyvind<br>
<br>
<big><font size="2"><big>That gives me <br>
<br>
print verifiedValues[dict.keys(verifiedValues)[0]]<br>
5.5 [mm]<br>
</big></font></big><br>
Which is pretty damn exactly what I need! Thank you very much! The
only problem now is that the order of the keys seems a bit random
but maybe I can find some pattern for that.<br>
<br>
Thanks again!<br>
<br>
- Ossi<br>
<br>
<br>
On 25.11.2011 11:24, Eyvind Axelsen wrote:
<blockquote
cite="mid:6A375D8809CD5E4B86F3444358F9A64C3C956B@exchangesrv.profdoc.no"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="MS Exchange Server version
6.5.7654.12">
<title>RE: [Ironpython-users] Scripting Ansys with IronPython -
Unable to callvalues from dictionary</title>
<!-- Converted from text/plain format -->
<p><font size="2">Hi Ossi,<br>
<br>
I had some problems posting to the list, so I send to you
directly:<br>
<br>
<br>
What happens if you try the following?<br>
<br>
print verifiedValues[dict.keys(verifiedValues)[0]]<br>
<br>
<br>
Eyvind.<br>
<br>
<br>
<br>
<br>
-----Original Message-----<br>
From: <a class="moz-txt-link-abbreviated"
href="mailto:ironpython-users-bounces+eyvind.axelsen=profdoc.no@python.org">ironpython-users-bounces+eyvind.axelsen=profdoc.no@python.org</a>
on behalf of Ossi Heinonen<br>
Sent: Thu 24.11.2011 09:54<br>
To: <a class="moz-txt-link-abbreviated"
href="mailto:Ironpython-users@python.org">Ironpython-users@python.org</a><br>
Subject: [Ironpython-users] Scripting Ansys with IronPython -
Unable to callvalues from dictionary<br>
<br>
Hi all!<br>
<br>
I have a problem with scripting the FEA software Ansys
Workbench with<br>
IronPython. I need to come up with a script that gets the
variable<br>
values in an optimum point that I have found using the
optimization tools.<br>
<br>
I found some help for this with "VerifyCandidate" in the
scripting guide<br>
in the Ansys manual and did this in the Ansys Workbench
command window:<br>
<br>
IronPython 2.6.10920.0 on .NET 2.0.50727.3625<br>
system1 = GetSystem(Name="GDO")<br>
optimization1 =
system1.GetContainer(ComponentName="Optimization")<br>
optimizationModel1 = optimization1.GetModel()<br>
verifiedValues =
optimizationModel1.VerifyCandidate(Index=0)<br>
print verifiedValues<br>
{'/Optimization/OutputParameter:P3': '-0.035979796200990677
[mm]',<br>
'/Optimization/InputParameter:P1': '5.5 [mm]',<br>
'/Optimization/OutputParameter:P2': '0.07417053282883164
[kg]'}<br>
<br>
Now I have a dictionary with my one design variable P1 and two
responses<br>
P2 and P3 with their values at the optimum. Looking good so
far. So now<br>
I only need to get my hands on the values and I'm home free.<br>
<br>
I think this should give me the value of the design variable
P1:<br>
<br>
verifiedValues['/Optimization/InputParameter:P1']<br>
KeyNotFoundException: /Optimization/InputParameter:P1<br>
<br>
But no, I get an error saying that there is no such key. But
when I list<br>
the keys, it's right there:<br>
<br>
dict.keys(verifiedValues)<br>
['/Optimization/OutputParameter:P3',<br>
'/Optimization/OutputParameter:P2',
'/Optimization/InputParameter:P1']<br>
<br>
So this is my problem. I've tried calling it without the
quotes or with<br>
double quotes and any other variation that I've come up with.
If I make<br>
a new dictionary manually with the exact same keys and values
copied<br>
from the screen it works just fine. But I can't get anything
out of the<br>
original dictionary.<br>
<br>
Any ideas on how to get it working or what could be done to
debug this?<br>
The only idea I've had is that for some reason the keys are
printed<br>
incorrectly and some characters are actually missing from
their names,<br>
but I might be totally off with this.<br>
<br>
Needless to say that I'm a total newbie with Python. Probably
the right<br>
people to ask are other Ansys users, but I've had no luck
finding one<br>
that could help me. Maybe my luck will chance with you Python
gurus :)<br>
<br>
All help is greatly appreciated!<br>
<br>
Best regards<br>
<br>
Ossi Heinonen<br>
Researcher<br>
Tampere University of Technology<br>
Finland<br>
<br>
_______________________________________________<br>
Ironpython-users mailing list<br>
<a class="moz-txt-link-abbreviated"
href="mailto:Ironpython-users@python.org">Ironpython-users@python.org</a><br>
<a moz-do-not-send="true"
href="http://mail.python.org/mailman/listinfo/ironpython-users">http://mail.python.org/mailman/listinfo/ironpython-users</a><br>
<br>
</font> </p>
</blockquote>
</body>
</html>