Search

Using MSBATCH

Support

<< Return to Index
Subject: Using MSBATCH
Product: MicroStation/J v07.01.00.62 or higher
Operating System: Windows® 95, Windows 98, Windows NT® 4.0, Windows 2000
Document Number: 8187

Sections:

  1. Introduction
  2. Using MSBATCH
  3. Command Line Parameters
  4. Importing a DWG or DXF using DWGIN
  5. The Dumptables Command Line Parameter
  6. DWGIN Command Line Parameters
  7. Exporting a DWG or DXF using DWGOUT
  8. DWGOUT Command Line Parameters
  9. The Batchfile Parameters

Introduction
MSBATCH has been part of MicroStation for a long time, but because it's initiated from a DOS command prompt many users do not know it exists or if they do, don't know how to use it. MSBATCH is a command line utility that allows special MDL applications called INITAPPs to run outside of MicroStation's graphics environment (note that MicroStation does need to be present in order for the applications to run). There are a number of MDL applications designed to work with MSBATCH:

CGMIN (importing CGM format files)
CGMOUT (exporting CGM format files)
CNVDGN (exporting 2D to 3D and 3D to 2D)
DWGIN (importing DWG and DXF format files)
DWGOUT (exporting DWG and DXF format files)
IGESIN (importing IGES format files)
IGESOUT (exporting IGES format files)
VCADIN (importing VersaCad format files)
RASTCONV (converting between image formats)
MERGE (copy all displayable elements from one design file or cell library to another (and to perform additional processing to effectively merge the source file into the destination file))
RepCell (replace single or multiple cells in a design file, or to update cells in a design with cells of the same name from the active cell library)

This TechNote focuses on the import/export of AutoCAD DWG and DXF files using Windows 95, Windows 98 and Windows NT platforms with MicroStation/J v07.01.00.62 or higher.

If you're using a version of MicroStation prior to MicroStation/J, some of the optional parameters may be different but the overall syntax and usage is the same. There are two MDL applications that are used: dwgin.ma and dwgout.ma. Both MDL applications have a number of command line parameters that can be used to override the default settings and configuration variables in MicroStation. The configuration variables that may need to be addressed are:

MS_DGNOUT Specifies the default folder for exported DGNs. Specifying the outdgn command line parameter will override this variable. The default path for the variable is Bentley\workspace\projects\untitled\out\.
MS_DWGBASIC Specifies or "hard codes" a BASIC macro to be used. It cannot be overwritten and the path is not defined. (This variable is only in MicroStation/J)
MS_DWGDATA Local folder that contains the DWG macro, tables and settingfiles. The default path for the variable is Bentley\home\prefs\dwgdata\.
MS_DWGIN Specifies the default input folder for importing DWGs. The path is not defined.
MS_DWGINSET Specifies the Settings File for importing. This file is needed by MSBATCH because it stores the last used BASIC macro. Specifying the macro command line parameter will override this variable. The default path and file name for the variable is Bentley\home\prefs\dwgdata\dwgin.guiResource.
MS_DWGLOG Specifies the log file destination folder. The log file is an ASCII text file that will contain information such as error messages from the translation. If any problems with a translation are found, it would be a good idea to open this file to verify that the translation proceeded correctly. The default path for the variable is Bentley\workspace\projects\untitled\out\.
MS_DWGOUT Specifies the default output folder for exported DWGs. Specifying the outdwg command line parameter will override this variable. The default path for the variable is Bentley\workspace\projects\untitled\out\.
MS_DWGOUTSET Specifies the Settings File for exporting. This file is needed by MSBATCH because it stores the last used BASIC macro. Specifying the macro command line parameter will override this variable. The default path and file name for the variable is Bentley\home\prefs\dwgdata\dwgout.guiResource.
MS_DWGTABLES Specifies the default location of the mapping tables and BASIC macro. If MS_DWGBASIC is added, it will override MS_DWGTABLES for the location of the BASIC macro. There are command line parameters for most of the mapping tables to override this variable. The default path for the variable is Bentley\home\prefs\dwgdata\. The font and hatch mapping tables have to be in the in the folder this variable points to. The other mapping table's location(s) can be defined in the BASIC macro.
MS_TRANSEED Specifies the default seed file used for DWG translations. In MSBATCH it's needed to determine which seed DGN should be used for importing DWGs/DXFs. Specifying the seeddgn command line parameter will override this variable. The default path and file name for the variable is Bentley\Workspace\system\seed\transeed.dgn.
MS_SHEETSEED Specifies the default sheet (*.s01) seed file. In MSBATCH it's needed to determine which sheet seed DGN should be used for importing DWG/DXF paperspace objects. The default path and file name for the variable is Bentley\Workspace\system\seed\sheetsd.dgn.

