MapInfo Pro

Expand all | Collapse all

Smart text in Layout Automation

  • 1.  Smart text in Layout Automation

    Posted 01-07-2020 18:21
    Hey Mapinfo Community

    I am new to Mapinfo and am hoping to automate the text details in a title of a layout. 

    My goal is to display the attribute information of column of a tab.

    A bit of background. The purpose is, we are seeking the row information in a column within a table. We are working on property boundaries with Lot and Plan information.

    So the process is; we select the single lot as a selection and create a layer from the selection. The good thing about this is it will return a single row of attributes in a table historically titled "Query1". We want to use a column within the table "Query1" named - Lot_Plan and grab the only attribute as the title of the figure by creating a smart text script to call the information of attribute in a table.

    The title we want with a smart text line is something like 234SP12345678   (an example of the information within the column Lot_plan)

    So far we have a script that reads  

    $mb{ColumnInfo(LayerInfo(LayoutItemWinID(CurContext(1), "Map-1", 1),1,1),"COL3",1)}

    --This script only returns the name of the column and not the attribute data in the row.

    If someone can offer assistance on the correct script.

    Further to this and more challenging would be how we could call the attribute data from multiple columns which would create an automated title such as "Lot 234 on plan  12345678 with a lot area of 245m(in this example the bold numbers are the attributes taken from a table.) 


    ------------------------------
    David Cini
    Knowledge Community Shared Account
    ------------------------------


  • 2.  RE: Smart text in Layout Automation

    Posted 01-07-2020 20:21
    Have a look in the MapInfo Marketplace and Community Downloads site at the SiteMapper tool. 

    The tool can help you batch print maps based on "sites" in your table (eg the property boundaries).  The tool has options to update the layout title with values from a field in your table.

    Regards

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne
    ------------------------------



  • 3.  RE: Smart text in Layout Automation

    Employee
    Posted 01-14-2020 03:20
      |   view attached
    Hi David

    Here's a small utility that can be used to read values from a specific record in a specific table.

    The tool has a function called MSFuncGetColumnValue which is registered as a public MapBasic function under the name ReadValue. This means that you can use this function from inside MapInfo Pro, for example in a SmartText.

    You will need MapInfo Pro 17.0.3 or newer to take advantage of this tool.

    Here's the declaration of the function:
    Declare Function MSFUNCGetColumnValue(   ByVal sTab As String
                                           , ByVal sCol As String
                                           , ByVal nRowID As Integer
                                           , ByVal bReturnError As Logical ) As String


    It takes these parameters:
    1. The table to read the value from
    2. The column to read the value from
    3. The RowID to read the value from
    4. Should it show potential errors or just return an empty string
     Here is an example of how to use it. If you want to create a SmartText the can return values from the current selection, you can create one like this: $mb{ReadValue("Selection", "Borough", 1, 0).

    In the example below, you can see how this would look in the layout. Also notice that I have used MapInfo Pro v2019 to create the example below which explains why I can use FALSE instead of 0.

    If you exit the edit mode of the text and if you have a current selection, the SmartText will display the value from the borough column. Note that the value will automatically change if you select a different record.

    You can, of course, make the SmartText read from a fixed table instead of the current selection.

    I have attached the compiled application as well as the source code for this small utility.

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------

    Attachment(s)

    zip
    GetColumnValue.zip   12 KB 1 version


  • 4.  RE: Smart text in Layout Automation

    Posted 01-14-2020 17:00
    Peter

    Thank you so much for your assistance. I am new to Mapbasic and I am sure I will be calling on your broad skill set in Mapinfo and related applications throughout my learning. Great to see there is a dedicated community out there which is willing to assist.Thanks again​

    ------------------------------
    David Cini
    Knowledge Community Shared Account
    ------------------------------



  • 5.  RE: Smart text in Layout Automation

    Posted 02-19-2020 00:24

    Dear Peter,

    Similar to what David Cini is trying to undertake, I am trying to produce a land register.  This is a register of just over 900 land parcels. i have been tasked with producing an A4 page per land parcel which shows a map of the land parcel and provides attribute data about the lad parcel.  I have found Kalu Ribush's SiteMapper tool which is perfect for automating the production of a large number of maps and have got this tool working, it is very simple and easy to use.

    Kalu's SiteMapper tool is designed to allow for the return of attribute data for one column.  At this stage I have 12 columns (maybe more) of attribute data I would like to display on the page.  Kalu did not design his tool to return multiple fields of attribute data (this is not a criticism)

    I am trying to find a way to put the attribute data for each land parcel on the layout page and still utilise SiteMapper to automate the production of over 900 maps.

    I have investigated the use of David Cini's smart text code 
    $mb{ColumnInfo(LayerInfo(LayoutItemWinID(CurContext(1), "Map-1", 1),1,1),"COL3",1)}
    and it provides the column name from the selection in the layout window called (Map-1) but not the associated attribute data value.

    I am not very good with MapBasic language so am wondering of you or someone/anyone can assist to create a smart text code to return attribute data. I'm thinking/hoping that for each attribute required there would be an individual smart code text. Much like David Cini's above it wold require the change of COL3 to COL4 etc to return the correct value but referring back to the layout map (Map-1) so tat when the SiteMapper tool is run it will change the value based on the land parcel being referred to in the layout map (Map-1).

    I have also investigated your recommendation to utilise the GetColumnValue tool and use the smart text script
    $mb{ReadValue("Selection", "Borough", 1, 0)
    as you have provided above.  Where "Selection" is the name of my land register table and "Borough" is the name of the column and a specified row number.  However when running the SiteMapper tool this value remains the same - unless I have missed something - which is highly likely

    For some reason it won't let me insert a screen shot or attach a file, so hopefully this make sense.  Happy to chat if it doesn't my direct line in 07 4761 3604

    I suppose I am loving the potential of using smart text codes to generate the attribute data because then you can customise the layout window with smart text codes as opposed to adjusting Kalu's SiteMapper tool to allow for X number of columns.  My Land Register project currently has 12 columns of attribute data I wish to show, however I see application for other Council Registers which at this stage have an unknown number of columns.

    Any help would be very gratefully received.

    Heather Holder



    ------------------------------
    Heather Holder
    GIS Technical Assistant
    Whitsunday Regional Council
    Proserpine
    ------------------------------



  • 6.  RE: Smart text in Layout Automation

    Employee
    Posted 02-19-2020 03:27
    Hi Heather

    Thanks for reaching out. I'll add @Kalu Ribush to this discussion as I might need his insight on this too.

    My initial idea was to use the query that Kalu creates for each site that his tool creates a map for. Unfortunately, that query name seems to be variable depending on the table name and maybe even also depending on the column with the unique values.​

    Kalu, in your code I can see you use this statement to set the name of the query for each site:
    strThisSite = "q_"+str$(left$(strColumnValueFileNameFix,24)) strThisSite = "q_"+str$(left$(strColumnValueFileNameFix,24))

    strColumnValueFileNameFix seems to originate from this expression:
    aliasColumnValueFileName = strSiteTab+"."+arrayColumnsNamesUnique(intSelectedColumnFileName) 

    Can you see a problem in changing this to a fixes query name, say q_CurrentSite:
    strThisSite = "q_CurrentSite"

    If we could modify your tool in this way, we could use, or maybe even include my small utility in your tool, that could read values from whatever column the user wants to, using a SmartText like this:
    $mb{ReadValue("q_CurrentSite", "Borough", 1, 0).

    I can give this a try if you think it would be possible, Kalu.

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 7.  RE: Smart text in Layout Automation

    Posted 02-19-2020 18:18
    Hi Peter and @Heather Holder

    I've made an update to my code which will help you with this. 

    I've added some code, so that you can add multiple empty text frames to the Layout Designer Window.

    If you name a text frame "COL1" (in the properties, not the frame text) then the frame text will be updated with the value for COL1.  If you name a frame COL2 .... etc ... up to COL20   (is this enough?).


    Note ... this is case sensitive  (must be "COL#").  Make sure the empty text frames are big enough to accommodate the column values.

    I'll send you a private link to the new version (1.7) to test.  If it's successful I'll look at publishing it to the download site.

    Regards
    Kalu

    ​​​

    ------------------------------
    Kalu Ribush
    Senior Mapping Specialist
    Department of Economic Development, Jobs, Transport and Resources (DEDJTR)
    Melbourne
    ------------------------------



  • 8.  RE: Smart text in Layout Automation

    Posted 02-19-2020 22:19
    Hi Peter and  @Kalu Ribush

    Thank you both, it works perfectly!!  I'm sure 20 columns will be more than enough - definitely for my purposes at the moment. 

    Kalu you are amazing I can't thank you enough for modifying your SiteMapper tool to suit my needs - that was above and beyond what I expected.  Thank you.  I can see this being a regular tool that I will utilise and that other people in my Council will soon want to use for all sorts of projects.  

    Regards
    Heather






    ------------------------------
    Heather Holder
    GIS Technical Assistant
    Whitsunday Regional Council
    Proserpine
    ------------------------------



  • 9.  RE: Smart text in Layout Automation

    Employee
    Posted 02-20-2020 02:17
    You rock, Kalu!
    Thanks for helping out here!

    ------------------------------
    Peter Horsbøll Møller
    Distinguished Engineer
    Pitney Bowes Software & Data
    ------------------------------



  • 10.  RE: Smart text in Layout Automation

    Posted 02-20-2020 18:12
    ​Hey Kalu

    I have been talking with Heather about her requirements with Site Mapper and would really appreciate if you can distribute SiteMapper Ver1.7 with the new multiple column text frames to the download site. Heather has been raving about the success of the add-in for her requirements and I think it is closer to what I will require to register our Infrastructure.

    One issue I did have with Site Mapper was the publishing of pdfs to desktop after the processing of the frames. As I have a possible 1,000+ maps to produce can you offer some guidance.

    Thanks again and hope to hear form you soon.

    ------------------------------
    David Cini
    GIS Analyst
    Cairns Regional Council
    Cairns
    ------------------------------



  • 11.  RE: Smart text in Layout Automation

    Employee
    Posted 02-22-2022 02:04
    Hi

    Just wanted to give you all a heads-up that we did publish several new versions of SiteMapper in the last two years.

    Here's a list of the improvements:
    • v1.7.0, 2020, April: The SiteMapper tool has been updated with new functionality to include additional columns on the layout window. The User Guide has now also been updated.
    • v1.9.0, 2021, September: The Microsoft PDF driver has been added and some further enhancement has been made to the layout. The user guide has been updated.
    • v1.9.1, 2021, September: Bug fixes
    • v2.1.3, 2021, November: Support for two maps in layouts, site ID values don't have to be unique, SiteMapper control on Home and Layout tab, and much more
    • v2.2.0, 2021, December: Support for validating that Site ID column only contains unique values. Additional verification for the configuration dialog and a couple of bug fixes
    You can find and download the SiteMapper tool from the MapInfo Marketplace from within MapInfo Pro. If you already have a version of Site Mapper, you should have seen notifications of the new versions too.


    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------