Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

Welcome Guest!
Want to take part in these discussions? If you have an account, sign in now.
If you don't have an account, apply for one now.
  1.  

    I thought I had asked at least one of these questions before but if so I can't remember the answer.

    1. When the "New Map Wizard" (NEWWIZ) is used with the "Decide settings myself" option, at least one blank map is saved before any is opened for editing. Does this mean the OnOpenMacro note is run rather than the OnNewMacro one? (If so then the latter would not be needed on "Wizard" templates.)
    2. When a predefined template is used rather than a wizard one, is the OnNewMacro note run instead of the OnOpenMacro one, or are both run (if so, in what sequence)?*
    3. While browsing the latest edition of the Tome of Ultimate Mapping I found references to an OnLoadMacro note on pages 68 and 426. Was this an earlier version of the other two or can it still be used instead of either if both would be the same?

    * Note that the GETDWGNAME command can only be safely used in the OnOpenMacro note because maps created from predefined templates open with a temporary name of "(Map).FCW" that does not have a path. (I'm thinking about writing a GETMAPVARS macro that generates a SAVEVARS command filename based on the drawing name that could be run when the drawing is opened.)

    •  
      CommentAuthorMonsen
    • CommentTimeApr 29th 2019
     
    1. For maps using the new map wizard, the OnNewMacro is run during the creation of the map, i.e. the file saved to disk is a copy of the template with that macro already run on it. Then, CC3+ loads the map from disk, and OnOpenMacro is run on it immediately (and every time you open it after that)

    2. Predefined maps do not utilize onNewMacro at all, they only run OnOpenMacro immediately when the new map is opened (and every time you open it after that)

    3. The references in the Tome is in error. It should refer to OnOpenMacro.
  2.  
    Posted By: Monsen1. For maps using the new map wizard, the OnNewMacro is run during the creation of the map, i.e. the file saved to disk is a copy of the template with that macro already run on it. Then, CC3+ loads the map from disk, and OnOpenMacro is run on it immediately (and every time you open it after that)

    So my afterthought was correct; the working filename for wizard templates would not have a path until it was first saved. This becomes even more complicated if the multilevel option is used.

    Posted By: Monsen2. Predefined maps do not utilize onNewMacro at all, they only run OnOpenMacro immediately when the new map is opened (and every time you open it after that)

    Oh dear! That means no calling the following macro in the OnOpenMacro of predefined maps. (I checked; the filename has no path until it is saved.

    MACRO GETMAPVARS
    ifdef VFNAME gmvrun
    getdwgname VFNAME
    grfn VFNAME VFNAME
    noextension VFNAME VFNAME
    apnd VFNAME _vars.scr
    :gmvrun
    scriptm VFNAME
    savevars VFNAME
    ENDM

    If anyone wants to include it in their core macro file, feel free.

    Posted By: Monsen3. The references in the Tome is in error. It should refer to OnOpenMacro.

    I thought it might be something like that. (So the OnNewMacro note is only used on wizard templates. How interesting.)

    •  
      CommentAuthorMonsen
    • CommentTimeApr 29th 2019 edited
     
    Posted By: DaltonSpenceSo theOnNewMacronote is only used on wizard templates. How interesting.
    Yes. The code that calls this macro is part of the new map wizard code. The new map wizard actually opens the template in the background, apply some modifications to, including running that macro, and then saves it to disk, before it then just proceeds to load it. Loading in a map in the "background" and doing stuff with it is similar to for example what the MULTIFILESCRIPT does.
  3.  
    Are there any known problems with the MULTIFILESCRIPT command? I wrote a simple script to change the floor names in the key area of multilevel map ("Floor 1" became "First Floor", "Floor 2" became "Second Floor", etc.) and while it worked on one map when called directly, any attempt to use MULTIFILESCRIPT to change all levels caused the program to crash out.
    •  
      CommentAuthorMonsen
    • CommentTimeApr 29th 2019
     
    Not sure for the MULTIFILESCRIPT. I've had it crash on myself too, but I am not sure when/why/what causes it.
  4.  

    I thought of a one line addition to my macro that might prove useful in the future. Basically I'm saving the relative drawing name (sans extension) in a variable for external file references specific to the drawing.

    MACRO GETMAPVARS
    ifdef VFNAME gmvrun
    getdwgname VFNAME
    grfn VFNAME VFNAME
    noextension VFNAME VFNAME
    gl FPNAME VFNAME
    apnd VFNAME _vars.scr
    :gmvrun
    scriptm VFNAME
    savevars VFNAME
    ENDM

    Also I've had some thoughts about adding a "Welcome" message to the OnOpenMacro note that can be turned off if requested. (This must be preceded by a call to the GETMAPVARS macro to work between loads.)

    GETMAPVARS
    ifdef HIDETIP ChkTip
    :WelcomeMsg
    gn HIDETIP 0
    askbox Welcome to this Drawing
    ... opening message ...
    Do you want to hide this message in future?

    iferr HideIt
    gn HIDETIP 1
    :HideIt
    savevars VFNAME
    go NoChk
    :ChkTip
    ifz HIDETIP WelcomeMsg
    :NoChk

    Note that the HIDETIP variable can be reset to 0 manually to see the Welcome message the next time the map is loaded, but you must enter "savevars VFNAME" on the command line immediately after for that to work. (Too bad there is no OnCloseMacro note that would be run whenever a map is closed so the mapper didn't have to remember to "savevars VFNAME" every time. ;) )

    •  
      CommentAuthorMonsen
    • CommentTimeMay 2nd 2019
     
    That's a cool idea.
  5.  
    I really should have posted this discussion to the Macros and XPs category. Is there any way I move it there?
    •  
      CommentAuthorMonsen
    • CommentTimeMay 7th 2019
     
    Just edit the first post in the discussion, and pick a new category.
  6.  
    Thanks.
  7.  

    To expand on my previous comment a similar bit of code could be placed at the beginning of each macro only drawing tool.

    SELSAVE
    SAVESETTINGS
    ifdef mdtTIP mdtChkTip
    gn mdtTIP 0
    :mdtWelcome
    askbox Welcome to this Drawing Tool
    ... opening message with instructions ...
    Do you want to hide this message in future?

    iferr mdtNoChk
    gn mdtTIP 1
    go mdtNoChk
    :mdtChkTip
    ifz mdtTIP mdtWelcome
    :mdtNoChk

    Note: the "mdt" prefix stands for "Macro Drawing Tool". You might want to change that for your own tools.

  8.  
    A bit of a caution here: One really shouldn't put a call to the GETMAPVARS macro (or script) in the OnOpenMacro note of a map template unless one really wants to save the variables in a script file in the template folder during it's development. It should only be added to the note after the map is first saved. I'm attaching a zip file with a couple of scripts that might be useful in the OnOpenMacro note. These scripts should be extracted to the "Scripts" folder of the CC3Plus data directory so they can be called by a "scriptm @Scripts\filename.scr" command. The GETMAPDIMS script is from the TIP: Determining Map Width in Macros discussion.
    •  
      CommentAuthorMonsen
    • CommentTime7 days ago
     
    Remember that macro variables are not reset when you open a new map, which can cause issues with getting, setting and checking "standard" variables from the OnOpenMacro map note.
  9.  
    They aren't? That is something I didn't know. And there is no way to "undefine" a variable (either individually or in a group) either, is there? Bummer, that makes my "clever ideas™" a bit trickier. :(