Changes between Initial Version and Version 1 of CodeSamples/Other/MaestroScripts/ScaleRangeUpdate


Ignore:
Timestamp:
Jul 19, 2013 12:29:45 AM (5 years ago)
Author:
jng
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CodeSamples/Other/MaestroScripts/ScaleRangeUpdate

    v1 v1  
     1[[PageOutline]]
     2
     3This page is one of the !MapGuide Community CodeSamples.  Visit the CodeSamples page to view more!
     4
     5This sample script contains a series of utility functions to batch update a series of Layer Definitions in a folder to conform to a specified minimum/maximum scale range.
     6
     7=== How to use this script ===
     8
     9 1. Launch MapGuide Maestro
     10 2. In the '''IronPython''' console, click '''Run File'''
     11 3. Browse to '''scale_ranges_utils.py''' and click '''Open''' to load this script
     12
     13Once loaded, you will have the following functions available for you to use from the IronPython console:
     14
     15{{{
     16#!python
     17def FixScaleRangesMinMax(conn, folder, min, max):
     18    """
     19    Modifies the first scale range of all Layer Definitions under the specified folder to the specified
     20    minimum and Mmximum scales
     21    """
     22def FixScaleRangesZeroToMax(conn, folder, max):
     23    """
     24    Modifies the first scale range of all Layer Definitions under the specified folder to the specified
     25    maximum scale. The minimum scale is un-set (ie. Set to 0)
     26    """
     27def FixScaleRangesMinToInfinity(conn, folder, min):
     28    """
     29    Modifies the first scale range of all Layer Definitions under the specified folder to the specified
     30    minimum scale. The maximum scale is un-set (ie. Set to infinity)
     31    """
     32def FixScaleRangesZeroToInfinity(conn, folder):
     33    """
     34    Modifies the first scale range of all Layer Definitions under the specified folder to [0, Infinity]
     35    """
     36}}}
     37
     38To modify all layers under {{{Library://Samples/Sheboygan/Layers/}}} to have a scale range of 50 to 12000, you would run the following snippets in your IronPython console. This assumes a session with only one active site connection:
     39
     40{{{
     41
     42>>> conn = app.GetConnection(app.GetConnectionNames()[0])
     43>>> FixScaleRangesMinMax(conn, "Library://Samples/Sheboygan/Layers/", 50, 12000)
     44
     45}}}
     46
     47This will output something similar to this:
     48
     49{{{
     50
     51Fixing: Library://Samples/Sheboygan/Layers/CityLimits.LayerDefinition
     52Scale range set to [50, 12000]
     53Saved: Library://Samples/Sheboygan/Layers/CityLimits.LayerDefinition
     54Fixing: Library://Samples/Sheboygan/Layers/Buildings.LayerDefinition
     55Scale range set to [50, 12000]
     56Saved: Library://Samples/Sheboygan/Layers/Buildings.LayerDefinition
     57Fixing: Library://Samples/Sheboygan/Layers/Districts.LayerDefinition
     58Scale range set to [50, 12000]
     59Saved: Library://Samples/Sheboygan/Layers/Districts.LayerDefinition
     60Fixing: Library://Samples/Sheboygan/Layers/Hydrography.LayerDefinition
     61Scale range set to [50, 12000]
     62Saved: Library://Samples/Sheboygan/Layers/Hydrography.LayerDefinition
     63Fixing: Library://Samples/Sheboygan/Layers/Islands.LayerDefinition
     64Scale range set to [50, 12000]
     65Saved: Library://Samples/Sheboygan/Layers/Islands.LayerDefinition
     66Fixing: Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition
     67Scale range set to [50, 12000]
     68Saved: Library://Samples/Sheboygan/Layers/Parcels.LayerDefinition
     69Fixing: Library://Samples/Sheboygan/Layers/Roads.LayerDefinition
     70Scale range set to [50, 12000]
     71Saved: Library://Samples/Sheboygan/Layers/Roads.LayerDefinition
     72Fixing: Library://Samples/Sheboygan/Layers/Tracks.LayerDefinition
     73Scale range set to [50, 12000]
     74Saved: Library://Samples/Sheboygan/Layers/Tracks.LayerDefinition
     75Fixing: Library://Samples/Sheboygan/Layers/Trees.LayerDefinition
     76Scale range set to [50, 12000]
     77Saved: Library://Samples/Sheboygan/Layers/Trees.LayerDefinition
     78>>>
     79
     80}}}
     81
     82=== Limitations ===
     83
     84This only operates on the first scale range it finds of each Layer Definition in the folder you specify.