MapInfo Pro Developers User Group

 View Only
  • 1.  Layout Templates

    Posted 08-25-2020 09:26
    Hi Everyone,

    Has anyone worked out how to open layout templates through Mapbasic?

    I can find where they are stored and the .lay seems to be the Mapbasic code to create the layout.

    I can of course just write the whole layout in MB but I wanted to allow the user and easy editing option through templates.

    Any help would be great

    many thanks

    Regards

    ------------------------------
    Martin Hodder
    Managing Consultant
    Higher Mapping Solutions
    ------------------------------


  • 2.  RE: Layout Templates

    Employee
    Posted 08-26-2020 03:48
    Hi Martin

    I might be missing the point but you can "use" the layout template and modify it through the standard tools in MapInfo Pro. Once you have emoade the edits, you can save the layout back as a Layout Template.

    Is that what you are looking for?

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



  • 3.  RE: Layout Templates

    Posted 08-26-2020 04:32
    Hi Peter,

    Thanks for the reply as always.

    What I am trying to achieve is for the user to press a button and the layout gets automatically created. So put in the map and add the logo and add the information that my program has calculated and held in variables.

    In the past would create workspaces with just the the layout - the program would open the workspace and populate it.

    I was hoping  the user they could edit a template to their own design and allow them to use the smart text.  Then the program would open the template and add in the information from the program - all by a single press of a button.

    Does that help clarify what I am trying to do?

    ------------------------------
    Martin Hodder
    Managing Consultant
    Higher Mapping Solutions (OEM)
    ------------------------------



  • 4.  RE: Layout Templates

    Employee
    Posted 08-26-2020 04:59
    That helps, Martin.

    The logo I would suggest you add to the template.

    You calculated variables, I'd suggest access using smart text elements that you also add to the template. Let me show you how below.

    In your application, that I expect will be running when they use the Layout Template, you create one or more functions that you publish to/register with MapInfo Pro using the IMBXRegisterPublicFunction method declared in IMapInfoPro.def. If you are using the RibbonLib, you can use RBNRegisterFunctionAsPublic.

    Now when you run your application this or these functions of your are available to the MapInfo Pro user, and to MapInfo Pro.

    This means you can use your function in a SmartText: $mb{MyFancyFunction("SomeParameter")}

    Your function can return a single word/number or it can return a longer text string with newline characters.

    I have described this in a bit more detail here: Smart text in Layout Automation.

    Alternatively, you can have a look at the source code for the Layout Template tool and mimic what this tool does when opening a Layout Template. You can find it in the Samples folder in your MapBasic installation folder: Samples\RIBBONINTERFACE\DotNet\LayoutTemplate..

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



  • 5.  RE: Layout Templates

    Posted 08-26-2020 05:34
    Thanks Peter,

    That is really great - I will have a look into those things.

    Regards

    Martin

    ------------------------------
    Martin Hodder
    Managing Consultant
    Higher Mapping Solutions (OEM)
    ------------------------------