<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Liu<br>
<br>
Thanks for the reply!<br>
<br>
I did as you suggested. Here's what I got with type()<br>
<br>
type(verifiedValues)<br>
<type 'dict'><br>
<br>
So it is a dictionary, right? Then I tried dir(verifiedValues)<br>
<br>
dir(verifiedValues)<br>
['Add', 'Clear', 'Contains', 'ContainsKey', 'CopyTo', 'Count',
'Equals', 'GetEnumerator', 'GetHashCode', 'GetType',<br>
'Item', 'Keys', 'MemberwiseClone', 'ReferenceEquals', 'Remove',
'ToString', 'TryGetValue', 'Values', '__add__', <br>
'__class__', '__cmp__', '__contains__', '__delattr__',
'__delitem__', '__doc__', '__eq__', '__format__', '__ge__', <br>
'__getattribute__', '__getitem__', '__gt__', '__hash__',
'__init__', '__iter__', '__le__', '__len__', '__lt__', '__ne__', <br>
'__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__setattr__', '__setitem__', '__sizeof__', '__str__', <br>
'__subclasshook__', 'clear', 'copy', 'fromkeys', 'get',
'has_key', 'items', 'iteritems', 'iterkeys', 'itervalues', 'keys', <br>
'pop', 'popitem', 'setdefault', 'update', 'values']<br>
<br>
This doesn't really say much to me, is it any help to you? Or should
I use dir() in some other way? <br>
<br>
I tried some of those, for example<br>
<br>
dict.Contains(verifiedValues,'/Optimization/InputParameter:P1')<br>
False<br>
<br>
So I think this tells me - once again - that there is no such key in
verifiedValues.<br>
<br>
I also tried<big><big><big><big><big><big><span
class="Apple-style-span" style="font-family:
arial,sans-serif; font-size: 13px; background-color:
rgb(255, 255, 255);"></span></big></big></big></big></big></big>
new_verifiedValues=dict(verifiedValues) but got the same result<br>
<br>
new_verifiedValues=dict(verifiedValues)<br>
new_verifiedValues['/Optimization/InputParameter:P1']<br>
KeyNotFoundException: /Optimization/InputParameter:P1<br>
<br>
Would you have any thoughts about what I could try next?<br>
<br>
Best regards<br>
Ossi Heinonen<br>
<br>
<br>
On 24.11.2011 13:05, 刘振海 wrote:
<blockquote
cite="mid:CAGZyxue5qtT9Epy4wPq0ZZqw9hid53PJtYo=JyYYXOaBLBEbpA@mail.gmail.com"
type="cite">Hi,
<div>I think you should check the type of <span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">verifiedValues
like "type(</span><span class="Apple-style-span"
style="font-family: arial,sans-serif; font-size: 13px;
background-color: rgb(255, 255, 255);">verifiedValues</span><span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">)"</span></div>
<div><span class="Apple-style-span" style="font-family:
arial,sans-serif; font-size: 13px; background-color: rgb(255,
255, 255);">then use the dir function to check the content of </span><span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">verifiedValues.</span></div>
<div><span class="Apple-style-span" style="font-family:
arial,sans-serif; font-size: 13px; background-color: rgb(255,
255, 255);">maybe try to use new_</span><span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">verifiedValues</span><span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">=dict(</span><span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">verifiedValues</span><span
class="Apple-style-span" style="font-family: arial,sans-serif;
font-size: 13px; background-color: rgb(255, 255, 255);">)</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif">Hope
it will help!</font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><br>
</font></div>
<div><font class="Apple-style-span" face="arial, sans-serif">Regards,</font></div>
<div><font class="Apple-style-span" face="arial, sans-serif">Liu
Zhenhai</font></div>
<div><br>
<div class="gmail_quote">2011/11/24 Ossi Heinonen <span
dir="ltr"><<a moz-do-not-send="true"
href="mailto:ossi.heinonen@tut.fi">ossi.heinonen@tut.fi</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">Hi all!<br>
<br>
I have a problem with scripting the FEA software Ansys
Workbench with IronPython. I need to come up with a script
that gets the variable 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 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 P2 and P3 with their values at the optimum.
Looking good so far. So now 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 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 double quotes and any other variation that
I've come up with. If I make a new dictionary manually with
the exact same keys and values copied from the screen it
works just fine. But I can't get anything out of the
original dictionary.<br>
<br>
Any ideas on how to get it working or what could be done to
debug this? The only idea I've had is that for some reason
the keys are printed incorrectly and some characters are
actually missing from their names, but I might be totally
off with this.<br>
<br>
Needless to say that I'm a total newbie with Python.
Probably the right people to ask are other Ansys users, but
I've had no luck finding one 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 moz-do-not-send="true"
href="mailto:Ironpython-users@python.org" target="_blank">Ironpython-users@python.org</a><br>
<a moz-do-not-send="true"
href="http://mail.python.org/mailman/listinfo/ironpython-users"
target="_blank">http://mail.python.org/mailman/listinfo/ironpython-users</a><br>
</blockquote>
</div>
<br>
</div>
</blockquote>
</body>
</html>