<div dir="ltr">Hi Antoine,<div><br></div><div>Are you having trouble recompiling the Type169 DLL? The files TRNDll64.dll (or the TRNDll64.lib file you'd want to link to if recompiling Type169.dll) are available in the TRNSYS18\Exe directory.  </div><div><br></div><div>In order to compile the type, I used what may not be the most elegant solution, and just copied the following files to the directory containing my modified Type169 source code:</div><div> "...\TRNSYS18\SourceCode\Templates\TRNSYS.h"</div><div>"...\TRNSYS18\Exe\TRNDll64.lib"</div><div>"

C:\ProgramData\Anaconda3\libs\python37.lib"</div><div><br></div><div>I then built the DLL using the GNU C++ compiler with the following commands:</div><div><br></div><div>g++ -c -IC:\ProgramData\Anaconda3\include Type169_modified.cpp<br>g++ -shared -o Type169.dll Type169_modified.o -Wl,TRNDll64.lib,python37.lib<br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><br></div><div>(Note that the Python install directory I used to get the python37.lib file and during compilation will be unique to your specific installation, "C:\ProgramData\Anaconda3" just happens to be the path for me.)  <br></div><div><br></div><div>Backing up the old Type169.dll in the "...\TRNSYS18\UserLib\ReleaseDLLs" folder and replacing it with this one based on my source code modifications mentioned before allows me to use Type169 with Python scripts as desired.</div><div><br></div><div>Best of luck!</div><div>-Brandon</div><div><br></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jul 1, 2020 at 1:12 PM Armandine Les Landes Antoine <<a href="mailto:A.ArmandineLesLandes@brgm.fr">A.ArmandineLesLandes@brgm.fr</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="FR">
<div class="gmail-m_-7282178134449061962WordSection1">
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Hi Brandon,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Thank you very much for your reply !<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I just tried to add the complete path to my script file as you mentionned but nothing changes…<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Now I was looking on the dependency of Type 169.dll and it seems that one dependency is missing (TRNDLL64.DLL)…. ?<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I guess that’s the reason why the type 169 does not work.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Best regards<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Antoine</span><b><span style="font-size:9pt;font-family:"Segoe UI",sans-serif;color:red"><u></u><u></u></span></b></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b><span style="font-size:11pt;font-family:Calibri,sans-serif">De :</span></b><span style="font-size:11pt;font-family:Calibri,sans-serif"> Brandon Hathaway <<a href="mailto:brandon.hathaway@sunvapor.net" target="_blank">brandon.hathaway@sunvapor.net</a>>
<br>
<b>Envoyé :</b> mercredi 1 juillet 2020 19:14<br>
<b>À :</b> TRNSYS users mailing list at OneBuilding.org <<a href="mailto:trnsys-users@lists.onebuilding.org" target="_blank">trnsys-users@lists.onebuilding.org</a>><br>
<b>Cc :</b> Armandine Les Landes Antoine <<a href="mailto:A.ArmandineLesLandes@brgm.fr" target="_blank">A.ArmandineLesLandes@brgm.fr</a>><br>
<b>Objet :</b> Re: [TRNSYS-users] TRNSYS 18 : type 169 python<u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">Hi Antoine,<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></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.<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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.)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">// PyRun_SimpleString(scriptPath.c_str());<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></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:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">PyRun_SimpleString("import os");<br>
PyRun_SimpleString("sys.path.append(os.getcwd())");<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal"><u></u> <u></u></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.)<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></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.<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><br>
Best regards,<br>
-Brandon<u></u><u></u></p>
</div>
<p class="MsoNormal"><u></u> <u></u></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" target="_blank">trnsys-users@lists.onebuilding.org</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0cm 0cm 0cm 6pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal">Hello all,<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I am trying to use the python with the Type 169.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Note that :<u></u><u></u></p>
<p class="gmail-m_-7282178134449061962gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7pt">       
</span>Python 3 (3.7) is correclty installed and it is accessible from the cmd line.<u></u><u></u></p>
<p class="gmail-m_-7282178134449061962gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7pt">       
</span>TRNSYS is installed to the root of C :<u></u><u></u></p>
<p class="gmail-m_-7282178134449061962gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7pt">       
</span>Python is in the Windows path<u></u><u></u></p>
<p class="gmail-m_-7282178134449061962gmail-m-4047226645764435582msolistparagraph">-<span style="font-size:7pt">       
</span>…<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I do not understand why nothing happen when I perform a simulation…<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I can not find anywhere the TRNSyspy module ??<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">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…<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">Thank you for you help !<u></u><u></u></p>
<p class="MsoNormal">Best regards,<u></u><u></u></p>
<p class="MsoNormal">Antoine<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></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><u></u><u></u></p>
</blockquote>
</div>
</div>
</div>

</blockquote></div>