Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Target orientation determination from surface

#1
Hi,

I would like to correct the target orientation on the CAD object's surface using its normal. (by adopting the orientation of the closest CAD point) 

I want to achieve something similar to the "Teach on surface" function's orientation determination. 

I have tried with *.stp and *.stl files. As a sample, I used the examples available in the API documentation. (attachment)

The error: I cannot read the points from the object, invalid curve id.

Can you help me please, how can I fix it?
Thanks!


Attached Files
.rdk   getcadori.rdk (Size: 1.18 MB / Downloads: 129)
#2
I recommend you to use the second example you can find with GetPoints:
https://robodk.com/doc/en/PythonAPI/robo....GetPoints

You'll find an infinite loop that looks for the hover/selection status on an object and allows you to retrieve the point under the mouse cursor and the normal. This is the example:
Code:
from robolink import *    # Import the RoboDK API
import time
RDK = Robolink()          # Start RoboDK API

while True:
   # Check if we have an object under the mouse cursor
   object, feature_type, feature_id, feature_name, points = RDK.GetPoints(FEATURE_HOVER_OBJECT)
   if object.Valid() and (object.type == ITEM_TYPE_OBJECT or object.type == ITEM_TYPE_TOOL):

       # Retrieve the selected feature on the object
       is_selected, feature_type, feature_id = object.SelectedFeature()

       if is_selected and feature_type == FEATURE_SURFACE:
           # Retrieve the mesh related to the surface ID
           point_mesh, name_feature = object.GetPoints(FEATURE_OBJECT_MESH, feature_id)
           print("Selected %i (%i):  %s" % (feature_id, feature_type, name_feature))
           print("Mesh points:")
           for xyzijk in point_mesh:
               print(xyzijk)

           # Clear selection or manipulate as necessary
           RDK.setSelection([])

       else:
           print("Click the surface to see the mesh")
           time.sleep(0.1)
           continue

   else:
       print("Object Not Selected. The surface of an object or a tool")

   time.sleep(0.1)
#3
Thanks Albert!

It's done:)
#4
Perfect! Thank you for your feedback.
  




Users browsing this thread:
1 Guest(s)