Using MSBATCH
MSBATCH is a DOS utility so the first thing we need to do is open a DOS window. Change the current directory to \Bentley\Program\MicroStation\ (cd \Bentley\Program\MicroStation\) .

While using MSBATCH, remember the following rules:

  • Do not have any spaces in the folder or file names (for example, c:\program files & house plans.dgn).
  • Only specify up to 9 parameters in one MSBATCH statement. If more than 9 are used the translation will abort. If more are needed, the batchfile parameter should be used. There is more information at the end of this article that explains the batchfile parameter.
  • Always execute MSBATCH from the root folder of MicroStation.

Command Line Parameters
Command line parameters are variables that define values in an MSBATCH statement. DWGIN and DWGOUT have a list of parameters that can be used for each MDL application. There are certain parameters that need to be in every MSBATCH statement and there are some that can be used to override configuration variables and menu settings in MicroStation. All the needed parameters are the same using MicroStation 95 up to and including the latest release of MicroStation/J.

Importing a DWG or DXF using DWGIN
The syntax to import an AutoCAD DWG is (on a single line):

MSBATCH dwgin input:c:\folder-names\*.dwg outdgn:c:\folder-names\ createdgn 
parameter: value parameter: value parameter: value parameter: value
parameter: value parameter: value
The syntax to import an AutoCAD DXF is (on a single line):
MSBATCH dwgin input:c:\folder-names\*.dxf outdgn:c:\folder-names\ createdgn 
parameter: value parameter: value parameter: value parameter: value
parameter: value parameter: value

MSBATCH: Starts the msbatch.bat batchfile located in the c:\Bentley\Program\MicroStation\ folder.
Dwgin: The MDL application used to import DWG/DXF files (Dwgin.ma).
Input: A command line parameter used with DWGIN (see DWGIN command line parameters below) to define what files are being imported. This parameter is always used.
Outdgn: A command line parameter used with DWGIN (see DWGIN command line parameters below) to define where the imported files will be created. If only one file is being translated you could specify the DGN name. If you're translating multiple files the \ must follow the last folder name. If it's not there all the translated files will import into one file with the last folder name. This parameter is optional. If it's not used, all the translated files will be created in the folder the input: parameter specifies.
Createdgn A command line parameter used with DWGIN (see DWGIN command line parameters below) to specify that if there are existing DGNs in the folder defined by outdgn: with the same name, they will be overwritten. This parameter is optional. If it's not used, MSBATCH will not overwrite existing files with the same name.
Parameter: All additional parameters are optional. One example for using one is specifying the colors: parameter to always attach the AutoCAD color table for all new DGNs. For example,
MSBATCH dwgin input:c:\folder-names\*.dwg outdgn:c:\folder-names\ createdgn colors:acadpalette
Note: All command line parameters except createdgn, createlib, dumptables and savesettings must be followed by a colon. If it's missing the translation will not work.

The Dumptables Command Line Parameter
Using the dumptables parameter will generate an ASCII text file(s) that supplies useful information concerning AutoCAD DWG and DXF file(s) that are selected. This information can be used to customize the import settings and mapping tables to produce an even more accurate translation. This is not a new parameter in MicroStation but it has been enhanced in MicroStation/J. Below is the dumptables parameter syntax for all released versions of MicroStation:

MSBATCH dwgin input:c:\folder-names\*.dwg outdgn:c:\folder-names\ dumptables

