|
Table of Contents
Scripts > DM_Clip
Script contents//
// Title | DM_Clip
// Purpose | A script to clip the altitude layer of the design map
// Author | Aaron Torpy
// Date | 7 July 2010
//
hvar hDM
set hDM <GetMap "DM">
assert <not <iseq hDM NULL>> "Error: Design map is not present"
assert <map.GetWidth hDM> "Error: Design map is not initialised"
// ask for clipping mode
combosel CS
combosel.InitCS &CS "Clip above|Clip below|Clip both" "Clip above"
if <not <EditUI &CS "Select clipping mode">>
return -1
endif
// check clipping mode, and ask for clipping altitudes
float ClipAltMin
float ClipAltMax
set ClipAltMin 0
set ClipAltMax 0
int ClipMode
set ClipMode 0
if <iseq <combosel.GetCurSel &CS> "Clip above">
set ClipMode 0
if <not <EditUI &ClipAltMax "Enter max clip height (metres)">>
return -1
endif
elseif <iseq <combosel.GetCurSel &CS> "Clip below">
set ClipMode 1
if <not <EditUI &ClipAltMin "Enter min clip height (metres)">>
return -1
endif
elseif <iseq <combosel.GetCurSel &CS> "Clip both">
set ClipMode 2
if <not <EditUI &ClipAltMin "Enter min clip height (metres)">>
return -1
endif
if <not <EditUI &ClipAltMax "Enter max clip height (metres)">>
return -1
endif
else
echo "ClipDesignMap script error:\r\n - unknown clipping mode"
return -1
endif
//echo <strcat ClipAltMin ClipAltMax> // debugging
// create temp HF to contain DM alt layer
map TempHF
if <not <calc.DM.GetLayer hDM &TempHF 0>>
echo "ClipDesignMap script error:\r\n - cannot extract altitude layer from design map"
return -1
endif
// store a backup
if <not <L3DTio_Backup.ExtBackupMap "DM" "Clip design map alt" 0 "view.ShowMap \"DM\"">>
echo "ClipDesignMap script error:\r\n - cannot store backup point for design map"
//return -1
endif
// clip the design map alt layer
if <or <iseq ClipMode 0> <iseq ClipMode 2>>
if <not <calc.HF.ClipAbove &TempHF ClipAltMax ClipAltMax true>>
echo "ClipDesignMap script error:\r\n - cannot clip max altitude layer of design map"
return -1
endif
endif
// clip the design map alt layer
if <or <iseq ClipMode 1> <iseq ClipMode 2>>
if <not <calc.HF.ClipBelow &TempHF ClipAltMin ClipAltMin true>>
echo "ClipDesignMap script error:\r\n - cannot clip min altitude layer of design map"
return -1
endif
endif
// copy back to design map
if <not <calc.DM.SetLayer hDM &TempHF 0>>
echo "ClipDesignMap script error:\r\n - cannot copy altitude layer into design map"
return -1
endif
// redraw design map
view.ShowMap "DM"
MessageBox "Clipping complete!" 0x40
return 0
CommentsNone. Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
|