/
SaveView.py
51 lines (38 loc) · 1.3 KB
/
SaveView.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# --------------------------------------------
# --------------- DESCRIPTION ----------------
#
# Save the 3D view point as a station parameter.
#
# More information about the RoboDK API for Python here:
# https://robodk.com/doc/en/RoboDK-API.html
# https://robodk.com/doc/en/PythonAPI/index.html
#
# More information on RoboDK Apps here:
# https://github.com/RoboDK/Plug-In-Interface/tree/master/PluginAppLoader
#
# --------------------------------------------
from robodk import robolink, robomath, roboapps
def SaveView(view_name):
"""
Save the 3D view point as a station parameter.
"""
# Start the RoboDK API
RDK = robolink.Robolink()
# Get the 3D view pose
vp = RDK.ViewPose()
# Convert to a string as XYZABC
vp_str = str(robomath.Pose_2_KUKA(vp))
# Save it as a station parameter (saved with the RDK file)
RDK.setParam(view_name, vp_str)
RDK.ShowMessage("Current view point saved: " + vp_str, False)
def runmain():
"""
Entrypoint of this action when it is executed on its own or interacted with in RoboDK.
Important: Use the function name 'runmain()' if you want to compile this action.
"""
if roboapps.Unchecked():
roboapps.Exit()
else:
SaveView("ViewManager-View-0")
if __name__ == '__main__':
runmain()