You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mapdl.kdist - calculates and lists ([X, Y, Z] coordinates) the distance between two keypoints using →
def parse_kdist(msg):
"""Parse the keypoint value from a keypoint message"""
finds = re.findall(NUM_PATTERN, msg)[-3:]
if len(finds) == 3:
return [float(val) for val in finds]
calculates and lists ([X, Y, Z] coordinates) the distance between two keypoints.
It is really and really helpful and useful.
But if you try to obtain the distances between the nodes using mapdl.ndist, you will obtain string output!
To Reproduce
To see the string output with mapdl.ndist run the code below:
###############################################################################
# Import and start MAPDL
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()
mapdl.finish()
mapdl.run("/CLEAR,all")
mapdl.prep7()
###############################################################################
# Simple class with coordinate attributes and the method to create nodes
# and get the distance between them.
class Create:
def __init__(self, x1, y1, z1, x2, y2, z2):
# Attributes
print("Define Distance")
self.x1 = x1
self.y1 = y1
self.z1 = z1
self.x2 = x2
self.y2 = y2
self.z2 = z2
def create_node_method(self):
node1 = mapdl.n(x=self.x1, y=self.y1, z=self.z1)
node2 = mapdl.n(x=self.x2, y=self.y2, z=self.z2)
dist_xyz_n = mapdl.ndist(node1, node2)
return dist_xyz_n
node = Create(1, 2, 3, 10, 20, 30)
node_dist = node.create_node_method()
print(node_dist)
print(f"The Data Type is: {type(node_dist)}")
###############################################################################
Expected results form mapdl.ndist
HOW IT WORKS FOR mapdl.kdist
###############################################################################
# Import and start MAPDL.
import math
from ansys.mapdl.core import launch_mapdl
mapdl = launch_mapdl()
mapdl.finish()
mapdl.run("/CLEAR,all")
mapdl.prep7()
# Simple class with coordinate attributes and the method to create keypoints and get the distance between them.
class Create:
def __init__(self, x1, y1, z1, x2, y2, z2):
# Attributes
print("Define Distance")
self.x1 = x1
self.y1 = y1
self.z1 = z1
self.x2 = x2
self.y2 = y2
self.z2 = z2
def create_kp_method(self):
kp1 = mapdl.k(x=self.x1, y=self.y1, z=self.z1)
kp2 = mapdl.k(x=self.x2, y=self.y2, z=self.z2)
list_dist_output = mapdl.kdist(kp1, kp2)
print(f"The LIST of X, Y, Z coordinate distances between keypoints: {list_dist_output}")
kp_x, kp_y, kp_z = list_dist_output
dist_kp = math.sqrt(kp_x ** 2 + kp_y ** 2 + kp_z ** 2)
mapdl.kplot(show_keypoint_numbering=True,
background="black",
show_bounds=True,
font_size=26)
return dist_kp
kp = Create(1, 2, 3, 10, 20, 30)
kp_dist = kp.create_kp_method()
print(f"Distance between keypoints is: {kp_dist}")
###############################################################################
**Expected results from mapdl.kdist ** Screenshots
SUGGESTIONS
We can add one more parsing script for mapdl.ndist as it was done for mapdl.kdist:
Describe the bug
During the simulation of VM8 #820 with pymapdl I have figured out that:
https://github.com/pyansys/pymapdl/blob/d8c70c26c7dd973ca12611ba76aed56dbe052650/ansys/mapdl/core/_commands/preproc/keypoints.py#L198
mapdl.kdist
- calculates and lists ([X, Y, Z] coordinates) the distance between two keypoints using →calculates and lists ([X, Y, Z] coordinates) the distance between two keypoints.
It is really and really helpful and useful.
But if you try to obtain the distances between the nodes using
mapdl.ndist
, you will obtain string output!To Reproduce
To see the string output with
mapdl.ndist
run the code below:Expected results form
mapdl.ndist
HOW IT WORKS FOR
mapdl.kdist
**Expected results from
mapdl.kdist
**Screenshots
SUGGESTIONS
We can add one more parsing script for
mapdl.ndist
as it was done formapdl.kdist
:locatin of the
mapdl.kdist
:https://github.com/pyansys/pymapdl/blob/d8c70c26c7dd973ca12611ba76aed56dbe052650/ansys/mapdl/core/_commands/preproc/keypoints.py#L198
Location of the parsing script for
mapdl.kdist
:https://github.com/pyansys/pymapdl/blob/d8c70c26c7dd973ca12611ba76aed56dbe052650/ansys/mapdl/core/_commands/parse.py#L21
System Information:
The text was updated successfully, but these errors were encountered: