简体   繁体   中英

Spotfire IronPython Loop through properties

How can I return the full list of document properties in a Spotfire file, using Ironpython.

Properties can be set by

Document.Properties["myProperty"] = "myValue"

I would like to do something like

for myProperty in Document.Properties:
     print myProperty
     #Some checks like if myProperty.Name = 'name1' then ...

Found this, but can't get it to work yet (it returns more then just the properties: http://www.cambridgesoft.com/support/EnterpriseSupport/KnowledgeBase/FAQ/details/Default.aspx?TechNote=2344

from Spotfire.Dxp.Data import *

for DocProp in Document.Data.Properties.GetProperties(DataPropertyClass.Document):
    print DocProp.Name, DocProp.Value

there is a property of the DocumentProperty object called isUserVisible that can help you here.

technically all the things that appear in your list are Document Properties (as in, they are "properties of the document"), and they are accessible via Edit»Document Properties . to get the DocumentProperties you are expecting (as in, "variables created in this document") you can run something like the following:

from Spotfire.Dxp.Data import DataPropertyClass

for d in Document.Data.Properties.GetProperties(DataPropertyClass.Document):
    if d.IsUserVisible: print d.Name, d.Value

you only need DataPropertyClass for the enumeration; the same effect can be achieved with no imports:

for d in Document.Data.Properties.GetProperties(0):
    if d.IsUserVisible: print d.Name, d.Value

(note that you will stil get the MaxMissingTimeParts and FiscalYearOffset properties that are created with each document by default.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM