GuidoScript scripts/dtmutilities.tcl
proc populateLayerNames {cad_file cadLayer layerTable surpacLayer hiddenData hatchPatterns} {
$surpacLayer removeAllItems
set fileName [$cad_file getCurrentValue]
set values ""
if {"$fileName" != ""} {
set buffer [ GuidoExecServer populateLayerNames [subst {file = "$fileName" }] ]
set status [GuidoGetParamBufferValue $buffer status]
if {$status >= 0} {
set numberOfRows [ GuidoGetParamBufferValue $buffer "LayerCount" ]
$layerTable setInitialRows $numberOfRows 1 $numberOfRows
for {set row 0} {$row < $numberOfRows} {incr row} {
set next "SurpacLayer($row)"
set nextLayer [ GuidoGetParamBufferValue $buffer $next ]
lappend values "$nextLayer"
}
eval [concat {$surpacLayer} {setValues} $values ]
for {set row 0} {$row < $numberOfRows} {incr row} {
set next "CadLayer($row)"
set nextLayer [ GuidoGetParamBufferValue $buffer $next ]
$cadLayer setCurrentValue $row $nextLayer
}
for {set row 0} {$row < $numberOfRows} {incr row} {
set next "SurpacLayer($row)"
set nextLayer [ GuidoGetParamBufferValue $buffer $next ]
$surpacLayer setCurrentValue $row $nextLayer
}
set ext [file extension $fileName]
if {$ext == ".dgn" || $ext == ".DGN"} {
$hiddenData setInputAllowed false
$hatchPatterns setInputAllowed false
} else {
$hiddenData setInputAllowed true
$hatchPatterns setInputAllowed true
}
} else {
$layerTable setInitialRows 1 1 500
$cadLayer setCurrentValue 0 ""
}
}
}
proc checkUncheckAll {checkAll layerTable load} {
set tickAll [$checkAll getCurrentValue]
set numberOfRows [$layerTable getRowCount]
for {set row 0} {$row < $numberOfRows} {incr row} {
if {$tickAll == "Y"} {
$load setCurrentValue $row "Y"
} else {
$load setCurrentValue $row "N"
}
}
}
GuidoForm CadImport {
-default_buttons
-help_id 1630
-label "Import AutoCAD or Microstation file into multiple layers"
-layout BoxLayout Y_AXIS
-tip "CAD_IMPORT_TIP_1"
GuidoPanel CadImport1 {
-border etched true
-layout CentreLineLayout
GuidoPanel CadImport1a {
-layout CentreLineLayout
GuidoFileBrowserField cad_file {
-display_length 22
-file_mask *.dwg *.dxf *.dgn
-format none
-label "File"
-max_length 252
-tip "CAD_IMPORT_TIP_2"
-translate lower
-extension true
-file_access read
-null false
}
}
GuidoButton scan_file {
-caption "Scan file"
-height 1
-selected_value "scan"
-tip "CAD_IMPORT_TIP_3"
-visible true
}
}
GuidoPanel borderLayout {
-layout borderlayout
GuidoTabbedPane tabPane {
GuidoPanel CadImport2 {
-label Layers
-layout BoxLayout Y_AXIS
-position centre
GuidoPanel CadImport2a {
-label "Layer information"
-border etched true
-layout BoxLayout Y_AXIS
GuidoPanel CadImport3 {
-border etched false
-layout BoxLayout X_AXIS
GuidoPanel CadImport3a {
-position West
-width 21
-layout BoxLayout X_AXIS
GuidoFiller fill1 {
-width 3.4
}
GuidoPanel checkAllPanel {
-layout CentreLineLayout
GuidoCheckBox checkAll {
-default true
-selected_value Y
-tip "CAD_IMPORT_TIP_4"
-unselected_value N
}
GuidoLabel checkAllLabel {
-height 1
-label "CAD_IMPORT_CHECK_ALL"
}
}
}
GuidoPanel CadImport3b {
-width 20
-position East
-layout BoxLayout X_AXIS
GuidoPanel defaultLayerPanel {
-layout CentreLineLayout
GuidoComboBox defaultLayer {
-display_length 12
-format none
-exclusive false
-label "CAD_IMPORT_MERGE_LAYER_NAME"
-max_length APP_MAX_LAYER_NAME_LENGTH
-tip "CAD_IMPORT_TIP_5"
}
}
GuidoFiller fill2 {
-width 1.6
}
}
}
GuidoPanel borderLayout {
-layout borderlayout
GuidoScrollPane layerScroll {
-height 20
-border etched false
GuidoTable layerTable {
-instances 1 1 500
-interactive false
-position centre
GuidoCheckBox load {
-default true
-label Load
-selected_value Y
-tip "CAD_IMPORT_TIP_6"
-unselected_value N
-next_focus surpacLayer
}
GuidoField cadLayer {
-display_length 20
-format none
-label "CAD Layer"
-input false
-max_length APP_MAX_LAYER_NAME_LENGTH
-tip "CAD_IMPORT_TIP_7"
-translate none
}
GuidoComboBox surpacLayer {
-display_length 16
-format none
-exclusive false
-label "Import layer name"
-max_length APP_MAX_LAYER_NAME_LENGTH
-tip "CAD_IMPORT_TIP_8"
}
}
}
}
}
}
GuidoPanel CadImport4 {
-label Options
-layout BoxLayout X_AXIS
-position centre
GuidoPanel CadImport5 {
-border etched false
-layout CentreLineLayout
GuidoCheckBox importTextArrows {
-default true
-selected_value Y
-label "AUTOCAD_IMPORT_TEXT"
-tip "AUTOCAD_IMPORT_TEXT_TIP"
-unselected_value N
}
GuidoCheckBox importStyles {
-default true
-selected_value Y
-label "AUTOCAD_IMPORT_STYLES"
-tip "AUTOCAD_IMPORT_STYLES_TIP"
-unselected_value N
}
GuidoCheckBox breakSegments {
-default true
-label "AUTOCAD_BREAK_SEGMENTS"
-selected_value Y
-tip "AUTOCAD_BREAK_SEGMENTS_TIP"
-unselected_value N
}
GuidoCheckBox hiddenData {
-default false
-selected_value Y
-label "AUTOCAD_IMPORT_HIDDEN"
-tip "AUTOCAD_IMPORT_HIDDEN_TIP"
-unselected_value N
}
GuidoCheckBox hatchPatterns {
-default false
-selected_value Y
-label "AUTOCAD_IMPORT_HATCH"
-tip "AUTOCAD_IMPORT_HATCH_TIP"
-unselected_value N
}
}
}
}
}
$defaultLayer setActionCallback initial {[getSurpacLayerNames $defaultLayer]}
$scan_file    setActionCallback valueChanged {[populateLayerNames $cad_file $cadLayer $layerTable $surpacLayer $hiddenData $hatchPatterns]}
$checkAll     setActionCallback valueChanged {[checkUncheckAll $checkAll $layerTable $load]}
}
