


{"id":160509,"date":"2021-07-20T09:05:12","date_gmt":"2021-07-20T09:05:12","guid":{"rendered":"\/forum\/forums\/topic\/how-to-execute-spaceclaim-script-within-act\/"},"modified":"2022-05-31T19:31:25","modified_gmt":"2022-05-31T19:31:25","slug":"how-to-execute-spaceclaim-script-within-act","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/how-to-execute-spaceclaim-script-within-act\/","title":{"rendered":"How to execute SpaceClaim script within ACT?"},"content":{"rendered":"<div class=\"Item-Body\">\n<div class=\"Message userContent\">\n<p>Hello everyone<\/p>\n<p>I&#039;m having difficulties implementing my previously developed SpaceClaim script, into an ACT scripting environment. I want to roll out this script solution out to my colleagues, as this design\/analysis is quite repetitive and I thought an ACT (APP) would be quite suitable for the task.<\/p>\n<p>The SpaceClaim script works perfectly within the SpaceClaim scripting environment. I&#039;ve modified the IronPython SpaceClaim script slightly to work better with ACT by:<\/p>\n<ol>\n<li>Splitting it into two .py files, the <strong>script <\/strong>and the <strong>definition (def) <\/strong>I&#039;ve defined<\/li>\n<li>Modified the input geometry variables to extract the values from the user (see example below)<\/li>\n<\/ol>\n<p><code class=\"code codeInline\" spellcheck=\"false\">br_h.Add(step.Properties[&quot;Geometry\/br_h_top&quot;].Value)&nbsp;<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">br_h.Add(step.Properties[&quot;Geometry\/br_h_bot&quot;].Value)&nbsp;<\/code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/p>\n<p>&nbsp;<code class=\"code codeInline\" spellcheck=\"false\">AC_geo.Add(&#039;br_h&#039;,br_h)<\/code><\/p>\n<p><\/p>\n<\/p>\n<p>So far I&#039;ve achieved the following in ACT:<\/p>\n<ol>\n<li>Defining the steps<\/li>\n<li>Setting up the workbench interface (separate load cases)<\/li>\n<li>Opening SpaceClaim <\/li>\n<li>Defining the geometry input<\/li>\n<li>Extracting the geometrical values from 4., to be used further in the IronPython code.<\/li>\n<\/ol>\n<p>After that the ACT program crashes on a line where I define: <\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;variable = Direction.Create(1,0,0)<\/code><\/p>\n<p>or:<\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">variable&nbsp;= List[IComponent]()<\/code><\/p>\n<p>My conclusion is therefore that: <em>ACT does not recognize the internal SpaceClaim IronPython functions as default.<\/em><\/p>\n<p>I&#039;ve tried to define the following default <strong>definition <\/strong>that &quot;imports&quot; the default SpaceClaim IronPython definitions. ACT can call and run the <strong>definition <\/strong>, but it doesn&#039;t work&#8230;..<\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">def script_import():<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;&#039;&#039;&#039;<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;This function imports SpaceClaim scripting for ACT<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;&#039;&#039;&#039;<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;import clr<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;clr.AddReference(&quot;Ansys.ACT.Interfaces&quot;)<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;import Ansys<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;clr.AddReference(&quot;SpaceClaim.Api.V19&quot;)<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;import SpaceClaim<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;clr.AddReference(&#039;SpaceClaim.Api.V19.Scripting&#039;)<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;from SpaceClaim.Api.V19 import Geometry<\/code><\/p>\n<p>&nbsp;<code class=\"code codeInline\" spellcheck=\"false\">&nbsp;from SpaceClaim.Api.V19 import Modeler<\/code><\/p>\n<p><code class=\"code codeInline\" spellcheck=\"false\">&nbsp;&nbsp;return<\/code><\/p>\n<p>I&#039;ve searched for days for some kind of solution online and in the ANSYS guides, but I cannot find my way around this problem. Do any of you have any suggestions?<\/p>\n<p><\/p>\n<\/p>\n<p><strong>Note<\/strong>: I cannot share the source code as it owned by the company I work for, but I can share some of if it would help<\/p>\n","protected":false},"template":"","class_list":["post-160509","topic","type-topic","status-closed","hentry","topic-tag-act","topic-tag-application-1","topic-tag-scripting","topic-tag-spaceclaim","topic-tag-workbench"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_author_ip":[""],"_bbp_view_count":["236"],"_bbp_likes_count":["0","0"],"_bbp_forum_subforum_count":["0"],"_btv_view_count":["2993"],"_bbp_subscription":["231731"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_topic_id":["160509"],"_bbp_forum_id":["27789"],"_bbp_engagement":["22865","23650","213086"],"_bbp_voice_count":["3"],"_bbp_reply_count":["3"],"_bbp_last_reply_id":["186040"],"_bbp_last_active_id":["186040"],"_bbp_last_active_time":["2022-05-31 19:31:25"]},"test":"bjmelorsted-dk"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/160509","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics"}],"about":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/160509\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=160509"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}