如何使用IronPython脚本在Spotfire库中创建文件夹

如何使用IronPython脚本在Spotfire库中创建文件夹,ironpython,spotfire,Ironpython,Spotfire,我想在Spotfire库中创建一个文件夹,并使用IronPython脚本保存分析文件。但是我不知道如何在Library Manager的“创建文件夹”功能中传递LibraryItem。您需要使用LibraryManager.TryGetItem方法选择父文件夹,然后将其和新文件夹名称传递给LibraryManager.CreateFolder方法 这对我很有用:- # Import namespaces from Spotfire.Dxp.Framework.Library import *

我想在Spotfire库中创建一个文件夹,并使用IronPython脚本保存分析文件。但是我不知道如何在Library Manager的“创建文件夹”功能中传递LibraryItem。

您需要使用LibraryManager.TryGetItem方法选择父文件夹,然后将其和新文件夹名称传递给LibraryManager.CreateFolder方法

这对我很有用:-

# Import namespaces
from Spotfire.Dxp.Framework.Library import *

libraryManager = Document.GetService(LibraryManager)
parentFolder = '/path/parentFolder/'
newSubFolder = 'newSub'

parentFolderExists, folder = libraryManager.TryGetItem(parentFolder, LibraryItemType.Folder)
if parentFolderExists:
    subfolderExists, subfolder = libraryManager.TryGetItem(customer + newSubFolder + '/', LibraryItemType.Folder)
    if not subfolderExists:
        print customer
        libraryManager.CreateFolder(folder, newSubFolder, LibraryItemMetadataSettings())