Mapping File Examples

The following mapping file example shows how the Multi-Reader is used to combine road ,water, and contour features from three Design files, located in different folders, into a single Design file. This example also illustrates how to use generic and specific keywords to configure the individual readers. In particular, notice how the WATER reader is specifically configured to use sub units while the ROAD and CONTOUR reader use master units (which has been selected as the default for this run). (Although it is not directly relevant to this example, it is interesting to note that the IGDS Writer uses the default master units setting as well.)

#-------------------------------------------------------------------------
# Set up the Multi-Reader to explicitly open three Design readers
READER_TYPE MULTI_READER
MULTI_READER_TYPE{0} IGDS
MULTI_READER_KEYWORD{0} ROAD
MULTI_READER_TYPE{1} IGDS
MULTI_READER_KEYWORD{1} WATER
MULTI_READER_TYPE{2} IGDS
MULTI_READER_KEYWORD{2} CONTOUR

#-------------------------------------------------------------------------
# Change default units for all Design readers and writers
IGDS_UNITS IGDS_MASTER_UNITS

#-------------------------------------------------------------------------
# Specific configuration for first Design reader
ROAD_DATASET "C:/Design/Road/road.dgn"

#-------------------------------------------------------------------------
# Specific configuration for second Design reader
WATER_DATASET "C:/Design/Water/water.dgn"
WATER_UNITS IGDS_SUB_UNITS

#-------------------------------------------------------------------------
# Specific configuration for third Design reader
CONTOUR_DATASET "C:/Design/Contour/contour.dgn"

#--------------------------------------------------------------------------
# Set up the Design writer
WRITER_TYPE IGDS
IGDS_SEED_FILE "C:/Design/seed2d_ft.dgn"
IGDS_DATASET "C:/Design/Output/merged.dgn"

#--------------------------------------------------------------------------
# Finally, just one correlation line to do it all
MULTI_READER *
IGDS *

The following mapping file example shows how the Multi-Reader is used to merge data from datasets of different types. It uses the Multi-Reader to combine a Shape dataset (folder) with two AutoCAD datasets (files) into a single Design dataset.

#-------------------------------------------------------------------------
# Set up the Multi-Reader to explicitly open a Shape reader and
# two AutoCAD readersREADER_TYPE MULTI_READER
MULTI_READER_TYPE{0} SHAPE
MULTI_READER_TYPE{1} DWG
MULTI_READER_KEYWORD{1} DWG_0
MULTI_READER_TYPE{2} DWG
MULTI_READER_KEYWORD{2} DWG_1

#-------------------------------------------------------------------------
# Set up the Shape reader
SHAPE_DATASET "C:/Shape"

#-------------------------------------------------------------------------
# Set up the first AutoCAD reader
DWG_0_DATASET "C:/AutoCAD/Tile1/tile1.dwg"

#-------------------------------------------------------------------------
# Set up the second AutoCAD reader
DWG_1_DATASET "C:/AutoCAD/Tile2/tile2.dwg"

#--------------------------------------------------------------------------
# Transform features to IGDS and put them in Level 1
FACTORY_DEF * TeeFactory \
INPUT FEATURE_TYPE * \
@Transform(&multi_reader_type,IGDS) \
@FeatureType(1) \
OUTPUT FEATURE_TYPE *

#--------------------------------------------------------------------------
# Set up the Design writer
WRITER_TYPE IGDS
IGDS_SEED_FILE "C:/Design/seed2d_ft.dgn"
IGDS_DATASET "C:/Design/Output/merged.dgn"

#--------------------------------------------------------------------------
# Finally, just one correlation line to do it all
MULTI_READER *
IGDS *

The following mapping file example uses the Multi-Reader to combine Level 2 from all the Design files in a given folder into a single Design File. Notice how the Design file unit specification is given using the reader keyword IGDS, which applies to all the individual Design file readers created by the Multi-Reader. This example illustrates how to change the Multi-Reader keyword to INPUT, which is then used in the Multi-Reader configuration and correlation line. This example also shows how to use MULTI_READER_VERBOSE in combination with MULTI_READER_TYPE{*} to request that a detailed information log be created for each reader.

Note: If the root folder contains anything other than Design files, this mapping file will report an error.

#--------------------------------------------------------------------------
# Set up the Multi-Reader to open a Design reader for
# each Design file in the root folder
READER_TYPE MULTI_READER
READER_KEYWORD INPUT
INPUT_TYPE{*} IGDS
INPUT_DATASET "C:/Design/Data"
INPUT_VERBOSE YES

#-------------------------------------------------------------------------
# Set up all the Design readers\
IGDS_UNITS IGDS_MASTER_UNITS

#--------------------------------------------------------------------------
# Set up the Design writer
WRITER_TYPE IGDS
WRITER_KEYWORD OUTPUT
OUTPUT_SEED_FILE "C:/Design/seed2d_ft.dgn"
OUTPUT_DATASET "C:/Design/Output/merged.dgn"

#--------------------------------------------------------------------------
# Weed out the levels we don't want, keep only this level:
MACRO SELECTED_LEVEL 2
FACTORY_DEF * TestFactory \
FACTORY_NAME "Level Weeder" \
INPUT FEATURE_TYPE * \
TEST @FeatureType() == $(SELECTED_LEVEL) \
OUTPUT PASSED FEATURE_TYPE *

#--------------------------------------------------------------------------
# Finally, just one correlation line to do it all
INPUT *
OUTPUT *

This more advanced mapping file example shows how to use the Multi-Reader in combination with a Tcl script to merge all the Design files located in the subfolders of some root folder into a single Design file. When the Tcl code executes, it dynamically generates the Multi-Reader lines for each file it finds. Variations on this mapping files could be used to read from other kinds of folder structures.

#--------------------------------------------------------------------------
# Set up a multi-reader
READER_TYPE MULTI_READER
# Generate MULTI_READER lines for all Design files in all the subfolders
# of the root folder
INCLUDE [ \
set allfiles [glob "C:/Design/*/*.dgn"]; \
set count 0; \
foreach name $allfiles { \
puts "MULTI_READER_TYPE{$count} IGDS"; \
puts "MULTI_READER_KEYWORD{$count} IGDS_$count"; \
puts "IGDS_${count}_DATASET \"$name\""; \
incr count; \
} ]
#--------------------------------------------------------------------------
# Set up the writer
WRITER_TYPE IGDS
WRITER_KEYWORD IGDS_OUT
IGDS_OUT_SEED_FILE "C:/Design/seed2d_ft.dgn"
IGDS_OUT_DATASET "C:/Design/Output/merged.dgn"

#--------------------------------------------------------------------------
# Finally, just one correlation line to do it all
MULTI_READER *
IGDS_OUT *