April 6, 2020 at 6:29 amsenior2020designSubscriber
Dear Ansys Student Community Helpers,
I am using the Ansys 2019 R1 scripting API's for capturing my model in Mechanical and saving it in the user_files of my project. But is there a way to access this folder with python scripting itself?
I have tried using the normal os.mkdir python coding but that only accesses the directory in which the Ansys software was installed in my operating system. Which is the C drive.
I have utilized the dataModel.WorkingDir to access my current directory in Ansys, but it seems that the Ansys API commands does not play well with the normal python mkdir coding.
Please let me know what I possibilities I have with my idea.
And please point me in the direction that may help me as well.
Thank you, DL
April 6, 2020 at 10:14 am
April 13, 2020 at 3:28 amsenior2020designSubscriber
I am sorry I believe my title is misleading. Thank you for your help but it seems this also leads me into the Mechanical directory.
by using both:
I am trying to access the User_files directory in the project name. because I want to automatically create a folder in that directory.
The before methods get me into the Project_filesdp0globalMECH
April 14, 2020 at 1:03 amAniketAnsys Employee
You should be able to use GetUserFilesDirectory() which works at the workbench level. You should be able to call that function from Mechanical by importing wbjn as explained in the above help link.
April 16, 2020 at 9:59 amsenior2020designSubscriber
I am currently trying different solutions with your insight.
Once I am able to access the working directory I am going to save images from Mechanical. I am using the Graphics.ModelViewManager.CaptureModelView(int index, "PNG") to capture and save my geometry into the working directory. The problem I am running into is that the API automatically saves it as the name created to the view inside Mechanical's Model View Window.
Is there any way to append to the name saved from using the CaptureModelView.
For example, the view name is "Open View" and when I use the Graphics.ModelViewManager.CaptureModelView(int index, "PNG") I get the file named
Open View.PNG in my directory. It there a way to append onto this filename while still using the CaptureModelView()?
April 20, 2020 at 2:58 pmAniketAnsys Employee
senior2020design, Is there any specific reason to use "Graphics.ModelViewManager.CaptureModelView" ? Can you use "Graphics.ExportImage" instead?
April 20, 2020 at 6:23 pmsenior2020designSubscriber
The issue I am running into with using API Methods that takes in a string filepath such as "Graphics.ExportImage(filePath)" is that the user can save their created Project anywhere on the hard drive. So I do not want to specify a specific filepath to save images because that would confuse users that have saved their Project into a different directory in their hard drive. The "Graphics.ModelViewManager.CaptureModelView" some how finds where the Project was saved and saves the image files into the user_files directory in the Project folder.
I have Version 2019 R1 and I could not seem to identify the existence of the GetUserFilesDirectory() in the reference guide.
Thank you for all the help, please let me know what other options are possible.
April 21, 2020 at 9:14 amAniketAnsys Employee
but you can always get the filepath string using GetUserFilesDirectory() from the workbench page right? Did you check the link that I gave?
GetUserFilesDirectory() is a workbench level command so you will be able to execute it from ACT console on Workbench page (not from ACT console in Mechanical).
The link I gave shows how to run workbench level commands from Mechanical. And "filepath" is literally a string, there should not be any issue to manipulate it and force it to the output of command GetUserFilesDirectory() using basic python commands.
- You must be logged in to reply to this topic.
Simulation World 2022
Check out more than 70 different sessions now available on demand. Get inspired as you hear from visionary companies, leading researchers and educators from around the globe on a variety of topics from life-saving improvements in healthcare, to bold new realities of space travel. Take a leap of certainty and check out a session today here.
Earth Rescue – An Ansys Online Series
The climate crisis is here. But so is the human ingenuity to fight it. Earth Rescue reveals what visionary companies are doing today to engineer radical new ideas in the fight against climate change. Click here to watch the first episode.
Subscribe to the Ansys Blog to get great new content about the power of simulation delivered right to your email on a weekly basis. With content from Ansys experts, partners and customers you will learn about product development advances, thought leadership and trends and tips to better use Ansys tools. Sign up here.
- How to calculate the residual stress on a coating by Vickers indentation?
- An Unknown error occurred during solution. Check the Solver Output…..
- Saving & sharing of Working project files in .wbpz format
- Solver Pivot Warning in Beam Element Model
- Understanding Force Convergence Solution Output
- Colors and Mesh Display
- whether have the difference between using contact and target bodies
- The solver engine was unable to converge on a solution for the nonlinear problem as constrained.
- What is the difference between bonded contact region and fixed joint
- Massive amount of memory (RAM) required for solve
© 2022 Copyright ANSYS, Inc. All rights reserved.