RoboDK Forum
Import Models from Rhino——革命制度党ntable Version

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+ - - -论坛:通用RoboDK问题(//www.sinclairbody.com/forum/Forum-General-questions-about-RoboDK)
+--- Thread: Import Models from Rhino (/Thread-Import-Models-from-Rhino)



Import Models from Rhino-srdr-09-21-2021

Hi!

I am trying to import a large number of brick models from Rhino 3D into the RoboDK work station. I need each brick to have a unique name in RoboDK so that I can identify them for the attach/detach simulation events. Is it possible by using the RoboDK plugin for Rhino?

Or can you suggest other solutions?

Thank you!


RE: Import Models from Rhino-Albert-09-21-2021

You should be able to rename items automatically using the API. For example, after you load one or more 3D models you can trigger a script that will take the last loaded 3D model and change the name iteratively.

The script could be something like this:

Code:
# Start the RoboDK API
from robolink import *
RDK = Robolink()

# Retrieve all objects (3D models)
allparts = RDK.ItemList(ITEM_TYPE_OBJECT)

# Get the part with the non unique name
part = RDK.Item("Rhino Part", ITEM_TYPE_OBJECT)

# Keep a part ID for each object
part_id = len(allparts)

# Iterate while we find a valid part with a neutral name
while part.Valid():
part_id = part_id + 1

# Set the name of the object
part.setName("Part " + str(part_id))

# Get the new part
part = RDK.Item("Rhino Part", ITEM_TYPE_OBJECT)