RoboDK Forum
没有美联社propriate Methods or ITEM_TYPE_* Variable for Folders可打印版本

+- RoboDK Forum (//www.sinclairbody.com/forum)
+-- Forum: RoboDK (EN) (//www.sinclairbody.com/forum/Forum-RoboDK-EN)
+--- Forum: RoboDK API (//www.sinclairbody.com/forum/Forum-RoboDK-API)
+--- Thread: No Appropriate Methods or ITEM_TYPE_* Variable for Folders (/Thread-No-Appropriate-Methods-or-ITEM-TYPE-Variable-for-Folders)



没有美联社propriate Methods or ITEM_TYPE_* Variable for Folders-Michaelw46-07-01-2019

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.


RE: No Appropriate Methods or ITEM_TYPE_* Variable for Folders-Albert-07-01-2019

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.


RE: No Appropriate Methods or ITEM_TYPE_* Variable for Folders-Michaelw46-07-24-2019

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?


RE: No Appropriate Methods or ITEM_TYPE_* Variable for Folders-Albert-07-26-2019

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")