


{"id":351172,"date":"2024-02-13T08:35:01","date_gmt":"2024-02-13T08:35:01","guid":{"rendered":"\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/"},"modified":"2024-02-20T09:01:41","modified_gmt":"2024-02-20T09:01:41","slug":"mechanical-stl-export-with-python-in-workbench","status":"closed","type":"topic","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/","title":{"rendered":"Mechanical stl export with Python in Workbench"},"content":{"rendered":"<p>Hello,<\/p>\n<p data-sourcepos=\"9:3-9:102\">I&#8217;m trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).<\/p>\n<p data-sourcepos=\"11:3-11:256\">I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in the Mechanical scripting window in the Mechanical UI. Interestingly, I can export pictures and text files using the same script.<\/p>\n<p data-sourcepos=\"13:3-13:55\">I&#8217;m unsure what&#8217;s causing the issue. Can you help me?<\/p>\n<p><em><span style=\"font-size: 12pt\">commands=&#8221;&#8221;&#8221;<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">STATIC_STRUCTURAL=Model.Analyses[0]<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">SOLUTION=STATIC_STRUCTURAL.Solution<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">setting2d= Ansys.Mechanical.Graphics.GraphicsImageExportSettings()<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">setting3d = Ansys.Mechanical.Graphics.Graphics3DExportSettings() #######1st option<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">TOTAL_DEFORMATION_RESULT=SOLUTION.AddTotalDeformation()<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">CAMERA=Graphics.Camera<\/span><\/em><\/p>\n<p><em><span style=\"font-size: 12pt\">SOLUTION.ClearGeneratedData()<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">SOLUTION.Solve()<\/span><\/em><\/p>\n<p><em><span style=\"font-size: 12pt\">TOTAL_DEFORMATION_RESULT.Activate()<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">CAMERA.SetFit()<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">FOLDER_PATH = &#8216;C:\\Users\\dbehrens\\Desktop&#8217;<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">Graphics.ExportImage(FOLDER_PATH+&#8217;\\\\DEF7.png&#8217;, GraphicsImageExportFormat.PNG, setting2d)<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">TOTAL_DEFORMATION_RESULT.ExportToTextFile(FOLDER_PATH+&#8217;\\\\Txt1.txt&#8217;)<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">Graphics.Export3D(FOLDER_PATH+&#8217;\\\\test.stl&#8217;, Graphics3DExportFormat.BinarySTL, setting3d)&nbsp;#######1st option<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">result = SOLUTION.Children[1] #######2nd option<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">result.ExportToSTLFile(&#8220;C:\\Users\\dbehrens\\Desktop\\test1.stl&#8221;) #######2nd option<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">&#8220;&#8221;&#8221;<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">model3 = system2.GetContainer(&#8220;Results&#8221;)&nbsp;<\/span><\/em><br \/><em><span style=\"font-size: 12pt\">model3.SendCommand(Language=&#8221;Python&#8221;, Command=commands)<\/span><\/em><\/p>\n","protected":false},"template":"","class_list":["post-351172","topic","type-topic","status-closed","hentry"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 4.9.10 - aioseo.com -->\n\t<meta name=\"description\" content=\"Hello,I&#039;m trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 4.9.10\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Ansys Learning Forum | Ansys Innovation Space\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Mechanical stl export with Python in Workbench | Ansys Learning Forum\" \/>\n\t\t<meta property=\"og:description\" content=\"Hello,I&#039;m trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2024-02-13T08:35:01+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2024-02-20T09:01:41+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Mechanical stl export with Python in Workbench | Ansys Learning Forum\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Hello,I&#039;m trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/mechanical-stl-export-with-python-in-workbench\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"position\":2,\"name\":\"Topics\",\"item\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/mechanical-stl-export-with-python-in-workbench\\\/#listItem\",\"name\":\"Mechanical stl export with Python in Workbench\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/mechanical-stl-export-with-python-in-workbench\\\/#listItem\",\"position\":3,\"name\":\"Mechanical stl export with Python in Workbench\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/topics\\\/#listItem\",\"name\":\"Topics\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/mechanical-stl-export-with-python-in-workbench\\\/#webpage\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/mechanical-stl-export-with-python-in-workbench\\\/\",\"name\":\"Mechanical stl export with Python in Workbench | Ansys Learning Forum\",\"description\":\"Hello,I'm trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/forums\\\/topic\\\/mechanical-stl-export-with-python-in-workbench\\\/#breadcrumblist\"},\"datePublished\":\"2024-02-13T08:35:01+00:00\",\"dateModified\":\"2024-02-20T09:01:41+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#website\",\"url\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/\",\"name\":\"Ansys Learning Forum\",\"description\":\"Ansys Innovation Space\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/innovationspace.ansys.com\\\/forum\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Mechanical stl export with Python in Workbench | Ansys Learning Forum","description":"Hello,I'm trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in","canonical_url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","position":1,"name":"Home","item":"https:\/\/innovationspace.ansys.com\/forum","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","position":2,"name":"Topics","item":"https:\/\/innovationspace.ansys.com\/forum\/topics\/","nextItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/#listItem","name":"Mechanical stl export with Python in Workbench"},"previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/#listItem","position":3,"name":"Mechanical stl export with Python in Workbench","previousItem":{"@type":"ListItem","@id":"https:\/\/innovationspace.ansys.com\/forum\/topics\/#listItem","name":"Topics"}}]},{"@type":"Organization","@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization","name":"Ansys Learning Forum","description":"Ansys Innovation Space","url":"https:\/\/innovationspace.ansys.com\/forum\/"},{"@type":"WebPage","@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/#webpage","url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/","name":"Mechanical stl export with Python in Workbench | Ansys Learning Forum","description":"Hello,I'm trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#website"},"breadcrumb":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/#breadcrumblist"},"datePublished":"2024-02-13T08:35:01+00:00","dateModified":"2024-02-20T09:01:41+00:00"},{"@type":"WebSite","@id":"https:\/\/innovationspace.ansys.com\/forum\/#website","url":"https:\/\/innovationspace.ansys.com\/forum\/","name":"Ansys Learning Forum","description":"Ansys Innovation Space","inLanguage":"en-US","publisher":{"@id":"https:\/\/innovationspace.ansys.com\/forum\/#organization"}}]},"og:locale":"en_US","og:site_name":"Ansys Learning Forum | Ansys Innovation Space","og:type":"article","og:title":"Mechanical stl export with Python in Workbench | Ansys Learning Forum","og:description":"Hello,I'm trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in","og:url":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/","article:published_time":"2024-02-13T08:35:01+00:00","article:modified_time":"2024-02-20T09:01:41+00:00","twitter:card":"summary_large_image","twitter:title":"Mechanical stl export with Python in Workbench | Ansys Learning Forum","twitter:description":"Hello,I'm trying to export an STL result from Ansys Mechanical using a Python script I run from Workbench (I have left out the part where I set up the model.).I found two options in the Ansys online help to export an STL, but neither works within my script. Both options function when executed directly in"},"aioseo_meta_data":{"post_id":"351172","title":null,"description":null,"keywords":null,"keyphrases":null,"primary_term":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"content","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":true,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"local_seo":null,"limit_modified_date":false,"created":"2024-10-28 17:00:04","updated":"2024-10-28 17:00:04","ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/innovationspace.ansys.com\/forum\/topics\/\" title=\"Topics\">Topics<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tMechanical stl export with Python in Workbench\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/innovationspace.ansys.com\/forum"},{"label":"Topics","link":"https:\/\/innovationspace.ansys.com\/forum\/topics\/"},{"label":"Mechanical stl export with Python in Workbench","link":"https:\/\/innovationspace.ansys.com\/forum\/forums\/topic\/mechanical-stl-export-with-python-in-workbench\/"}],"acf":[],"custom_fields":[{"0":{"_bbp_subscription":["28765","170445"],"_bbp_author_ip":["23.206.193.41"]," _bbp_last_reply_id":["0"]," _bbp_likes_count":["0"],"_btv_view_count":["1417"],"_bbp_topic_status":["answered"],"_edit_lock":["1707813398:223883"],"_bbp_topic_id":["351172"],"_bbp_forum_id":["27791"],"_bbp_engagement":["28765","170445"],"_bbp_voice_count":["2"],"_bbp_reply_count":["5"],"_bbp_last_reply_id":["351865"],"_bbp_last_active_id":["351865"],"_bbp_last_active_time":["2024-02-16 10:08:26"]},"test":"dbehrensmarum-de"}],"_links":{"self":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/351172","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":1,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/351172\/revisions"}],"predecessor-version":[{"id":351173,"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/topics\/351172\/revisions\/351173"}],"wp:attachment":[{"href":"https:\/\/innovationspace.ansys.com\/forum\/wp-json\/wp\/v2\/media?parent=351172"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}