Tagged: ansys-mechanical, apdl, named-selections, scripting-journaling
-
-
February 17, 2022 at 12:50 pm
fruswrit
SubscriberHi,
I want APDL to read my Named Selection... well, "names" created in Mechanical, and I have been unable to find a way to do it natively. I have been able to do it via Mechanical script (as follows, for those interested):
named_selection_all=DataModel.GetObjectsByType(Ansys.ACT.Automation.Mechanical.NamedSelection)
for ns in named_selection_all:
print(ns.Name)
I have been able even to access the ARGS from the script with this kind of command:
command_snippet_1.InputArgument1 = r'35'
However, it seems it is not possible to get it to accept a string. Or at least I have not been successful. The reason I want my APDL script to read those string is because I want it to export a series of results for each named selection with the filename being the name of said named selection.
Any ideas? Thank you in advance!
February 17, 2022 at 1:08 pmErik Kostson
Ansys EmployeeHi
We can not put a text as an argument (ARG1 say).
One workaround is to print with ACT the named selection to a text file and then read that text file with apdl (see perhaps TREAD and *DIM command on how to read in a text file). Then you will have access to all the names in a table (*DIM).
Another way is to use just apdl commands to get the named selections since they are defined in the ds.dat as components (CM). These commands are relevant to get the total number of components and the name of the first and second one.
*GET,mycm, COMP, 0,NCOMP *GET, myfcm,COMP, 1,NAME
*GET, myscm,COMP, 2,NAME
All the best
Erik
February 17, 2022 at 1:14 pmfruswrit
SubscriberHi Thank you. I was trying to avoid it as it is kind of a pain, but it may be the only way.
CheersFebruary 17, 2022 at 1:36 pmErik Kostson
Ansys Employeeactually this is quite easy and can be automated via a *do loop - so you can write to arg1 how many named selections you have (via act as you showed above) and
then just do a loop in the command snippet to get all their names and to create .txt files with their names:
imax=ARG1
*DO, i, 1, imax, 1
*GET,myfcm%i%,COMP,i,NAME
*CFOPEN,myfcm%i% *CFCLOS
*ENDDO
February 17, 2022 at 1:57 pmfruswrit
SubscriberWow, that might be the best of both worlds!
I have tried it and it is working now (well, more or less, I think ):
*DO LOOP ON PARAMETER= I FROM1.0000TO3.0000BY1.0000
*GETMYFCM1FROMCOMPITEM=NAMEVALUE= RESPUESTA
OPENED FILE= RESPUESTA FOR COMMAND FILE DATA
COMMAND FILE CLOSED
*ENDDOINDEX= I
"RESPUESTA" was the name of my named selection indeed.
I will have to check a little bit, as it does not appear to be looping beyond the first iteration. But certainly it works.
Thank you for your extremely fast and helpful answers! You deserve a raise!
February 17, 2022 at 1:59 pmErik Kostson
Ansys EmployeeYes it is quite OK I think - I tried it on my end and it generated all the files based on the number of named selections and their names, so seems to be working (in the solve.out it will not write out all the iterations in the loop).
All the best
Erik
Viewing 5 reply threads- You must be logged in to reply to this topic.
Ansys Innovation SpaceBoost Ansys Fluent Simulations with AWS
Computational Fluid Dynamics (CFD) helps engineers design products in which the flow of fluid components is a significant challenge. These different use cases often require large complex models to solve on a traditional workstation. Click here to join this event to learn how to leverage Ansys Fluids on the cloud, thanks to Ansys Gateway powered by AWS.
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.
Ansys Blog
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.
Trending discussions- Saving & sharing of Working project files in .wbpz format
- Solver Pivot Warning in Beam Element Model
- Understanding Force Convergence Solution Output
- An Unknown error occurred during solution. Check the Solver Output…..
- What is the difference between bonded contact region and fixed joint
- 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.
- Colors and Mesh Display
- User manual
- material damping and modal analysis
Top Contributors-
3694
-
2564
-
1765
-
1234
-
590
Top Rated Tags© 2023 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.
-