Calling interface macro

Tagged: ,

This topic contains 3 replies, has 3 voices, and was last updated by  Bruce Walker 2 weeks ago.

  • Author
    Posts
  • #3610

    Bruce Walker
    Participant

    Can anyone point me in the right direction to figure out how to call a macro for a couple of interface pages?

    I am developing a cabinet object that calls a macro for the doors & drawers. Because this macro does the 3d & 2d script, I call it from the cabinet’s master script. This works fine for those scripts, but now I’m doing the interface, I can’t figure out how to get the page order correct. What I end up with is two pages sitting on top of each other, and/or an error message that says “FieldID ‘1’ previously defined at line xxx in the Interface script of file [parent file name].gsm.” Also, most of my tabs from the parent object disappear.

    I’ve developed a number of hierarchical interfaces, so am reasonably familiar with what’s involved – but I’m stumped on this one. I’ve tried digging through the GS door object, but my brain hurts now.

    Cheers

    www.brucepwalker.com
    https://www.mindmeister.com/65450406

    AC20 6005 AUS Full & AC 21 3009 NZE Full | Win 10 Pro 64 | Intel i7-7700HQ 2.80GHz | 16 Gb RAM
    NVIDIA GeForce GTX 1060 8Mb

  • #3612

    Gergely Fehér
    Keymaster

    If you call a macro from master for the 2D and 3D, you should put it in a condition: “if GLOB_SCRIPT_TYPE = 2 or GLOB_SCRIPT_TYPE = 3 then” – in this case, it won’t ruin your paramscript or interface script.

    Gergely Fehér
    Team Leader, Library Team
    GRAPHISOFT SE

  • #3640

    Dominika Bobály
    Keymaster

    Some more tips:
    * make sure there is no interference between the ui_page IDs of the object and the macro. Everyone should know exactly which pages they are responsible for. Either pass down the necessary data to the macro via parameters, or hardcode the page IDs in both places. In our door objects, we have a macro containing the hardcoded IDs, and we call that macro in each interface script where a new tabpage is inicialized. You don”t have to do this in case you have a handful of pages alltogether, just hardcode the IDs exactly the same way in all places belonging to the same UI tabpage set.
    * the warning “FieldID ‘1’ previously defined at…” usually appears if you have more than one listfield in the tabpage set, and their listfield ID-s are conflicting. In case there is only one listfield/tabpage, it is best to use the tabpage ID as listfield ID (theoretically tabpage ID-s should be unique). In case you have more than one listfield on a tabpage, you should come up with a unique listfield ID a different way.
    * listfields can have listitems defined in different places, see here. You do not have to duplicate the listfield in case some items are added in a macro.

    Good luck.

    Dominika Bobály
    Library Developer, Library Team
    GRAPHISOFT SE

  • #3662

    Bruce Walker
    Participant

    Thanks Gergely and Dominika. I have managed to get it working now. For future reference for anybody with the same issues who may stumble across this post:
    1. I had accidentally declared the ID variable the same in both objects (e.g. unID = 1). I changed the macro declaration to ensure the listfield ID was unique.

    2. I was using the tab[iTAB] = “” : iTAB = iTAB + 1 method to declare all my page titles. This works well with only one object, but with a macro, it gets too complicated (I found). So I swapped out the array for direct variables. Next time, I think I’ll just write the page title directly in the subroutine.

    3. Each page needed a unique ID…in the order I wanted them to appear.

    4. The call function needed to include “gs_ui_current_page = gs_ui_current_page”

    Thanks again!

    www.brucepwalker.com
    https://www.mindmeister.com/65450406

    AC20 6005 AUS Full & AC 21 3009 NZE Full | Win 10 Pro 64 | Intel i7-7700HQ 2.80GHz | 16 Gb RAM
    NVIDIA GeForce GTX 1060 8Mb

You must be logged in to reply to this topic.