


{"id":364189,"date":"2024-04-25T12:33:27","date_gmt":"2024-04-25T12:33:27","guid":{"rendered":"\/forum\/forums\/reply\/364189\/"},"modified":"2024-04-25T12:33:27","modified_gmt":"2024-04-25T12:33:27","slug":"364189","status":"publish","type":"reply","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/reply\/364189\/","title":{"rendered":"Reply To: Run IronScript from slurm"},"content":{"rendered":"<p>&lt;p&gt;Hi Keniel,&lt;br&gt;&lt;br&gt;Please try the following:&lt;\/p&gt;&lt;p&gt;<strong><em>$&nbsp; export ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1&lt;br&gt;<\/em><\/strong><strong><em>$&nbsp; ansysedt.exe -features=beta -ng -runscriptandexit &lt;scriptName&gt; [&lt;projectName&gt;]<\/em><\/strong>&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;&lt;br&gt;Please search AEDT help for &#8220;&lt;\/span&gt;Running Ansys Electronics Desktop from a Command Line&#8221;&lt;br&gt;&lt;br&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;Note &#8211; &#8216;-ng&#8217; and &#8216;-runscriptandexit&#8217; have been available since 2019R1&lt;br&gt;&lt;br&gt;&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Desktop automation is in terms of COM calls to the various COM objects exposed by desktop. This has always been unconditionally supported in a general-purpose graphical mode (&lt;span style=&#8221;font-style: italic;&#8221;&gt;Desktop with a GUI or in Iconic mode without specialized -batchextract etc modes&lt;\/span&gt;). When desktop is run in non-graphical mode (&lt;span style=&#8221;font-style: italic;&#8221;&gt;-ng in the command line)&lt;\/span&gt;, recorded scripts cannot be played back: instead, a select few commands are available via the &lt;span style=&#8221;font-style: italic;&#8221;&gt;-batchextract&lt;\/span&gt; script.&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;To ensure general command execution ability, AnsysET enforced the need for a GUI system: the user&rsquo;s compute environment required a graphics subsystem (&lt;span style=&#8221;font-style: italic;&#8221;&gt;X Servers on Linux in particular&lt;\/span&gt;) to be configured.&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Some commands when run graphically would be somewhat expensive because of the needed User Interface updates and sometimes a user composes a script with hundreds of such expensive calls slowing the execution down noticeably. Forcing the user to run desktop in GUI mode forced the performance penalties as well.&lt;\/p&gt;&lt;p style=&#8221;margin-top: 18pt; margin-bottom: 6pt; font-family: Arial; font-size: 16.0pt; color: black;&#8221;&gt;Non Graphical Command Limitations&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;2019 R1 release starts making progress toward allowing all commands to be run non-graphically. commands will be transitioned in phases and some graphical commands like Plot Export will be unavailable initially. If such commands are used, script execution will be terminated with a suitable error message.&lt;\/p&gt;&lt;p style=&#8221;margin-top: 18pt; margin-bottom: 6pt; font-family: Arial; font-size: 16.0pt; color: black;&#8221;&gt;Enabling from the GUI&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Bring up the Options and enable &ldquo;beta&rdquo; features. If enabling all beta features is not desired, then the command line will have to be used with the &ldquo;&lt;span style=&#8221;font-style: italic;&#8221;&gt;-features&lt;\/span&gt;=&lt;span style=&#8221;font-style: italic;&#8221;&gt;SF6694_Non_Graphical_Command_execution&rdquo; &lt;\/span&gt;parameter.&lt;\/p&gt;&lt;p style=&#8221;margin-top: 18pt; margin-bottom: 6pt; font-family: Arial; font-size: 16.0pt; color: black;&#8221;&gt;Enabling from the Command Line&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Invoke desktop in ng mode for script execution by specifying the beta flag: this allows the existing &lt;span style=&#8221;font-style: italic;&#8221;&gt;-runscriptandexit &lt;\/span&gt;command-line parameter to work in non-graphical mode as well.&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-weight: bold; font-style: italic;&#8221;&gt;ansysedt.exe -features=beta -ng -runscriptandexit &lt;scriptName&gt; [&lt;projectName&gt;]&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Note: -features=&rdquo;beta&rdquo; turns on all beta features. If there is a need to disable all beta features except &lt;span style=&#8221;font-style: italic;&#8221;&gt;&ldquo;non-graphical command execution&rdquo;, &lt;\/span&gt;the more specific &ldquo;&lt;span style=&#8221;font-style: italic;&#8221;&gt;-features&lt;\/span&gt;=&lt;span style=&#8221;font-style: italic;&#8221;&gt;SF6694_Non_Graphical_Command_execution&rdquo; &lt;\/span&gt;can be used instead.&lt;\/p&gt;&lt;p style=&#8221;margin-top: 18pt; margin-bottom: 6pt; font-family: Arial; font-size: 16.0pt; color: black;&#8221;&gt;Enabling For Workbench Scenarios&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Prior to 19R1, when workbench was run in batch mode &lt;span style=&#8221;font-style: italic;&#8221;&gt;(-B command line parameter)&lt;\/span&gt;, several methods of the Electromagnetics Addin are disabled. This saga-feature enables them back and allows all Workebench&lt;-&gt;AnsysEDT interaction to occur fully non-graphically. To enable this, you must set the following environment variable.&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;ANSYSEM_FEATURE_SF6694_NON_GRAPHICAL_COMMAND_EXECUTION_ENABLE=1&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin-top: 18pt; margin-bottom: 6pt; font-family: Arial; font-size: 16.0pt; color: black;&#8221;&gt;Enabling for stand-alone scripting scenarios&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;For stand-alone scripting scenarios (&lt;span style=&#8221;font-style: italic;&#8221;&gt;where the ipy64.exe interpreter is used instead of ansysem.exe to run the script)&lt;\/span&gt;. Refer to online help and search for &ldquo;&lt;span style=&#8221;font-style: italic;&#8221;&gt;Standalone IronPython&lt;\/span&gt;&rdquo; for additional details.&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Arial; font-size: 11.0pt; color: black;&#8221;&gt;Standalone graphical scripts, have the following preamble.&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;import sys&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;sys.path.append(&#8220;&lt;application path&gt;&#8221;)&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;sys.path.append(&#8220;&lt;application path&gt;\/PythonFiles\/DesktopPlugin&#8221;)&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;import ScriptEnv&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;ScriptEnv.Initialize(&#8220;Ansoft.ElectronicsDesktop&#8221;)&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;This is used for the typical graphical AnsysEDT COM server. For, non-graphical com servers, the final &lt;span style=&#8221;font-style: italic;&#8221;&gt;ScriptEnv.Initialize&lt;\/span&gt; is replaced by ScriptEnv.InitializeNew.&lt;\/p&gt;&lt;ul style=&#8221;direction: ltr; unicode-bidi: embed; margin-top: 0in; margin-bottom: 0in;&#8221; type=&#8221;disc&#8221;&gt;&lt;li style=&#8221;margin-top: 0; margin-bottom: 0; vertical-align: middle; color: black;&#8221;&gt;&lt;span style=&#8221;font-weight: bold; font-family: Verdana; font-size: 11.0pt;&#8221;&gt;Note: &lt;\/span&gt;&lt;span style=&#8221;font-weight: bold; font-style: italic; font-family: Verdana; font-size: 11.0pt;&#8221;&gt;InitializeNew&lt;\/span&gt;&lt;span style=&#8221;font-weight: bold; font-family: Verdana; font-size: 11.0pt;&#8221;&gt; does not take the COM ProgID since it launches the Exe directly by computing a path relative to the ScriptEnv.py module.&lt;\/span&gt;<\/li>\n<p>&lt;li style=&#8221;margin-top: 0; margin-bottom: 0; vertical-align: middle; color: black;&#8221;&gt;&lt;span style=&#8221;font-weight: bold; font-family: Verdana; font-size: 11.0pt;&#8221;&gt;Note: &lt;\/span&gt;&lt;span style=&#8221;font-weight: bold; font-style: italic; font-family: Verdana; font-size: 11.0pt;&#8221;&gt;InitializeNew&lt;\/span&gt;&lt;span style=&#8221;font-weight: bold; font-family: Verdana; font-size: 11.0pt;&#8221;&gt; specifies that a new instance is to be launched everytime. This helps by not connecting to existing COM server.&lt;\/span&gt;<\/li>\n<\/ul>\n<p>&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;import sys&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;sys.path.append(&#8220;&lt;application path&gt;&#8221;)&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;sys.path.append(&#8220;&lt;application path&gt;\/PythonFiles\/DesktopPlugin&#8221;)&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;import ScriptEnv&lt;\/span&gt;&lt;\/p&gt;&lt;p style=&#8221;margin: 0in; font-family: Verdana; font-size: 11.0pt; color: black;&#8221;&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;ScriptEnv.&lt;\/span&gt;&lt;span style=&#8221;font-weight: bold; font-style: italic;&#8221;&gt;InitializeNew&lt;\/span&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;( &lt;\/span&gt;&lt;span style=&#8221;font-weight: bold; font-style: italic;&#8221;&gt;NonGraphical &lt;\/span&gt;&lt;span style=&#8221;font-style: italic;&#8221;&gt;= True)&lt;\/span&gt;&lt;\/p&gt;<\/p>\n","protected":false},"template":"","class_list":["post-364189","reply","type-reply","status-publish","hentry"],"aioseo_notices":[],"acf":[],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/364189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/reply"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/replies\/364189\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=364189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}