Scripts XML
Choisir cette commande pour exécuter des fonctions dont les paramètres sont définis dans un fichier XML.
Introduction
Sélectionner Exécuter le script XML dans le menu Fichier ou faire glisser le fichier xml dans la fenêtre OCAD.
Généralités
Fichier
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.New | File | String | ocd file name |
File.Open | File | String | ocd file name |
File.Close | Enabled | Boolean | true, false |
File.Save | Enabled | Boolean | true, false |
File.SaveAs | File | String | ocd file name |
File.Import.Ocd | File SymbolOption ColorOption |
String Integer Integer |
File name [0..3] [0, 1] |
File.MultipleFileImport | Directory CoordinateSystem NewOffset Horizontally Vertically Angle MapScale GridDistance LayerField |
String Integer Boolean Integer Integer Double Integer Double String |
Directory of import files -1 = WGS 84, 1000 = existing grid of OCAD file true, false |
File.Exit | Enabled | Boolean | true, false Close OCAD Program |
Visualisation
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
View.Mode | Enum types | normalMode, spotColorMode, draftMode | |
View.EntireMap | Enabled | Boolean | true, false |
View.MoveTo | X Y |
Double Double |
|
View.Zoom | Double |
Carte
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
Map.OptimizeRepair | Enabled | Boolean | true, false |
Map.ChangeScale | NewScale | Integer | e. g. 10 000 |
EnlargeReduceSymbols | Boolean | true, false | |
Map.ConvertLayer | CrtFile | String | crt file name |
Map.LoadSymbolsFrom | File | String | ocd file name (with symbols to be loaded) The option replace existing colors and symbols is used |
Map.Routing | FromCoordinateEasting FromCoordinateNorthing ToCoordinateEasting ToCoordinateNorthing TemplateFile AddDrivingDirections |
Double Double Double Double String Boolean |
|
Base de données
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
Database.Dataset.New | DatasetName DBaseFile OdbcDataSource Table KeyField SymbolField TextField SizeField LengthUnit AreaUnit Decimals HorizontalCoordinate VerticalCoordinate Username Passwort |
String String String String String String String String String String Integer String String String String |
mandatory mandatory mandatory |
Database.Dataset.Remove | Dataset | String Integer |
all for all databases 3, 2, 1, ... for only one or several |
Database.Assign.Symbols | Dataset CntFile |
String Integer String |
all for all databases 1, 2, 3, ... for only one database Condition table file |
Database.Assign.Texts | Dataset TextField Symbol ReplaceExistingObjects |
String Integer String String Boolean |
all for all databases 1, 2, 3, ... for only one database ex. 101.0 true, false (Default) |
Database.Assign.Angles | Dataset AngleField |
String Integer String |
all for all databases 1, 2, 3, ... for only one database |
Database.CreateObjects | Dataset SelectSymbol Condition HorizontalCoordinate VerticalCoordinate Unit TextField HorizontalOffset VerticalOffset |
Integer Double String String String Enum types String Double Double |
1, 2, 3, ... Number of dataset Symbol numer. ex. 207,0 SQL String (ex. SYMBOL LIKE 207,0) Database fieldname Database fieldname m, km Database fieldname |
Fichier d'exemples xml:
<?xml version="1.0" encoding="ISO-8859-1"?> <!-- OCAD XML Script for multiple Shape import and assigning symbols from database --> <OcadScript> <File.New> <!-- This path has to be adjusted before using the script! Choose a template file. --> <File>C:\Export\Chlosterwald.ocd</File> </File.New> <File.MultipleFileImport> <!-- This path has to be adjusted before using the script! --> <Directory>C:\Export\Files</Directory> <CoordinateSystem>1000</CoordinateSystem> <NewOffset>true</NewOffset> <Horizontally>600000</Horizontally> <Vertically>200000</Vertically> <Angle>0</Angle> <MapScale>10000</MapScale> <GridDistance>500</GridDistance> <LayerField>OBJECTVAL</LayerField> </File.MultipleFileImport> <Database.Assign.Texts> <Dataset>all</Dataset> <TextField>TEXT</TextField> <Symbol>902.000</Symbol> <ReplaceExistingObjects>false</ReplaceExistingObjects> </Database.Assign.Texts> <Database.Assign.Angles> <Dataset>all</Dataset> <AngleField>ANGLE</AngleField> </Database.Assign.Angles> <Database.Assign.Symbols> <Dataset>all</Dataset> <CntFile>C:\Export\Chlosterwald.cnt</CntFile> </Database.Assign.Symbols> <Database.Dataset.Remove> <Dataset>all</Dataset> </Database.Dataset.Remove> <Map.OptimizeRepair> <Enabled>true</Enabled> </Map.OptimizeRepair> <View.EntireMap> <Enabled>true</Enabled> </View.EntireMap> <File.Save> <Enabled>false</Enabled> </File.Save> <File.SaveAs> <File>C:\Export\Chlosterwald_Example.ocd</File> </File.SaveAs> <File.Close> <Enabled>true</Enabled> </File.Close> <File.Exit> <Enabled>false</Enabled> </File.Exit> </OcadScript>
Script XML pour une carte partielle
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
export | file | String | eg.: ‚ c:\export\PartialMap1.ocd ‘ OCAD creates files PartialMap1_1_1.ocd, PartialMap1_1_2.ocd, |
export | coordSystem | Enum types | mm (paper), m (real world) |
export | T, L, B, R | Float | top, left, bottom, right |
export.loop | enabled horizontalPages verticalpages horizontalOverlap verticalOverlap |
Bool Integer Integer Float Float |
true, false number of pages in horizontal direction number of pages in vertical direction horizontal overlap in mm or m vertical overlap in mm or m |
Fichier d'exemple xml:
<ocadScript> // comment <partialMapScript> <export id="0"> // first export section <file>c:\export\PartialMap1.ocd</file> // export file <coordSystem>mm</coordSystem> // paper oder real world coordinates <T>100</T> // export rectangle with Top Left point and Bottom Right point <L>0</L> <B>50</B> <R>50</R> <loop> // the loop export several ocd files. For this example 21 files. <enabled>true</enabled> <horizontalPages>7</horizontalPages> <verticalPages>3</verticalPages> <horizontalOverlap>10</horizontalOverlap> // horizontal and vertical overlap. <verticalOverlap>10</verticalOverlap> </loop> </export> // second export section <export id="1"> <file>c:\export\PartialMap2.ocd</file> <coordSystem>mm</coordSystem> <L>0</L> <R>50</R> <B>50</B> <T>100</T> <loop> <enabled>false</enabled> </loop> // export only one ocd file </export> </partialMapScript> </ocadScript>
Script d'impression XML
Les paramètres d'impression peuvent être enregistrés dans un script XML.
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Print.Printer | Name DmPaperSize DmDefaultSource DmPrintQuality DmColor DmMediaType |
String Integer Integer Integer Integer Integer |
Eg. ,HP Color LaserJet 2840 PCL' 9 15 600 2 272 |
File.Print.Portrait | Enabled | Bool | true, false |
File.Print.SpotColor | Enabled | Bool | true, false |
File.Print.PartialMap | Range L, R, B, T |
Integer Float |
1 Left, Right, Bottom, Top |
File.Print.HoizontalOverlap | Float | -12,74 | |
File.Print.VerticalOverlap | Float | 8.74 | |
File.Print.PrintScale | Integer | Eg. 25000 | |
File.Print.Copies | Integer | Number of copies | |
File.Print.Intensity | Integer | ||
File.Print.LineWidth | Integer | ||
File.Print.PrintScreenGrid | Enabled | Bool | true, false |
File.Print.PrintScreenGridColor | Integer | Color number |
Script d'exportation XML
AI (Adobe Illustrator), PDF
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | File | String | eg.: ,c::\Export\Chlosterwald.ai‘ |
File.Export | Format | Enum types | AI, PDF |
File.Export.PartOfMap | Enabled Coordinates L, R, B, T |
Bool Enum types Float |
true, false mm (page), m (real world) left, right, bottom, top |
File.Export | ExportScale | Integer | e.g. '10000' for the scale 1:10'000 |
File.Export | Colors | Enum types | normal, spotColors |
File.Export.SpotColors | Combine | Bool | true, false [only if Colors = spotColors] |
File.Export.SpotColors | Enabled | Spotcolor name | [only if Colors = spotColors] |
BMP, GIF, JPEG
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | File | String | eg.: ‚c:\Export\Chlosterwald.bmp‘ |
File.Export | Format | Enum types | BMP, GIF, JPEG |
File.Export | Quality | Integer | only for JPEG, [0..100] |
File.Export | Resolution | Integer | in dpi [40..2540] |
File.Export | Anti-Aliasing | Boolean | true, false |
File.Export | ColorCorrection | Boolean | true, false |
File.Export.PartOfMap | Enabled Coordinates L, R, B, T |
Bool Enum types Float |
true, false mm (page), m (real world) left, right, bottom, top |
File.Export.Tiles | Enabled Width Height |
Boolean Integer Integer |
true, false [only if Enabled = true] [only if Enabled = true] |
File.Export.GeoRef | Enabled PixelSize CreateWorldFile |
Bool Float Bool |
true, false in meter [only if Enabled = true] true, false [only if Enabled = true] |
EPS
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | File | String | eg.: ‚c:\Export\Chlosterwald.eps ‘ |
File.Export | Format | Enum types | EPS |
File.Export.PartOfMap | Enabled Coordinates L, R, B, T |
Bool Enum types Float |
true, false mm (page), m (real world) left, right, bottom, top |
File.Export | Colors | Enum types | normal, spotColors |
File.Export.SpotColors | Enabled | Spotcolor name | [only if Colors = spotColors] |
SVG (Scalable Vector Graphics)
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | File | String | eg.: ‚c:\Export\Chlosterwald.svg ‘ |
File.Export | Format | Enum types | SVG |
File.Export.PartOfMap | Enabled Coordinates L, R, B, T |
Bool Enum types Float |
true, false mm (page), m (real world) left, right, bottom, top |
File.Export | ExportScale | Integer | e.g. '10000' for the scale 1:10'000 |
File.Export | CompressFile | Boolean | true, false |
TIFF
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | File | String | eg.: ‚c:\Export\Chlosterwald.tif‘ If spotColors is enabled and Combine=false then the filename is ‚c:\Export\Chlosterwald.Spotcolor name.tif ‘ |
File.Export | Format | Enum types | TIFF |
File.Export | Resolution | Integer | in dpi [40..2540]. Only used if File.Export.GeoRef -> Enabled = false |
File.Export | Anti-Aliasing | Boolean | true, false |
File.Export | ColorCorrection | Boolean | true, false |
File.Export.PartOfMap | Enabled Coordinates L, R, B, T |
Bool Enum types Float |
true, false mm (page), m (real world) left, right, bottom, top |
File.Export.Tiles | Enabled Width Height |
Bool Integer Integer |
true, false [only if Enabled = true] [only if Enabled = true] |
File.Export.GeoRef | Enabled PixelSize CreateWorldFile |
Bool Float Bool |
true (->PixelSize), false (->Resolution) in meter [only if Enabled = true] true, false [only if Enabled = true] |
File.Export | Colors | Enum types | normal, spotColors |
File.Export.SpotColors | Combine Enabled |
Bool Spotcolor name |
true, false [only if Colors = spotColors] [only if Colors = spotColors] |
File.Export | ColorMode | Integer | 0 = 32 bit CMYK 1 = 24 bit RGB 2 = 256 colors 3 = grayscale 4 = 8 bit CMYK 5 = 1 bit black/white 6 = halftone screen |
File.Export | Compression | Integer | 1 = no compression 2 = CCITT 4 = FaxG4 5 = LZW |
DXF
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | File | String | eg.: ‚c:\Export\Chlosterwald.dxf ‘ |
File.Export | Format | Enum types | DXF |
File.Export | ExportScale | Integer | e.g. '10000' for the scale 1:10'000 |
File.Export | ConvertAnsiToOem | Boolean | true, false |
File.Export | ConvertOemToUnicode | Boolean | true, false |
File.Export | ObjectsSelectedSymbols | Boolean | true, false |
File.Export | AddSymbolDescription | Boolean | true, false |
File.Export | UseCrtFileName | String | eg.: ‚c:\CRT\Chlosterwald.crt‘ |
File.Export | ExportAsSplines | Boolean | true, false |
File.Export | Coordinates | Enum types | m, mm |
Shape
Node <OcadScript> | Parameter | Data type | Values / Description |
---|---|---|---|
File.Export | ExportPath | String | eg.: ‚c:\Export‘ (only path name) |
File.Export | Format | Enum types | SHAPE |
File.Export | PointObjects LineObjects AreaObjects TextObjects |
Boolean Boolean Boolean Boolean |
true, false true, false true, false true, false |
File.Export | Dataset | String | all for 'All objects' or index eg.: 2 (Objects in dataset with index = 2) |
File.Export | WordWrap | Boolean | true, false |
File.Export | ProjectionFile | Boolean | true, false |
File.Export | Utf8Encoding | Boolean | true, false |
Exemple
L'exemple ci-dessous exporte deux fichiers pdf en spot colors et deux fichiers Shape. Chaque noeud de script peut contenir plusieurs enfants.
<?xml version="1.0" encoding="ISO-8859-1"?> <OcadScript> <File.Open> <File>M:\OCAD11\Changes\11-06xx\11-0663\Chlosterwald.ocd</File> </File.Open> <File.Export> <File>M:\OCAD11\Changes\11-06xx\11-0663\output\Chlosterwald.pdf</File> <Format>PDF</Format> <PartOfMap> <Enabled>true</Enabled> <Coordinates>mm</Coordinates> <L>0</L> <R>50</R> <B>50</B> <T>100</T> </PartOfMap> <ExportScale>10000</ExportScale> <Colors>spotColors</Colors> <SpotColors> <Combine>false</Combine> <Enabled>Blau</Enabled> <Enabled>Gelb</Enabled> </SpotColors> </File.Export> <File.Export> <ExportPath>M:\OCAD11\Changes\11-06xx\11-0663\output\</ExportPath> <Format>SHAPE</Format> <PointObjects>false</PointObjects> <LineObjects>true</LineObjects> <AreaObjects>true</AreaObjects> <TextObjects>false</TextObjects> <Dataset>all</Dataset> <WordWrap>true</WordWrap> <ProjectionFile>false</ProjectionFile> </File.Export> <File.Save> <Enabled>true</Enabled> </File.Save> <File.Close> <Enabled>true</Enabled> </File.Close> </OcadScript>
Script XML à partir d'une ligne de commande
Il est possible d'exécuter un script XML depuis une ligne de commande ou à partir d'un fichier batch.
Ouvrir la commande de Windows et entrer le nom du programme OCAD et celui du script. Par exemple: "C:\Program Files\OCAD\OCAD 11\Ocad11.exe" "C:\Data\ExportScriptExample_PDF.xml"
Ne pas oublier d'utiliser le paramètre <File.Open> pour ouvrir le fichier, <File.Close> pour le fermer et <File.Exit> pour quitter OCAD.
Ouvrir un fichier ocd à partir d'une ligne de commande
Il est possible d'ouvrir un fichier OCD à partir d'une ligne de commande, avec des paramètre optionnel de visualisation.
Ouvrir la commande de Windows et entrer le nom du programme OCAD e et celui du fichier OCD..
Par exemple:
"C:\Program Files\OCAD\OCAD 11\Ocad11.exe" "M:\Data\Map.cod"
OCAD supporte les paramètres supplémentaires optionnels pour ouvrir la carte à une position voulue et afficher son échelle
-c: centrer la visualisation -s: voir l'échelle
Par exemple:
"C:\Program Files\OCAD\OCAD 11\Ocad11.exe" -c 710000,231000 -s 2500 "M:\Data\Map.cod"
Chapitre précédent: Base de données
Chapitre suivant: Elaboration de parcours de course d'orientation
Retour à la page Accueil