


{"id":296218,"date":"2023-08-03T00:00:46","date_gmt":"2023-08-03T00:00:46","guid":{"rendered":"\/forum\/forums\/topic\/extract-joint-probes-with-scripting-api\/"},"modified":"2023-08-03T00:00:46","modified_gmt":"2023-08-03T00:00:46","slug":"extract-joint-probes-with-scripting-api","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/extract-joint-probes-with-scripting-api\/","title":{"rendered":"Extract joint probes with scripting API"},"content":{"rendered":"<p>I have a model with some joints (bushings to ground). I have several analyses in this model, in each analysis I have some joint probes that are telling me the joint force.&nbsp; I want to print the joint forces to a text file using scripting.&nbsp; First I was trying to just print the joint forces to the shell.&nbsp; I found this example to base my code on: https:\/\/ansyshelp.ansys.com\/account\/secured?returnurl=\/Views\/Secured\/corp\/v221\/en\/act_script\/act_script_examples_evaluate_spring_reaction_forces.html&nbsp;<\/p>\n<p>EXAMPLE:&nbsp;<\/p>\n<pre class=\"programlisting\"># Get access to solver data\nanalysis = Model.Analyses[0]\nsolver_data = analysis.Solution.SolverData\n\n# Get access to result reader\nwith analysis.GetResultsData() as reader:\n    spring_results = reader.GetResult(\"SPRING\")\n    # Get a list of all springs\n    springs = Model.Connections.GetChildren(DataModelObjectCategory.Spring, False)\n\n    for spring in springs:\n        print(spring.Name)\n\n        spring_data = solver_data.GetObjectData(spring)\n        element_id = spring_data.ElementId\n\n        fForce = spring_results.GetElementValues(element_id)\n        print(fForce[0])<\/pre>\n<p>But it&#8217;s for springs.&nbsp; Trying to change it to work for bushing joints, I don&#8217;t know what to put here: reader.GetResult(&#8220;SPRING&#8221;)&nbsp; I tried &#8220;reader.GetResult(&#8220;JOINT&#8221;) but that does not compile.&nbsp; It does run if I keep it as &#8220;SPRING&#8221; but the results are nonsense.&nbsp; Please help! I could not find any documentation on the GetResult function.<\/p>\n<p>Here is my code so far:<\/p>\n<p># Get access to solver data<br \/>analysis = Model.Analyses[0]<br \/>solver_data = analysis.Solution.SolverData<br \/># Get access to result reader<br \/>with analysis.GetResultsData() as reader:<br \/>&nbsp; &nbsp; joint_results = reader.GetResult(&#8220;SPRING&#8221;)<br \/>&nbsp; &nbsp; # Get a list of all joints<br \/>&nbsp; &nbsp; joints = Model.Connections.GetChildren(DataModelObjectCategory.Joint, True)<br \/>&nbsp; &nbsp; for joint in joints:<br \/>&nbsp; &nbsp; &nbsp; &nbsp; print(joint.Name)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; joint_data = solver_data.GetObjectData(joint)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; element_id = joint_data.ElementId<br \/>&nbsp; &nbsp; &nbsp; &nbsp; print(element_id)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; fForce = joint_results.GetElementValues(element_id)<br \/>&nbsp; &nbsp; &nbsp; &nbsp; print(fForce[0])<\/p>\n<p>I am using 2022 R1<\/p>\n","protected":false},"template":"","class_list":["post-296218","topic","type-topic","status-closed","hentry","topic-tag-mechanicalworkbench-1","topic-tag-ansys-mechanical","topic-tag-python-scripting","topic-tag-scripting"],"aioseo_notices":[],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["290684","170445"],"_bbp_author_ip":["23.206.193.146"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_bbp_likes_count":["1"],"_btv_view_count":["2593"],"_bbp_topic_status":["unanswered"],"_bbp_status":["publish"],"_bbp_notification_enabled":["7476"],"_bbp_topic_id":["296218"],"_bbp_forum_id":["27791"],"_bbp_engagement":["170445","290684"],"_bbp_voice_count":["2"],"_bbp_reply_count":["1"],"_bbp_last_reply_id":["298054"],"_bbp_last_active_id":["298054"],"_bbp_last_active_time":["2023-08-03 18:27:19"]},"test":"cheyennehuagmail-com"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/296218","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\/296218\/revisions"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=296218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}