'---------------------------------------------- '---------Creation Information----------------- '---------------------------------------------- ' 'Name: draininput 'Author: Cindy How 'Date: 5/97 ' '---------------------------------------------- '------------Purpose/Description--------------- '---------------------------------------------- ' 'This script will take use the node and branch 'theme of the ISBL system and begin to create the input 'file by describing the connectivity as naUTilus 'requires. It should be run after sortpoint. ' 'The connectivity carried over from AutoCad makes 'this script possible, as each line has a preserved 'direction. ' 'Note: Elbow drains run to branches and on line 'drains are connected to nodes. ' '----------------------------------------------- '-------------------Input----------------------- '----------------------------------------------- ' '1. Attribute table for the theme inodes '2. Attribute table for the theme ibranch ' '----------------------------------------------- '------------------Output----------------------- '----------------------------------------------- ' '1. New table called drains.dbf holding the information ' on drains needed to create part of the naUTilus ' input file. ' ' '----------------------------------------------- '---------Get Initial Information--------------- '----------------------------------------------- TheView = av.getActiveDoc TheTheme = theView.FindTheme("inodes.shp") NodeTab = theTheme.GetFtab BrTheme = theView.Findtheme("ibranch.shp") BrTab = BrTheme.GetFtab TypeFld = NodeTab.FindField("Node_Type") NodeFld = NodeTab.FindField("Node") BranchFld = NodeTab.FindField("Arc_") InodeFld = NodeTab.FindField("Inode") TNodeFld = BrTab.FindField("Tnode_") FnodeFld = BrTab.FindField("Fnode_") '----------------------------------------------- '-----Define fields for and create new table---- '----------------------------------------------- TabName = "drains.dbf".asFilename InTab = Vtab.MakeNew(TabName,dBase) RefFld = Field.make("ISBL_ref",#Field_short,4,0) 'inodes.shp "inodes" number for reference DtypeFld = Field.make("Drain_Type",#Field_short,4,0) DConnectFld = Field.make("Connectivity",#Field_short,4,0) DFlowFld = Field.Make("Flow_rate",#Field_double,8,4) DtempFld = Field.make("Temperature",#Field_float,8,2) DconcFld = Field.Make("Concentration",#Field_double,8,4) DdiamFld = Field.Make("Diameter",#Field_double,8,4) DsealFld = Field.Make("Sealed",#Field_short,4,0) DOilFld = Field.Make("Oil_frac",#Field_double,8,4) InTab.AddFields({RefFld,Dtypefld,dconnectfld,dflowfld,dtempfld,dconcfld,ddiamfld,dsealFld,doilFld}) '------------------------------------------------ '------Fill new table with connectivity data----- '------------------------------------------------ i = 0 For each rec in NodeTab InTab.addrecord Inode = NodeTab.ReturnValue(InodeFld,rec) InTab.SetValue(RefFld,rec,Inode) TypeCheck = NodeTab.ReturnValue(TypeFld,i) if (TypeCheck = -1) then 'Elbow drain InTab.SetValue(DtypeFld,i,1) ToBranch = NodeTab.ReturnValue(BranchFld,rec) InTab.SetValue(DConnectFld,i,ToBranch) else InTab.SetValue(DtypeFld,i,2) 'on line drain Connode = NodeTab.ReturnValue(NodeFld,i) InTab.SetValue(DconnectFld,i,connode) end i = i +1 'total number of inodes = i end '------------------------------------------------- '----------------Find Terminal node--------------- '------------------------------------------------- '(The last node in the ArcView theme is not considered the last 'node by naUTilus. It is not even numbered in the naUTilus 'numbering scheme. Therefore, the node immediately previous 'to the last ArcView node is the naUTilus "terminal node".) For each rec in InTab EndCheck = InTab.ReturnValue(DConnectFld,rec) If (EndCheck = -1) then RefNum = InTab.ReturnValue(RefFld,rec) RefNum = RefNum - 1 ArcNum = NodeTab.ReturnValue(BranchFld,refnum) 'ArcNum (from previous line) is the last branch in the system) - by both numbering systems arcnum = arcnum -1 TermNodeNtab = BrTab.ReturnValue(FnodeFld,arcnum) num = TermNodeNtab - 1 TermNodeInTab = NodeTab.ReturnValue(NodeFld,num) 'last node in system 'Remove record of ArcView last node (not numbered in naUTilus system) from drains.dbf InTab.RemoveRecord(rec) else end end '----------------------------------------------- '--------------Input data to table-------------- '----------------------------------------------- deflt = MsgBox.Input("Is this an open or closed system? 1 = Open/Mixed, 2 = Closed","User Input","1") deflt = deflt.AsNumber If (deflt = 1) then scheck = 1 elseif (deflt = 2) then scheck = 2 else MsgBox.Info("That is not a valid choice","Invalid") exit end For each record in InTab InTab.SetValue(DSealFld, record,scheck) end labels = {"Diameter (m)", "Temperature (C)"} defaults = {"0.25","20"} OutList = MsgBox.MultiInput("Enter the default drain diameter and temperature","User Input",labels,defaults) NewDiam = OutList.Get(0).AsNumber NewTemp = OutList.Get(1).AsNumber For each record in InTab InTab.SetValue(DDiamFld,record,NewDiam) InTab.SetValue(DTempFld,record,NewTemp) end TheTab = Table.Make(InTab) TheTab.SetName("drains.dbf") MsgBox.Info("Click on the drains you wish to edit (change sealed/unsealed, enter flow data).","User Input")