WeiWei Shu 2 Posted March 5, 2020 Share Posted March 5, 2020 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 More sharing options...
Tyger Guzman 2 Posted March 5, 2020 Share Posted March 5, 2020 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]() print(x.HtmlContent) 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. https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-analyst_api/html/T_Spotfire_Dxp_Application_Visuals_VisualTypeIdentifiers.htm_ga=2.176910373.129358251.1583167442-1235101339.1574092729&_gac=1.149692802.1579798659.EAIaIQobChMI2dKKypia5wIVlpOzCh0HzAbeEAAYASAAEgIz8_D_BwE Link to comment Share on other sites More sharing options...
WeiWei Shu 2 Posted March 6, 2020 Author Share Posted March 6, 2020 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 More sharing options...
Rayees Wani Posted March 6, 2020 Share Posted March 6, 2020 Is "As" a dictionary attribute of "vis" With respect to the Visual Class, if you check the below documentation: https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-a... As is a method that belongs to this class and below is the description of the same: https://docs.tibco.com/pub/doc_remote/sfire_dev/area/doc/api/TIB_sfire-a... Visual.As Method Gets the visual as the specified type. Link to comment Share on other sites More sharing options...
WeiWei Shu 2 Posted March 6, 2020 Author Share Posted March 6, 2020 Hi Rayees, Thank you very much for answering my questions. It's very helpful and I'm "clear as mud" now! Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now