This parameter will produce the following information in an ASCII text file(s) that has the same name as the DWG(s) but with a *.dmp extension:

  • Font Names
  • Block Names
  • Layer List
  • Line Type List
  • Dimension Style Names
  • Partial System Vars:
    Version The version of AutoCAD the DWG was created with.
    EXTMIN The minimal x,y or x,y,z coordinate location of the DWG.
    EXTMAX The maximum x,y or x,y,z coordinate location of the DWG.
    LTSCALE The linetype scale of the DWG.
    LUNITS The type of measurement the DWG is using.
    VISRETAIN A system variable that controls dependent layer properties.
  • Pline Information
  • Xref Information
Note: Pline Information and Xref Information will only be created using MicroStation/J.

The dumptable parameter in MicroStation/J has 3 options.

Dumptables:[toFile] Generates the same report as if no option was specified.
Dumptables:[toScreen] Generates the same report as the toTable option but only displays it in the DOS window. Will not produce a text file.
Dumptables:[toTable] This option will create translation mapping tables with the related data needed. The tables still need more information by the user to be used correctly.

Note: The tables that are created will have the same name as the DWG, the name of the table and the extension *.tbl.

[File name]ltype.tbl The linestyle mapping table.
[File name]layer.tbl The layer mapping table.
[File name]font.tbl The font mapping table.
[File name]block.tbl The block mapping table.

DWGIN Command Line Parameters

attributes:[tag|text] Import as tag/text switch
batchfile:[filename] Uses a batchfile for input
blocks:[library|create|components] Controls block import
colors:[acadpalette|match|map] Controls color conversion and the design file color table
colortable:[filename] Specifies a color mapping table
compressfract:[on|off] Compresses fractions
createdgn Overwrites existing DGN files
createlib Overwrites an existing cell library
displayElement[on|off] Display objects as they are created (not applicable)
dumptables[toscreen|tofile|totable] Creates a text file containing all attributes of selected DWGs
frozen:[on|off] Controls translation of frozen layers
input:[filename] Specifies files for import; overrides MS_DWGIN
leveltable:[filename] Specifies a layer mapping table
linestyles:[on|off] Controls the use of custom linestyles
macro:[filename] Runs a MicroStation BASIC macro
mapchars:[on|off] Controls character mapping
outdgn:[filename] Specifies output filename; overrides MS_DGNOUT
outlib:[filename] Specifies cell library name
pausescreen:[on|off] Disables the pause after a batch operation
savesettings Saves the MSBATCH settings to the settingsfile
seeddgn:[filename] Specifies import seed file; overrides MS_TRANSEED
seedlib:[filename] Specifies cell library seed; overrides MS_CELLSEED
settingsfile:[filename] Specifies setting file; overrides MS_DWGINSET
styletable:[filename] Specifies the linestyle mapping table
units:[master|sub] Specifies Working Units to use for importing the file
weightcolor:[filename] Specifies weight-to-color mapping table
weighttable:[filename] Specifies weight mapping table
xrefnest:nestdepth Specifies nesting depth for Xrefs
xresolve:[none|missing|always] Controls automatic translations of Xrefs

Note: All parameters that require a [filename] must also have the full folder path.

Exporting a DWG or DXF using DWGOUT
The syntax to export to an AutoCAD DWG is (on a single line):

MSBATCH dwgout input:c:\folder-names\*.dgn outdwg:c:\folder-names\ createdwg
parameter:value parameter: value parameter:value parameter: value
parameter: value parameter: value
The syntax to export to an AutoCAD DXF is (on a single line):
MSBATCH dwgout input:c:\folder-names\*.dgn outdwg:c:\folder-names\ createdxf
parameter: value parameter: value parameter: value parameter: value
parameter: value parameter: value

MSBATCH: Starts the msbatch.bat batchfile located in the c:\Bentley\Program\MicroStation\ folder.
Dwgout: The MDL application used to export DWG/DXF files (Dwgout.ma).
Input: A command line parameter used with DWGOUT (see DWGOUT command line parameters below) to define what files are being exported. This parameter is always used.
Outdwg: A command line parameter used to define where the exported files will be created. If only one file is being translated you could specify the DWG name. If you're translating multiple files the \ has to follow the last folder name. This parameter is optional. If it's not used, all the translated files will be created in the folder the input: parameter specifies.
Createdwg A command line parameter used with DWGOUT to define that if there are existing files in the folder defined by outdwg: with the same name, they will be overwritten. This parameter is optional. If it's not used, MSBATCH will not overwrite existing files with the same name.
Parameter: All additional parameters are optional. One example for using one is specifying the selfref: parameter to always export self-referenced reference files to merge with the DGN it's referenced to. For example,

