GuidoScript scripts/dtmutilities.tcl
proc validateFields { save_file attribute } {
set file "[ $save_file getCurrentValue ]"
set attr "[ $attribute getCurrentValue ]"
if { $attr == "" && $file == "N" } {
GuidoMessage warning MUST_SAVE_PARTIAL_FILE
return 0
}
return 1
}
proc validateFileName { nameFld } {
set name "[$nameFld getCurrentValue]"
set val [ file exists $name ]
if { $val == 0 } {
GuidoMessage warning FILE_DOES_NOT_EXIST $name
return 0
}
if {[string first ".bpp" $name] == -1} {
GuidoMessage warning INVALID_PARTIAL_FILE
return 0
}
return $val
}
proc setComboValues { } {
global constraint_type
set buffer [ GuidoExecServer GetBlockModelParameters {} ]
set type 0
set rotated [ GuidoGetParamBufferValue $buffer Rotated]
if {$rotated == "true"} {
set plunge [ GuidoGetParamBufferValue $buffer Rotation(1)]
set dip [ GuidoGetParamBufferValue $buffer Rotation(2)]
if {[expr abs($plunge) > 0.01]} {
set type 1
}
if {[expr abs($dip) > 0.01]} {
set type 1
}
}
if {$type == 0} {
$constraint_type setValues "STRING" "3DM" "DTM" "BETWEEN DTMS" "PLANE" "PLANE EQ" "PERCENT FILE"
} else {
$constraint_type setValues "STRING" "3DM" "DTM" "PLANE" "PLANE EQ" "PERCENT FILE"
GuidoMessage warning BM_ROT_BETWEEN_DTMS
}
}
GuidoApp check_bm "CHECK BM CONNECTED"
set result [$check_bm invoke]
$check_bm destroy
if { $result == "0" } {
GuidoForm PartialPercentages {
-default_buttons
-label "Block Model Partial Percentage Calculation"
-tip BM_PARTIAL_PERCENTAGES_TIP
-layout BoxLayout Y_AXIS
-help_id 949
-action initial {[setComboValues ]}
GuidoPanel main {
-layout BoxLayout Y_AXIS
GuidoPanel left {
-layout CentreLineLayout
GuidoComboBox constraint_type {
-label "Constraint to apply"
-display_length 17
-exclusive true
-null false
-max_length 12
-default "STRING"
-tip  BM_CONSTRAINT_TYPE_TIP
}
GuidoBMAttributeBrowser Attribute {
-label "Attribute to calculate"
-display_length 17
-max_length BM_MAX_ATT_NAME_LEN
-null true
-format none
-translate none
-exclusive true
-attribute_types real
-tip BM_BLOCK_ATTRIBUTE_TIP
}
GuidoComboBox sub_precision {
-label "Precision"
-display_length 17
-exclusive true
-null false
-value_in "1" "2" "3" "4" "5"
-default "3"
-dependency { "[ $constraint_type getCurrentValue ]" != "PERCENT FILE"}
-tip BM_BLOCK_PRECISION_TIP
}
}
}
GuidoFiller filler_height_1 {
-height 1
}
GuidoPanel overlay_panel {
-layout OverlayLayout
GuidoPanel string {
-border etched true
-dependency {"[ $constraint_type getCurrentValue]" == "STRING"}
-layout CentreLineLayout
GuidoFileBrowserField stringFile {
-display_length 20.5
-label "String file"
-format none
-null false
-max_length 256
-file_mask *.str
-link stringID
}
GuidoField stringID {
-display_length 20.5
-label "ID range"
-format none
-max_length 32
-translate mixed
}
GuidoLabel inside_label {
-label Inside
}
GuidoCheckBox inside {
-default true
-selected_value Y
-unselected_value N
}
GuidoComboBox extentDirection {
-display_length 1
-format none
-label "Extent"
-null false
-value_in X Y Z
}
GuidoLabel option_fields_label {
-font_style bold
-label "Optional fields"
}
GuidoFiller filler {
}
GuidoField extentLowerbound {
-display_length 20.5
-label "Lower Bound"
-format double
-max_length 10
}
GuidoField extentUpperbound {
-display_length 20.5
-label "Upper Bound"
-format double
-max_length 10
}
GuidoField stringRange {
-display_length 20.5
-format none
-label "String range"
-max_length 32
}
GuidoField segmentRange {
-display_length 20.5
-format none
-label "Segment range"
-max_length 32
}
}
GuidoPanel 3dmAll {
-dependency {"[ $constraint_type getCurrentValue]" == "3DM"}
-layout BoxLayout Y_AXIS
GuidoLabel warnLabel {
-label "Intersecting solids may give an incorrect result"
}
GuidoPanel 3dm {
-border etched true
-layout CentreLineLayout
GuidoFileBrowserField threeDMLocation {
-display_length 20
-label "3DM file"
-format none
-file_mask *.dtm
-null false
-max_length 256
-link threeDMid
}
GuidoField threeDMid {
-display_length 20
-label "Id range"
-format range
-max_length 256
}
GuidoLabel inside3DM_label {
-label Inside
}
GuidoCheckBox inside3DM {
-default true
-selected_value Y
-unselected_value N
}
GuidoLabel option_fields_label2 {
-font_style bold
-label "Optional fields"
}
GuidoFiller filler {
}
GuidoField objectRange {
-display_length 20
-format range
-label "Object range"
-max_length 32
}
GuidoField trisolationRange {
-display_length 20
-format range
-label "Trisolation range"
-max_length 32
}
}
}
GuidoPanel dtm {
-border etched true
-dependency {"[ $constraint_type getCurrentValue]" == "DTM"}
-layout CentreLineLayout
GuidoFileBrowserField dtmFile {
-display_length 20
-label "DTM file"
-format none
-null false
-max_length 256
-file_mask *.dtm
}
GuidoLabel abovedtm_label {
-label Above
}
GuidoCheckBox abovedtm {
-default true
-selected_value Y
-unselected_value N
}
GuidoLabel option_fields_label1 {
-font_style bold
-label "Optional fields"
}
GuidoFiller filler {
}
GuidoField objectNumber {
-display_length 20
-format integer
-label "Object number"
-max_length 32
}
GuidoField trisolationNumber {
-display_length 20
-format integer
-label "Trisolation number"
-max_length 32
}
}
GuidoPanel betweenDtm {
-border etched true
-dependency {"[ $constraint_type getCurrentValue]" == "BETWEEN DTMS"}
-layout CentreLineLayout
GuidoFileBrowserField topDtmFile {
-display_length 16
-label "Top DTM file"
-format none
-null false
-max_length 256
-file_mask *.dtm
-action valueChanged {[fill_triobject_trisolation_details $topDtmFile $top_obj_id $top_obj_name $top_trisol_id $top_trisol_name]}
}
GuidoComboBox top_obj_id {
-display_length 5
-format integer
-max_length 32
-translate none
-exclusive true
-label "Top Object ID"
-tip "04949_TIP_1"
-action valueChanged {[fill_triobject_details $topDtmFile $top_obj_id $top_obj_name $top_trisol_id $top_trisol_name "false" "false"]}
}
GuidoLabel top_obj_name {}
GuidoFiller filler {
-width 0.2
}
GuidoComboBox top_trisol_id {
-display_length 5
-format integer
-max_length 32
-translate none
-exclusive true
-label "Top Trisolation ID"
-tip "04949_TIP_2"
-action valueChanged {[fill_trisolation_details $topDtmFile $top_obj_id $top_trisol_id $top_trisol_name "true" "false"]}
}
GuidoFiller filler {
-width 0.2
}
GuidoLabel top_trisol_name {}
GuidoFileBrowserField bottomDtmFile {
-display_length 16
-label "Bottom DTM file"
-format none
-null false
-max_length 256
-file_mask *.dtm
-action valueChanged {[fill_triobject_trisolation_details $bottomDtmFile $bot_obj_id $bot_obj_name $bot_trisol_id $bot_trisol_name]}
}
GuidoComboBox bot_obj_id {
-display_length 5
-format integer
-max_length 32
-translate none
-exclusive true
-label "Bottom Object ID"
-tip "04949_TIP_1"
-action valueChanged {[fill_triobject_details $bottomDtmFile $bot_obj_id $bot_obj_name $bot_trisol_id $bot_trisol_name "false" "false"]}
}
GuidoFiller filler {
-width 0.2
}
GuidoLabel bot_obj_name {}
GuidoComboBox bot_trisol_id {
-display_length 5
-format integer
-max_length 32
-translate none
-exclusive true
-label "Bottom Trisolation ID"
-tip "04949_TIP_2"
-action valueChanged {[fill_trisolation_details $bottomDtmFile $bot_obj_id $bot_trisol_id $bot_trisol_name "true" "false"]}
}
GuidoFiller filler {
-width 0.2
}
GuidoLabel bot_trisol_name {}
GuidoFileBrowserField boundaryStringFile {
-display_length 16
-label "Boundary String File"
-format none
-null false
-max_length 256
-file_mask *.str
}
GuidoField stringNumber {
-display_length 16
-format integer
-label "Boundary String Number"
-max_length 32
}
GuidoField segmentNumber {
-display_length 16
-format integer
-label "Boundary Segment Number"
-max_length 32
}
}
GuidoPanel plane_eq {
-border etched true
-dependency {"[ $constraint_type getCurrentValue]" == "PLANE EQ"}
-layout BoxLayout Y_AXIS
GuidoLabel equation_label {
-label "Equation of plane:"
}
GuidoFiller filler_height_1 {
-height 1
}
GuidoPanel equation_panel {
-layout BoxLayout X_AXIS
GuidoField x {
-display_length 5
-format none
-max_length 16
-translate upper
}
GuidoLabel x_plus_label {
-label "X +"
}
GuidoField y {
-display_length 5
-format none
-max_length 32
-translate upper
}
GuidoLabel y_plus_label {
-label "Y + "
}
GuidoField z {
-display_length 5
-format none
-max_length 32
-translate upper
}
GuidoLabel z_minus_label {
-label "Z - "
}
GuidoField equals {
-display_length 5
-format none
-max_length 32
-translate upper
}
GuidoLabel equalsLabel {
-label " = 0"
}
}
GuidoFiller filler_height_1 {
-height 1
}
GuidoPanel  above_panel {
-layout CentreLineLayout
GuidoLabel above_label1 {
-label "Above"
}
GuidoCheckBox above_plane {
-default true
-selected_value Y
-unselected_value N
}
}
}
GuidoPanel plane {
-border etched true
-dependency {"[ $constraint_type getCurrentValue]" == "PLANE"}
-layout CentrelineLayout
GuidoComboBox direction {
-display_length 2
-label "Direction"
-format none
-value_in X Y Z
-exclusive true
-null false
-max_length 3
-translate upper
}
GuidoFiller filler_width_1 {
-width 1
}
GuidoFiller filler_height_1 {
-height 1
}
GuidoField value {
-display_length 5
-format none
-label "Co-ordinates"
-max_length 5
-translate upper
}
GuidoFiller filler_height_1 {
-height 1
}
GuidoFiller filler_height_1 {
-height 1
}
GuidoLabel above_label4 {
-label "Above"
}
GuidoCheckBox above {
-default true
-selected_value Y
-unselected_value N
}
}
GuidoPanel partial_file {
-border etched true
-dependency {"[ $constraint_type getCurrentValue]" == "PERCENT FILE" }
-layout CentrelineLayout
GuidoFileBrowserField partialFile {
-display_length 23
-label "Partial file"
-format none
-null false
-max_length 256
-file_mask *.bpp
-validation {[validateFileName $partialFile ]}
}
GuidoLabel insideConstraint_label {
-label Inside
}
GuidoCheckBox insideConstraint {
-default true
-selected_value Y
-unselected_value N
}
}
}
GuidoPanel save_partial_file {
-layout BoxLayout Y_AXIS
GuidoPanel check_panel {
-layout BoxLayout X_AXIS
-dependency { "[ $constraint_type getCurrentValue ]" != "PERCENT FILE"}
GuidoCheckBox save_file {
-label "Save partial percent as file?"
-default N
-selected_value Y
-unselected_value N
-display_length 8
-tip BM_SAVE_PERCENT_TIP
-validation {"[validateFields $save_file $Attribute]"}
}
}
GuidoPanel f_panel {
-layout BoxLayout X_AXIS
-dependency { "[ $save_file getCurrentValue ]" == "Y" &&
"[ $constraint_type getCurrentValue ]" != "PERCENT FILE"}
GuidoLabel l {
-label "File Name"
}
GuidoFiller f66 {
-width 1
}
GuidoFileBrowserField partial_file_name {
-display_length 16
-file_access write overwrite_validation
-format none
-null false
-max_length 256
-file_mask *.bpp
}
}
}
}
set status ""
$Attribute updateBrowserList
set attr ""
set attr "[ $Attribute getCurrentValue ]"
$PartialPercentages interact
set status [ $PartialPercentages getStatus ]
if { $status == "apply" } {
set type ""
set type [ $constraint_type getCurrentValue ]
set attr "[ $Attribute getCurrentValue ]"
GuidoApp app "PARTIAL PERCENTAGES"
$app setParam constraint_type $type
$app setParam attribute $attr
$app setParam precision [ $sub_precision getCurrentValue ]
$app setParam save [ $save_file getCurrentValue ]
$app setParam save_file_name [ $partial_file_name getCurrentValue ]
if { $type == "STRING" } {
$app setParam file [ $stringFile getCurrentValue ]
$app setParam id [ $stringID getCurrentValue ]
$app setParam inside [ $inside getCurrentValue ]
$app setParam direction [ $extentDirection getCurrentValue ]
$app setParam lbound [ $extentLowerbound getCurrentValue ]
$app setParam ubound [ $extentUpperbound getCurrentValue ]
$app setParam range [ $stringRange getCurrentValue ]
$app setParam segment [ $segmentRange getCurrentValue ]
} elseif { $type == "DTM" } {
set dtmFileName ""
set dtmFileName [ $dtmFile getCurrentValue ]
set locationAndIdLength [string length $dtmFileName ]
incr locationAndIdLength -5
set i $locationAndIdLength
while {$i > -1 } {
if { [string match {[1234567890]*} [string index $dtmFileName $i] ] == 0 } {
break
}
incr i -1
}
if { $i > $locationAndIdLength } {
$app setParam id 0
} else {
$app setParam id [string range $dtmFileName [expr $i + 1] $locationAndIdLength]
}
$app setParam file  [string range $dtmFileName 0 $i]
$app setParam above [ $abovedtm getCurrentValue ]
$app setParam object_number [ $objectNumber getCurrentValue ]
$app setParam trisol_number [ $trisolationNumber getCurrentValue ]
} elseif { $type == "3DM" } {
$app setParam file [ $threeDMLocation getCurrentValue ]
$app setParam id [ $threeDMid getCurrentValue ]
$app setParam inside [ $inside3DM getCurrentValue ]
$app setParam object_range [ $objectRange getCurrentValue ]
$app setParam trisol_range [ $trisolationRange getCurrentValue ]
} elseif { $type == "PLANE EQ" } {
$app setParam x [ $x getCurrentValue ]
$app setParam y [ $y getCurrentValue ]
$app setParam z [ $z getCurrentValue ]
$app setParam equals [ $equals getCurrentValue ]
$app setParam above_plane [ $above_plane getCurrentValue ]
} elseif { $type == "PLANE" } {
$app setParam direction [ $direction getCurrentValue ]
$app setParam coordinates [ $value getCurrentValue ]
$app setParam above [ $above getCurrentValue ]
} elseif { $type == "PERCENT FILE" } {
$app setParam use_percent_file [ $partialFile getCurrentValue ]
$app setParam inside [ $insideConstraint getCurrentValue ]
} elseif { $type == "BETWEEN DTMS" } {
$app setParam topDtmFile [ $topDtmFile getCurrentValue ]
$app setParam top_obj_id [ $top_obj_id getCurrentValue ]
$app setParam top_trisol_id [ $top_trisol_id getCurrentValue ]
$app setParam bottomDtmFile [ $bottomDtmFile getCurrentValue ]
$app setParam bot_obj_id [ $bot_obj_id getCurrentValue ]
$app setParam bot_trisol_id [ $bot_trisol_id getCurrentValue ]
$app setParam boundaryStringFile [ $boundaryStringFile getCurrentValue ]
$app setParam stringNumber [ $stringNumber getCurrentValue ]
$app setParam segmentNumber [ $segmentNumber getCurrentValue ]
}
set result [$app invoke]
$app destroy
}
$PartialPercentages hide
}
$PartialPercentages destroy
}
