-
-
January 19, 2021 at 9:29 amJosiSandovalSubscriber
Hi,
I'm working on a parametric study where I need to run many simulations of the same geometry but different dimensions. The steps I follow to generate the simulation files are the following:
1.Open Ansys WB
2.Import SolidWorks geometry into the project schematic
3.Open SpaceClaim and run script to generate name selections.
4. Open Mechanical and : click in "Generate mesh" and click in "Write iinput files". This last step will generate and input file that I need for running the simulation on a server.
Step 1 to 3 I have already automated in the journal script (.wbjn file) which is attached on this post. I execute the journal script with the following command line :
C:Program FilesANSYS Incv201FrameworkinWin64>RunWB2.exe -R "C:UsersJSScriptsRunScript.wbjn" -I
Currently the step 4 which is open mechanical and generate mesh and input file are done manually. My goal is to write a script for these two tasks. I have used recording macro in mechanical scripting to generate the script which gives me the following lines for generating the mesh:
#region Set current scoping selection
currentSelection = ExtAPI.SelectionManager.CreateSelectionInfo(Ansys.ACT.Interfaces.Common.SelectionTypeEnum.GeometryEntities)
currentSelection.Ids = []
ExtAPI.SelectionManager.NewSelection(currentSelection)
#endregion
But when I try to use this script in other simulation it doesn't work. Also the recording macro doesn't work when I click on "Write input file".
I haven't been able to find some guidance to accomplish this on ACT customization suite. Do you have any advise on how to generate a mechanical script that can generate mesh and write input file?
Thanks!
January 19, 2021 at 12:57 pmAniketForum ModeratorAnsys staff can not download any files on the learning forum, so if you want to reach a larger audience to get answers from, please insert the images inline.nAlso, thanks for taking efforts to use the journaling feature for your needs, You should be able to script these two options in the Mechanical using ACT automation APIs, but if you connect the systems as follows to your systems in Workbench, (As you are already aware these are recorded in the journal file).nYou can generate the B4 cell when the APDL system is connected, and it should write the APDL input file (sys-1.dat) for the mesh in your model. n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning ForumnJanuary 19, 2021 at 1:10 pmJosiSandovalSubscriberHi Aniket,nthanks for your answer. This is the journal file that I previously attached:n#SpaceClaim script (py file) contains the script to create name selectionsnmyScriptGeometry =r'C:\Users\JS\Scripts\NameSelection.py'nn#Direction of WB file, which contains the project schematicnOpen(FilePath=SimulationFiles/simulation.wbpj)nExtensions.UnloadExtension( Id=2dd1520d-ded5-4cd7-936f-aebc0ce01f18, Version=2.3, Format=Binary)nn#Import the geometry from SW into the Project Schematic geometry containernsystem1 = GetSystem(Name=SYS)ngeometry1 = system1.GetContainer(ComponentName=Geometry)ngeometry1.SetFile(FilePath=Assembly.SLDASM)nn#Open the geometry on SpaceClaim and run the script to create name selections, then shuts down SpaceClaimngeometry1.Edit(IsSpaceClaimGeometry=True)ngeometry1.RunScript(ScriptFile = myScriptGeometry, GeometryContainer = Geometry, useAsMacro = false)ngeometry1.Exit()nn#Open Mechanical and refresh changes done in the geometrynsystem1 = GetSystem(Name=SYS)nmodelComponent1 = system1.GetComponent(Name=Model)nmodelComponent1.Refresh()nmodel1 = system1.GetContainer(ComponentName=Model)nn#Script for mechanical to do some meshing (script Missing)nScriptPath=C:/Users/JS/Scripts/mechanicalscript.pynwith open(ScriptPath, r) as Script:nSolveCommand=Script.read()nmodel1.SendCommand(Language='Python', Command = SolveCommand) #Pass your mechanical sript from workbench to mechanicalnmodel1.Exit()nnSave(Overwrite=True)nnSo my idea is to have a script(mechanicalscript.py) that when is executed, generates the mesh and the input file. You mentioned that I can do this in Mechanical using ACT automation APIs, do you have any examples that you could share or some tutorial. I will also try the way you showed it on your comment, adding a Mechanical APL and recording those actions. thanksnJanuary 19, 2021 at 3:16 pmAniketForum ModeratorYou may have seen this already, but here are some resources:nANSYS Store Developer Resources andnhttps://ansyshelp.ansys.com/account/Secured?returnurl=/Views/Secured/corp/v201/en/act_script/act_script.html nWhere you should be able to find the developer's guide, API guide as well as some templates.nOnce you have found the required APIs, and code works as you intended in Mechanical, send those commands from workbench page using methods mentioned in:nRun Mechanical Macro from Workbench ? Ansys Learning ForumnI hope that helps.n-AniketnHow to access Ansys help linksnGuidelines for Posting on Ansys Learning ForumnNovember 14, 2023 at 2:09 pmChandan MukherjeeSubscriberHey all,
I am currently working on a project that needs to mesh 100 of geometry made using spaceclaim, and the geometry names are in alphabetical order.
Now when I am trying to automate the meshing using python API, the only ths first geoemetry is getting meshed. The actual problem is that I could not export the meshed file.
Can you please help me write a python script to import the geometry then mesh it then export it to a folder.
Thanks in advance
Viewing 4 reply threads- The topic ‘How to develop a script to “Generate mesh” and “Write input file” in mechanical scripting?’ is closed to new replies.
Ansys Innovation SpaceTrending discussions- Problem with access to session files
- Ayuda con Error: “Unable to access the source: EngineeringData”
- At least one body has been found to have only 1 element in at least 2 directions
- Error when opening saved Workbench project
- Geometric stiffness matrix for solid elements
- How to select the interface delamination surface of a laminate?
- How to apply Compression-only Support?
- Timestep range set for animation export
- Image to file in Mechanical is bugged and does not show text
- SMART crack under fatigue conditions, different crack sizes can’t growth
Top Contributors-
1191
-
513
-
488
-
225
-
209
Top Rated Tags© 2024 Copyright ANSYS, Inc. All rights reserved.
Ansys does not support the usage of unauthorized Ansys software. Please visit www.ansys.com to obtain an official distribution.
-