How do I get the nearest node to (X,Y,Z) using mapdl.get?

James Derrick
James Derrick Administrator, Employee Posts: 283
Ancient Membership 100 Comments 100 Likes 25 Answers
admin
edited June 2023 in Structures

I have some 3D geometry I've constructed in pymapdl and I'm trying to get the nearest node to the coordinates (X, Y, Z). I understand in APDL you would use the N=NODE(X, Y, Z) command as a shortcut for the *GET command.

PyMAPDL does not have an equivalent for this (Yet), so I'm trying to write the explicit get command out using mapdl.get. The APDL command I have so far is as follows:

*GET,_,NODE,N,LOC,0, 0.6, -0.1

I'm just trying to store the data in a blank parameter, hence the _. I'm more interested in what's returned. However at the moment it's throwing an error:

ansys.mapdl.core.errors.MapdlRuntimeError: *** ERROR ***                           CP =       1.656   TIME= 11:02:53
 Unknown label in field 6 ( 0 ) of *GET command.                         
  Line= *GET,_,NODE,N,LOC,0,0.6,-0.1                                     
  The *GET command is ignored.

What am I doing wrong? according to the documentation, what I've done so far should work.

the documentation

EDIT:

using a non-underscore param name did not work either:

ansys.mapdl.core.errors.MapdlRuntimeError: *** ERROR ***                           CP =       1.500   TIME= 11:24:45
 Unknown label in field 6 ( 0 ) of *GET command.                         
  Line= *GET,N,NODE,N,LOC,0,0.6,-0.1                                     
  The *GET command is ignored.

EDIT 2:

This did not work either

ansys.mapdl.core.errors.MapdlRuntimeError: *** ERROR ***                           CP =       1.578   TIME= 12:00:27
 Unknown label in field 6 ( 0 ) of *GET command.                         
  Line= *GET,MYPARAM,NODE,N,LOC,0,0.6,-0.1                               
  The *GET command is ignored.
Tagged:

Answers

  • Rohith Patchigolla
    Rohith Patchigolla Member, Moderator, Employee Posts: 212
    100 Comments 25 Answers Second Anniversary 25 Likes
    ✭✭✭✭
    Answer ✓

    I believe it was because of the "underscore" used for the parameter name. Please try it with a name starting with an alphabet to do a sanity check.

    Here are some rules to define a valid parameter name in APDL, from ANSYS Help (*SET command).

    • An alphanumeric name used to identify this parameter. Par can contain up to 32 characters, beginning with a letter and containing only letters, numbers, and underscores. Examples: ABC A3X TOP_END

    • Command names, function names, label names, component and assembly names, etc., are invalid, as are parameter names beginning with an underscore (for example, _LOOP).

    Edit 1: There is no option via *GET to extract node ID based on x, y and z locations. Only option is test = Node(x,y,z). One can use the below command in PyMAPDL to get the parameter.

    mapdl.run('test = NODE(X,Y,Z)')