'*** This script creates a point file and adds a point and data to it Script.The.SetNumberFormat( "d" ) theView = av.GetActiveDoc '***********Create date-dependent filename*********** '**************************************************** today = Date.Now today.SetFormat( "yyMMdd" ) 'today.Setformat ( "M, D, yyyy") a = today.AsString b = "H20" c = b+a d = FileName.Make( c ) e = ".shp" f = c+e ' hr991204.shp for instance '******If a theme in the view is being edited, Stop Editing it before creating new theme**** 'p = theView.GetDisplay.ReturnUserPoint '******************************************************************************************* theTheme = theView.FindTheme( f ) if (theTheme <> nil) then theView.SetEditableTheme(theTheme) theTheme.SetActive(True) end 'theTheme = theView.GetEditableTheme if (theTheme = nil) then '******************************************************************************************** '********* Make A New Theme ***************************************************************** '******************************************************************************************** '***********Define File Type***************** '******************************************** class = Point '***** Make the Feature Table (FTab) '******************************************** tbl = FTab.MakeNew(d, class) '**make the feature table with MakeNew, but this has only one field, the feature type (point) '* you MUST add at least one more field for the feature table to be valid if (tbl.HasError) then if (tbl.HasLockError) then MsgBox.Error("Unable to acquire Write Lock for file " + d.GetBaseName, "") else MsgBox.Error("Unable to create " + d.GetBaseName, "") end return nil end fld1 = Field.Make("ID", #FIELD_DECIMAL, 8, 0) fld1.SetVisible( TRUE ) tbl.AddFields({fld1}) fld2 = Field.Make("X-COORD", #FIELD_DECIMAL, 14, 2) fld2.SetVisible( TRUE ) tbl.AddFields({fld2}) fld3 = Field.Make("Y-COORD", #FIELD_DECIMAL, 14, 2) fld3.SetVisible( TRUE ) tbl.AddFields({fld3}) fld4 = Field.Make("COUNTY", #FIELD_CHAR, 30, 0) fld4.SetVisible( TRUE ) tbl.AddFields({fld4}) fld5 = Field.Make("QUADNAME", #FIELD_CHAR, 30, 0) fld5.SetVisible( TRUE ) tbl.AddFields({fld5}) fld6 = Field.Make("Spring_Name", #FIELD_CHAR, 35, 0) fld6.SetVisible( TRUE ) tbl.AddFields({fld6}) fld7 = Field.Make("WR-ID", #FIELD_DECIMAL, 8, 0) fld7.SetVisible( TRUE ) tbl.AddFields({fld7}) fld8 = Field.Make("Township", #FIELD_CHAR, 5, 0) fld8.SetVisible( TRUE ) tbl.AddFields({fld8}) fld9 = Field.Make("Range", #FIELD_CHAR, 5, 0) fld9.SetVisible( TRUE ) tbl.AddFields({fld9}) fld10 = Field.Make("Section", #FIELD_DECIMAL, 3, 0) fld10.SetVisible( TRUE ) tbl.AddFields({fld10}) fld11 = Field.Make("Date", #FIELD_DATE, 9, 0) fld11.SetVisible( TRUE ) tbl.AddFields({fld11}) fld12 = Field.Make("Latitude", #FIELD_CHAR, 12, 0) fld12.SetVisible( TRUE ) tbl.AddFields({fld12}) fld13 = Field.Make("Longitude", #FIELD_CHAR, 12, 0) fld13.SetVisible( TRUE ) tbl.AddFields({fld13}) tbl.SetEditable(True) '********************************************************************************** '*** Make the FTheme ("a visual representation of the features defined in an FTab") '********************************************************************************** theTheme = FTheme.Make(tbl) '********************************************************************************** '***Add theme to view '********************************************************************************** theView.AddTheme(theTheme) theTheme.SetActive(TRUE) theTheme.SetVisible(TRUE) theView.SetEditableTheme(theTheme) av.GetProject.SetModified(true) '************************************************************************************** '***Define Theme Variables '************************************************************************************** theView = av.GetActiveDoc theDisplay = theView.GetDisplay theTheme = theView.GetEditableTheme '******************************************* '**** Make a Legend '******************************************* newLegend = Legend.Make( #SYMBOL_MARKER ) newLegend.GetSymbols.Get( 0 ).SetColor( Color.GetRed ) theTheme.SetLegend( newLegend ) 'theTheme.UpdateLegend ' Redraw end '****************************************** '******Define the Point with the User Click '****************************************** 'PROJUTM returns the utm and lat/long coordinates of the 'selected POint. 'will only work on UTM Zone 10 Coverages 'alter thePrj object to use in differenent projections 'Attach script to apply button in View Tool Menu '************************************************************** '***************************************************************** theProj = av.Getproject theView = av.GetActiveDoc if (theView = nil) then theView = theProj.FindDoc("oregon") end 'Name of Test View theView.SetUnits(#UNITS_LINEAR_FEET) theprj=transverseMercator.Make(theView.REturnExtent) 'Alter this to reflect Theme Projection 'theprj = theView.GetProjection.ReturnExtent) ' if view is Projected 'Set Projection Parameters if View is not projected theprj.SetSpheroid(#SPHEROID_GRS80) theprj.SetCentralMeridian(-123.00)' FOR UTM ZONE 10 theprj.SetScale(0.9996) thePrj.SetFalseEasting(500000.00) ' if we have meters theprj.SetFalseNorthing(0.00) pt = theView.GetDisplay.ReturnUserPoint utmN = pt.GetY.SetFormat("dddddddd.ddd").abs utmE = pt.getX.SetFormat("dddddddd.ddd").abs 'msgbox.info("The Easting is: = " +utmE.Asstring + nl+ "The Northing is " ++utmN.Asstring,"UTM ZONE 10") 'latlongpt = _p.returnUnProjected(theprj) ' use this for meters latlongpt = (pt/(3.280839@3.280839)).returnUnProjected(theprj)' use this for feet long = latlongpt.getx.SetFormat("ddd.ddddddd").abs lat = latlongpt.gety.SetFormat("ddd.ddddddd").abs longdeg = long.Truncate latdeg = lat.truncate ''msgbox.info (" the latdeg = :" +longdeg.asString,"") longmin = ((long - longdeg) * 60).Abs latmin = (( lat-latdeg) * 60).Abs longsecT = longmin.truncate LatsecT = latmin.truncate longsec = (((longmin - longsecT) * 60).abs.truncate - 5) latsec = ((latmin - LatsecT) * 60).abs.Truncate 'msgbox.info("longitude in DMS is: " +longdeg.ABs.asstring ++longsecT.asString ++Longsec.asstring ++"W" ,"LONGITUDE") head = ("lat/long") 'msgbox.info("The Easting is: = " +utme.Asstring ++"E" + nl+ "The Northing is " '++utmn.Asstring ++"N" + nl + "Latitude is: = " +Latdeg.abs.Asstring ++LatsecT.asString ++latsec.asString ++"N" + nl+ ' "Longitude is:" +longdeg.ABs.asstring ++longsecT.asString ++Longsec.asstring ++"W","UTM LAT/LONG") 'msgbox.info("The Easting is: = " +utme.Asstring +"E" + nl+ "The Northing is " '++utmn.Asstring +"N" + nl + "The Latitude is: = " +Lat.Asstring ++"W" + nl+ '"The Longitude is " ++Long.Asstring ++"N","UTM LAT/LONG") 'This part will place text where you clicked 'example 'theText2 = "Length = " + theLengthText + ", Bearing = " + theBearingText 'lbl = Latdeg.abs.Asstring ++ LatsecT.asString ++ latsec.asString ++ "N" + nl+ 'longdeg.ABs.asstring ++ longsecT.asString ++ Longsec.asstring ++ "W" later = Latdeg.abs.Asstring++LatsecT.asString++latsec.asString++"N" longer = longdeg.ABs.asstring++longsecT.asString++Longsec.asstring++"W" '******************************************** '** Define Object Variables for Quad & County & Township & Range & Section '******************************************** quadTheme = theView.FindTheme("USGS QUADS") quadTheme.SetActive(TRUE) quadTheme.SelectByPoint(pt, #VTAB_SELTYPE_NEW) quadTable = quadTheme.GetFTab quadField = quadTable.FindField("QUADNAME") quadBitMap = quadTable.GetSelection quadrec = quadBitMap.GetNextSet(-1) theQuad = quadTable.ReturnValue (quadfield, quadrec) quadTheme.SetActive(FALSE) 'msgbox.report(theQuad.AsString,"QUADNAME" ) cntyTheme = theView.FindTheme("COUNTY") cntyTheme.SetActive(TRUE) cntyTheme.SelectByPoint(pt, #VTAB_SELTYPE_NEW) cntyTable = cntyTheme.GetFTab cntyField = cntyTable.FindField("County") cntyBitMap = cntyTable.GetSelection cntyrec = cntyBitMap.GetNextSet(-1) theCounty = cntyTable.ReturnValue (cntyfield, cntyrec) cntyTheme.SetActive(FALSE) 'msgbox.report(theCounty.AsString,"cntyfield" ) sectTheme = theView.FindTheme("Sections") sectTheme.SetActive(TRUE) sectTheme.SelectByPoint(pt, #VTAB_SELTYPE_NEW) sectTable = sectTheme.GetFTab sectField = sectTable.FindField("Section") sectBitMap = sectTable.GetSelection sectrec = sectBitMap.GetNextSet(-1) theSection= sectTable.ReturnValue (sectfield, sectrec) sectTheme.SetActive(FALSE) twpTheme = theView.FindTheme("Sections") twpTheme.SetActive(TRUE) twpTheme.SelectByPoint(pt, #VTAB_SELTYPE_NEW) twpTable = twpTheme.GetFTab twpField = twpTable.FindField("Township") twpBitMap = twpTable.GetSelection twprec = twpBitMap.GetNextSet(-1) theTownship= twpTable.ReturnValue (twpfield, twprec) twpTheme.SetActive(FALSE) rngeTheme = theView.FindTheme("Sections") rngeTheme.SetActive(TRUE) rngeTheme.SelectByPoint(pt, #VTAB_SELTYPE_NEW) rngeTable = rngeTheme.GetFTab rngeField = rngeTable.FindField("Range") rngeBitMap = rngeTable.GetSelection rngerec = rngeBitMap.GetNextSet(-1) theRange = rngeTable.ReturnValue (rngefield, rngerec) rngeTheme.SetActive(FALSE) theName = msgbox.Input ("NAME IT HERE","Enter Water Right/Diversion Name:","WATER RIGHT NAME") '********************************************************************************************* '******* Add Basic Data to the Feature Table '********************************************************************************************* '**Define Field Variables theField0 = theTheme.GetFTab.FindField("Shape") theField1 = theTheme.GetFTab.FindField("ID") theField2 = theTheme.GetFTab.FindField("X-COORD") theField3 = theTheme.GetFTab.FindField("Y-COORD") theField4 = theTheme.GetFTab.FindField("QUADNAME") theField5 = theTheme.GetFTab.FindField("COUNTY") theField6 = theTheme.GetFTab.FindField("SECTION") theField7 = theTheme.GetFTab.FindField("TOWNSHIP") theField8 = theTheme.GetFTab.FindField("RANGE") theField9 = theTheme.GetFTab.FindField("DATE") theField10 = theTheme.GetFTab.FindField("SPRING_NAME") theField11 = theTheme.GetFTab.FindField("LATITUDE") theField12 = theTheme.GetFTab.FindField("LONGITUDE") '***Add Data x = pt.GetX y = pt.GetY theTheme.GetFTab.BeginTransaction rec = theTheme.GetFTab.AddRecord num = rec + 1 '**************PROJECT UTM 10 FEET > Lat LONG ******* 'PROJUTM returns the utm and lat/long coordinates of the 'selected POint. 'will only work on UTM Zone 10 Coverages 'alter thePrj object to use in differenent projections 'Attach script to apply button in View Tool Menu '************************************************************** p = theView.GetDisplay.ReturnUserPoint '************************************************************** theProj = av.Getproject theView = av.GetActiveDoc if (theView = nil) then theView = theProj.FindDoc("oregon") end 'Name of Test View theView.SetUnits(#UNITS_LINEAR_FEET) theprj=transverseMercator.Make(theView.REturnExtent) 'Alter this to reflect Theme Projection 'theprj = theView.GetProjection.ReturnExtent) ' if view is Projected 'Set Projection Parameters if View is not projected theprj.SetSpheroid(#SPHEROID_GRS80) theprj.SetCentralMeridian(-123.00)' FOR UTM ZONE 10 theprj.SetScale(0.9996) thePrj.SetFalseEasting(500000.00) ' if we have meters theprj.SetFalseNorthing(0.00) '_p = theView.GetDisplay.ReturnUserPoint utmN = p.GetY.SetFormat("dddddddd.ddd").abs utmE = p.getX.SetFormat("dddddddd.ddd").abs ''msgbox.info("The Easting is: = " +utmE.Asstring + nl+ "The Northing is " ++utmN.Asstring,"UTM ZONE 10") 'latlongpt = preturnUnProjected(theprj) ' use this for meters latlongpt = (p/(3.280839@3.280839)).returnUnProjected(theprj)' use this for feet long = latlongpt.getx.SetFormat("ddd.ddddddd").abs lat = latlongpt.gety.SetFormat("ddd.ddddddd").abs longdeg = long.Truncate latdeg = lat.truncate ''msgbox.info (" the latdeg = :" +longdeg.asString,"") longmin = ((long - longdeg) * 60).Abs latmin = (( lat-latdeg) * 60).Abs longsecT = longmin.truncate LatsecT = latmin.truncate longsec = (((longmin - longsecT) * 60).abs.truncate - 5) latsec = ((latmin - LatsecT) * 60).abs.Truncate ''msgbox.info("longitude in DMS is: " +longdeg.ABs.asstring ++longsecT.asString ++Longsec.asstring ++"W" ,"LONGITUDE") head = ("lat/long") 'msgbox.info("The Easting is: = " +utme.Asstring ++"E" + nl+ "The Northing is " '++utmn.Asstring ++"N" + nl + "Latitude is: = " +Latdeg.abs.Asstring ++LatsecT.asString ++latsec.asString ++"N" + nl+ ' "Longitude is:" +longdeg.ABs.asstring ++longsecT.asString ++Longsec.asstring ++"W","UTM LAT/LONG") ''msgbox.info("The Easting is: = " +utme.Asstring +"E" + nl+ "The Northing is " '++utmn.Asstring +"N" + nl + "The Latitude is: = " +Lat.Asstring ++"W" + nl+ '"The Longitude is " ++Long.Asstring ++"N","UTM LAT/LONG") 'This part will place text where you clicked 'example 'theText2 = "Length = " + theLengthText + ", Bearing = " + theBearingText 'lbl = Latdeg.abs.Asstring ++ LatsecT.asString ++ latsec.asString ++ "N" + nl+ 'longdeg.ABs.asstring ++ longsecT.asString ++ Longsec.asstring ++ "W" later = Latdeg.abs.Asstring++LatsecT.asString++latsec.asString++"N" longer = longdeg.ABs.asstring ++longsecT.asString++Longsec.asstring++"W" ' msgbox.Info ("Later is :" ++later, "later") '**************************************************** theTheme.GetFTab.SetValue(theField0, rec, pt) theTheme.GetFTab.SetValue(theField1, rec, num) theTheme.GetFTab.SetValue(theField2, rec, x) theTheme.GetFTab.SetValue(theField3, rec, y) theTheme.GetFTab.SetValue(theField4, rec, theQuad) theTheme.GetFTab.SetValue(theField5, rec, theCounty) theTheme.GetFTab.SetValue(theField6, rec, theSection) theTheme.GetFTab.SetValue(theField7, rec, theTownship) theTheme.GetFTab.SetValue(theField8, rec, theRange) theTheme.GetFTab.SetValue(theField9, rec, today) theTheme.GetFTab.SetValue(theField10, rec, theName) theTheme.GetFTab.SetValue(theField11, rec, later) theTheme.GetFTab.SetValue(theField12, rec, longer) theTheme.GetFTab.EndTransaction theTheme.GetFTab.GetSelection.ClearAll theTheme.GetFTab.GetSelection.Set(rec) theTheme.GetFTab.UpdateSelection av.GetProject.SetModified(true) '******************************************* '*****Label the Point '******************************************* theTheme.SetLabelField(theTheme.GetFTab.FindField("ID")) theLabel = theTheme.GetLabelField theView.Label(pt) '******************************************* '***Text Masks myFill = RasterFill.Make myFill.SetStyle(#RASTERFILL_STYLE_STIPPLE) myFill.SetColor(Color.GetWhite) myTextSymbol = TextSymbol.Make myFont = Font.Make("Arial", "Bold") myTextSymbol.SetFont(myFont) theView = av.GetActiveDoc theView.GetGraphics.UnSelectAll myList = GraphicList.Make myGraphicSet = theTheme.GetGraphics myGraphicList = theView.GetGraphics myGraphic = myGraphicSet.Get( rec ) if(myGraphic.Is(graphicText)) then myGraphic.SetSymbol(myTextSymbol) myList.Add(myGraphic) myGraphicList.RemoveGraphic(myGraphic) 'this remove the graphic from list AND set br = myGraphic.GetBounds.Clone myBox = GraphicShape.Make(br) myBox.SetSymbol(myFill) myBoxHeight = myBox.GetShape.GetHeight myBoxWidth = myBox.GetShape.GetWidth myBox.GetShape.SetOrigin(myBox.GetOrigin - ((myBoxHeight/4)@(myBoxHeight/5))) 'moves graphic down & to left myBox.GetShape.SetSize(myBoxWidth@myBoxHeight + ((myBoxHeight/2.5)@(myBoxHeight/10))) 'makes graphic a little bigger myList.Add(myBox) myBox.SetSelected(true) end myList.MoveSelectedToBack myGroup = GraphicGroup.Make for each g in myList 'since there are only 2 grapics in the list, myGroup.Add(g) 'we can add "all" graphics in the list to the end 'group. x2 = 50 y2 = 0 ptoffset = Point.Make(x2,y2) myGroup.Offset(ptoffset) myGraphicSet.Add(myGroup) myGraphicList.AddBatch(myGroup) myGraphicList.UnSelectAll '******************************************************************************************* '******* Stop Editing theme '****************************************************************************************** theTheme.StopEditing(true) theTheme.SetVisible(TRUE) theTheme.ClearSelection av.GetProject.SetModified(true)