<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
p.gmail-m-4047226645764435582msolistparagraph, li.gmail-m-4047226645764435582msolistparagraph, div.gmail-m-4047226645764435582msolistparagraph
        {mso-style-name:gmail-m_-4047226645764435582msolistparagraph;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FR" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Brandon,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Thank you very much for your reply !<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I just tried to add the complete path to my script file as you mentionned but nothing changes…<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Now I was looking on the dependency of Type 169.dll and it seems that one dependency is missing (TRNDLL64.DLL)…. ?<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">I guess that’s the reason why the type 169 does not work.<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Best regards<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Antoine</span><b><span style="font-size:9.0pt;font-family:"Segoe UI",sans-serif;color:red;mso-fareast-language:EN-US"><o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">De :</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Brandon Hathaway <brandon.hathaway@sunvapor.net>
<br>
<b>Envoyé :</b> mercredi 1 juillet 2020 19:14<br>
<b>À :</b> TRNSYS users mailing list at OneBuilding.org <trnsys-users@lists.onebuilding.org><br>
<b>Cc :</b> Armandine Les Landes Antoine <A.ArmandineLesLandes@brgm.fr><br>
<b>Objet :</b> Re: [TRNSYS-users] TRNSYS 18 : type 169 python<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi Antoine,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I experienced the same behavior, and was able to trace down the cause with some digging into the Type169 source code.  In my case, it seemed that specifying the name of the Python script alone, rather than the complete path, was causing
 an issue when the code attempts to strip the script name and script path into separate variables.  The variable "scriptPath" contained just the name of the script, causing an undesired result when the Type169 code attempts to execute a "sys.path.append()"
 command through Python, resulting in the inability to Import the script.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I suspect that if you just specify the complete path to your script file in the entry box within the TRNSYS Type169 Special Cards configuration tab, rather than only the filename, the Type169 should work.  (However, the fix I ended up using
 since I was already into the source code is described below just in case anyone finds it helpful.)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">In my case, I fixed the issue in the source code by commenting out the existing line that executes the above mentioned command around line 267:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">// PyRun_SimpleString(scriptPath.c_str());<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Then I added the following two lines which (1) import the OS module in the Python session then (2) use that module to get the current working directory and append it to the path:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">PyRun_SimpleString("import os");<br>
PyRun_SimpleString("sys.path.append(os.getcwd())");<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">After making those changes and recompiling the Type169.dll, my issue was resolved when specifying just the name of a script within the current working directory.  (Note, this makes it so that the script must ALWAYS be within the current
 working directory, as the path/filename stripping part of the code is now ignored.)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">As for the TRNSYSpy module, it isn't a file, but is created within the Type169 program and appended to the Inittab just before python is initialized, which you'll see if you open the C++ source code around lines 262-264, so don't worry
 about that portion.<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><br>
Best regards,<br>
-Brandon<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">On Wed, Jul 1, 2020 at 4:12 AM Armandine Les Landes Antoine via TRNSYS-users <<a href="mailto:trnsys-users@lists.onebuilding.org">trnsys-users@lists.onebuilding.org</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hello all,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I am trying to use the python with the Type 169.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Note that :<o:p></o:p></p>
<p class="gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7.0pt">       
</span>Python 3 (3.7) is correclty installed and it is accessible from the cmd line.<o:p></o:p></p>
<p class="gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7.0pt">       
</span>TRNSYS is installed to the root of C :<o:p></o:p></p>
<p class="gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7.0pt">       
</span>Python is in the Windows path<o:p></o:p></p>
<p class="gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7.0pt">       
</span>…<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I do not understand why nothing happen when I perform a simulation…<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I can not find anywhere the TRNSyspy module ??<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Could you provide an example of TRNSys using the Type 169 ? there is no example in TRNSYS18/Examples/.  such as Calling_Python ? that could help…<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thank you for you help !<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Best regards,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Antoine<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">_______________________________________________<br>
TRNSYS-users mailing list<br>
<a href="mailto:TRNSYS-users@lists.onebuilding.org" target="_blank">TRNSYS-users@lists.onebuilding.org</a><br>
<a href="https://urldefense.com/v3/__http:/lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.org__;!!KbSiYrE!3KgRiZFdQB9lulJRoOYCbkNbIEabZZbSR-5KHiOfstBA5V6Xau1CG8_pwSNShjipGA-J5607$" target="_blank">http://lists.onebuilding.org/listinfo.cgi/trnsys-users-onebuilding.org</a><o:p></o:p></p>
</blockquote>
</div>
</div>
</body>
</html>