How does one replace the geometries (shapes, polylines, etc.) already present in a layout when a new data file is loaded into the layout file?
Explanation of the Question:
I created a layout file from a dataset that contains geometries, such as a relative wind velocity vector or aircraft body axes relative to wind axes. I want to create a template from this layout, but the geometries are now embedded in the .lay file as $!AttachGeom records. This becomes an issue when I want to use the layout file as a template, replacing the original dataset with a new one using the “Load Data…/Replace data in all shared frames and retain style” option shown in Figure 1 and 2. The geometry associated with the dataset being replaced is retained and displayed along with the new geometries in a new dataset (see Figure 3). Thus, the plot is left with unwanted geometries (the rectangular geometry in Figure 3) from the previous dataset.
Here are a few workarounds for this situation:
Option 1: Create a layout that starts with cleared text/geometries
1. Create an example layout.
2. Delete all of the text and geometries you know will be supplied by the dataset. One way to do this is by creating a quick macro. See this example:
$!MACROFUNCTION NAME = "Delete All Text and Geometries" SHOWINMACROPANEL = TRUE $!PICK ADDALL SELECTTEXT = YES SELECTGEOMS = YES $!PICK CLEAR $!ENDMACROFUNCTION
Then run this quick macro prior to loading a data file into the template.¹
3. Save the layout. This is the template layout with no saved geometries.
Option 2: Use stylesheets instead of layouts
Reading and Writing stylesheets allows for the inclusion/exclusion of text and geometries. Consider the following:
1. Read in data and create frames with desired plots (text on the plots will be coming from the original data).
2. For each frame in the plot save a stylesheet (via Frame > Save frame style…).
3. Go to Scripting > Record Macro… and start recording a macro.
4. Click the New Layout button.
5. Read in data (File > Load Data…).
6. Read in stylesheets (Frame/Load frame style) created in step 2 above, creating all new frames except the first. At this point you will have a plot with the duplicated text and geometries (from data and style).
7. Stop recording the macro.
8. Edit the recorded macro and for each $!READSTYLESHEET command add the following options:
INCLUDETEXT = FALSE
INCLUDEGEOM = FALSE
From now on to view a different dataset you will need to edit the macro file and change the name of the dataset (or overwrite the same data files with new data) and then run the macro.
¹ See Adding Macros to the Quick Macro Panel for more details.