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

No Appropriate Methods or ITEM_TYPE_* Variable for Folders

#1
In the RoboDK UI application, right clicking on the open station brings up a context menu which gives the user the 'Add Folder' option, which does not seem to be possible using the Python API. After checking the robolink Item() class, I found that folders are valid Item objects and calling Type() on them returns 17, but there is no ITEM_TYPE_* variable assigned to that value as there are for other types of Items. Also, there are no methods to allow the user to add or manipulate folder Items.


 I was able to work around this and create new folders by using Copy(), Paste(), and setName() on an existing folder and then using setParent() to add Items to the new folder, but that only works if the user has already added an empty folder using the UI. Is there any way to add and manipulate folder Items directly that I might be missing? If not, that would be a good feature to implement in the future as folders are extremely useful for organizing things like targets and programs, which tend to clutter up the station tree.
#2
There is no dedicated call in the API to add a folder. However, you can do the following to add a folder:

Code:
RDK.Command("AddFolder", "Folder Name")
folder = RDK.Item("Folder Name")

I assume you just want to reorganize your station tree so you'll have to use folder.setParent to do so.
#3
The 'AddFolder()' method does not seem to exist. When I try running your code I get the following error:


Quote:AttributeError: 'Robolink' object has no attribute 'AddFolder'


Is there any other way to add a folder without copying, pasting, and renaming one that already exists?
#4
I'm sorry, I made a mistake with the small example I provided. I meant to say:

Code:
RDK.Command("AddFolder", "Folder Name")
folder = RDK.Item("Folder Name")
  




Users browsing this thread:
1 Guest(s)