Jump to content

"AttributeError: 'NoneType' object has no attribute 'As'"


Sarra Belkadhi

Recommended Posts

Hello,

I want abookmarkto be displayed in text area automatically each time I save one, I used this code:

# Copyright 2017. TIBCO Software Inc. Licensed under TIBCO BSD-style license.

 

import clr

clr.AddReference("System.Windows.Forms")

from System.Windows.Forms import MessageBox

from System.Text import *

from Spotfire.Dxp.Application.AnalyticItems import BookmarkManager

import Spotfire.Dxp.Application.Filters as filters

from Spotfire.Dxp.Application.Visuals import HtmlTextArea

 

textArea= None

builder=StringBuilder()

htmlContent=None

 

#Get Bookmark Manager

bookmarkManager = Application.GetService(BookmarkManager)

 

#Loop through bookmarks and apply each bookmark

for bookmark in bookmarkManager.GetBookmarks():

bookmarkManager.Apply(bookmark,0)

MessageBox.Show("Applied bookmark: "+bookmark.Name)

myPanel= Document.ActivePageReference.FilterPanel

for tables in Document.Data.Tables:

filterCollection= myPanel.FilteringSchemeReference.Item[tables]

builder.AppendLine("Filters for applied for Bookmark"+bookmark.Name+"n")

builder.AppendLine("Filters in "+tables.Name)

for filters in filterCollection:

builder.AppendLine(str(filters.Context))

builder.AppendLine("n")

 

#Add the Filter settings to Text Area with title Filters in Different Bookmarks

for vis in Document.ActivePageReference.Visuals:

if vis.Title=="Filters in Different BookMarks":

textArea=vis

htmlContent=vis.As[HtmlTextArea]().HtmlContent

textArea.As[HtmlTextArea]().HtmlContent=builder.ToString()But I get the error:

"AttributeError: 'NoneType' object has no attribute 'As'"

is there a way to get around this error

Thank you in advance,

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...