Jump to content
We've recently updated our Privacy Statement, available here. ×

Can someone help explain what does vis.As[VisualContent]() do

WeiWei Shu 2

Recommended Posts

I see a lot of code snippets have this "vis.As[VisualContent]()" statement. I got a feeling that this is to cast vis back to its parent class, i.e., VisualContent, is that right But why do you need cast it back Also is "As" an IronPython function/keywords or a Spotfire-specific function

Thanks in advance.

Link to comment
Share on other sites

Its used so that the script parameter is given the correct attributes/methods to use in your code :


from Spotfire.Dxp.Application.Visuals import *


x = vis.As[HtmlTextArea]()




x= vis.As[VisualContent]()

print(x.Title)In the above example if you set to HtmlTextArea you can access items like HtmlContent in text area, where as if you use VisuualContent you wont be able to call .HtmlContent but you can get details of the visual such as Title.


Link to comment
Share on other sites

Thanks for the explaination.  I do have a follow-up question: how to understand its syntax  Is "As" a dictionary attribute of "vis"  And then setting the key to "HtmlTextArea" gets its value which is a class  The class is then initialized because it is followed by ()





Link to comment
Share on other sites

Is "As" a dictionary attribute of "vis"

With respect to the Visual Class, if you check the below documentation:


As is a method that belongs to this class and below is the description of the same:


Visual.As Method

Gets the visual as the specified type.

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...