TAGGED: ansys-mechanical, apdl, named-selections, scripting-journaling
-
-
February 17, 2022 at 12:50 pmfruswritSubscriber
Hi,
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 KostsonAnsys 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 pmfruswritSubscriberHi 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 KostsonAnsys 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 pmfruswritSubscriberWow, 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 KostsonAnsys 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- The topic ‘Getting type string data from Mechanical script to APDL Command Snippets (via ARGs or otherwise)’ 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 apply Compression-only Support?
- How to select the interface delamination surface of a laminate?
- 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-
1241
-
543
-
523
-
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.
-