MSBATCH dwgout input:c:\folder-names\*.dgn outdwg:c:\folder-names\ createdwg selfref:merge.

Note: If the selfref: parameter is used and the self-reference file needs to be attached to the exported DWG, do not use the Xref setting. Currently all released versions of AutoCAD cannot have self-reference Xrefs. If this setting is used the attachment will be created but AutoCAD does not support this feature so it will be ignored. If the DWG is imported back into MicroStation the file attachment should work correctly.

Note: All command line parameters except createdwg, createdxf and savesettings must be followed by a colon.

DWGOUT Command Line Parameters

batchfile:[filename] Uses a batchfile for input
colors:[256|16|8] Controls number of colors used for export
colortable:[filename] Specifies a color mapping table
createdwg Overwrites existing DWG or DXF files
createdxf Exports as a DXF file
expandfrac:[on|off] Controls the expansion of fractions
input:[filename] Specifies files for export; overrides MS_DEF
leveltable:[filename] Specifies a layer mapping table
linestyle:[line|components] Controls how complex linestyles are exported
linecode:[line|components|polyline] Controls how wide linestyles are exported
mapchars:[on|off] Enables font character mapping
mapcolors:[on|off] Enables color mapping
macro:[filename] Attaches a macro file
outdwg:[filename] Specifies output filename; overrides MS_DWGOUT
outdxf:[complete|minimal|entities] Controls header creation for DXF export
overridelevel:[on|off] Controls the use of level names for export
pausescreen:[on|off] Disables the pause after a batch operation
ref:[ignore|merge|xref] Specifies how reference files are exported
refsourceview:[viewnumber] Specifies the view number 1-8 used to merge reference files
clipref:[ignore|merge|ref] Specifies how clipped reference files are exported
selfref:[ignore|merge|ref] Specifies how self-reference files are exported
seeddwg:[filename] Specifies an AutoCAD prototype drawing to use for export settings
Savesettings Saves settings as defined in the MSBATCH statement to the attached settings file
settingsfile:[filename] Specifies settings file to be attached
shape:[poly(line|face|mesh)] Specifies the entity to use for exporting shapes
sourceview:[viewnumber] Specifies a view to use (view 1 through 8) as the source view for export. If a view number is not selected, Level Symbology will be ignored
splinesegs:[number] Specifies the interval of spline segments
styletable:[filename] Specifies the linestyle mapping table
surfu:[number] Specifies the number of segments in the U dir
surfv:[number] Specifies the number of segments in the V dir
units:[master|sub] Specifies the working unit to use for exporting the file
version:[2.6|9|10|11|12] Specifies the AutoCAD version number for DWG output
weightcolortable:[filename] Specifies the weight-to-color mapping table
weighttable:[filename] Specifies the weight mapping table

Note: All parameters that require a [filename] must also have the full folder path.

The Batchfile Parameters
This parameter will allow users to specify files from different folders and/or use different, optional parameters in one MSBATCH execution. The various MSBATCH statements are placed inside an ASCII text file--MSBATCH can then execute this text file. This parameter is also useful if a lot of files need to be translated.

The syntax to import an AutoCAD DWG using the Batchfile parameter is:

MSBATCH dwgin batchfile:example.bat

The syntax to export an AutoCAD DWG using the Batchfile parameter is:

MSBATCH dwgout batchfile:example.bat
The example.bat file name can be any name the user wants. Typically *.bat or *.txt is used. The syntax of a statement to be placed in the ASCII text file is:

-iinput:c:\folder-names\*.dwg -ioutdgn:c:\folder-names\ -icreatedgn
or
-iinput:c:\folder-names\*.dgn -ioutdwg:c:\folder-names\ -icreatedwg

These statements need all of the required parameters that MSBATCH normally uses. The main difference is that there has to be a -i in front of all the parameters for it to work. You can have as many statements as needed.

 

How useful was this page?
less
  more
Suggest new content or let us know how we can improve this content (optional):

<< E-mail this page