theView = av.getactivedoc theThemes = theView.GetThemes If(theThemes.count = 0) Then msgbox.warning("There are no themes in the view...exiting.", "EXITING") return(0) End '******************************************************** '***CREATE A LIST OF THEMES THAT ARE POINT TYPE ONLY '***TO INSURE THE USER DOEN"T CHOOSE A NON-POINT THEME '******************************************************** pointList = {} For Each t in 0 .. (theThemes.Count - 1) If(theThemes.Get(t).GetFTab.GetShapeClass.GetClassName = "point") Then 'msgbox.info(theThemes.Get(t).GetFTab.GetShapeClass.GetClassName, "") pointList.add(theThemes.Get(t).GetName) Else Continue End End If(pointList.Count = 0) Then msgbox.warning("There are NO POINT THEMES in the view...exiting.", "EXITING") return(0) End ptThmSel = msgbox.listasstring(pointList, "Select the SAMPLE POINTS theme", "") if(ptThmSel = NIL) Then Return(0) End ptTheme = theView.FindTheme(ptThmSel.asstring) ptFTab = ptTheme.GetFTab ptShpFld = ptFTab.FindField("shape") ptXfld = ptFTab.FindField("xcentroid") ptYfld = ptFTab.FindField("ycentroid") '***CHECK FOR TYPE POINT THEME If(ptXfld = NIL) Then msgbox.info("Required field not found. Creating XCENTROID attribute field", "Creating Field") ptFTab.SetEditable(True) newFld = Field.Make("xcentroid", #FIELD_FLOAT, 12, 2) ptFTab.AddFields({newFld}) ptFTab.SetEditable(False) End ptXfld = ptFTab.FindField("xcentroid") If(ptYfld = NIL) Then msgbox.info("Required field not found. Creating YCENTROID attribute field", "Creating Field") ptFTab.SetEditable(True) newFld = Field.Make("ycentroid", #FIELD_FLOAT, 12, 2) ptFTab.AddFields({newFld}) ptFTab.SetEditable(False) End ptYfld = ptFTab.FindField("ycentroid") If(ptFTab.GetNumRecords > 0) Then yn = msgbox.yesno("Existing Sample Points Found...Delete Before Continuing?", "DELETE EXISTING POINTS????", false) If(yn = true) Then ptFTab.SetEditable(True) For Each r in ptFTab ptFTab.removerecord(r) End ptFTab.SetEditable(False) Else return(0) End End ptFTab.Refresh '******************************************************** '***CREATE A LIST OF THEMES THAT ARE POLYGON TYPE ONLY '***TO INSURE THE USER DOEN"T CHOOSE A NON_POLYGON THEME '******************************************************** polyList = {} For Each t in 0 .. (theThemes.Count - 1) If(theThemes.Get(t).GetFTab.GetShapeClass.GetClassName = "polygon") Then 'msgbox.info(theThemes.Get(t).GetFTab.GetShapeClass.GetClassName, "") polyList.add(theThemes.Get(t).GetName) Else Continue End End If(polyList.Count = 0) Then msgbox.warning("There are NO POLYGON THEMES in the view...exiting.", "EXITING") return(0) End polyThmSel = msgbox.listasstring(polyList, "Select a POLYGON theme", "") if(polyThmSel = NIL) Then Return(0) End polyTheme = theView.FindTheme(polyThmSel.asstring) polyFTab = polyTheme.GetFTab polyShpFld = polyFTab.FindField("shape") For Each r in polyFTab theShp = polyFTab.ReturnValue(polyShpFld, r) theCentroid = theShp.ReturnCenter centroidX = theCentroid.GetX centroidY = theCentroid.GetY ptFTab.SetEditable(True) theRec = ptFTab.AddRecord ptFTab.SetValue(ptShpFld, theRec, theCentroid) ptFTab.SetValue(ptXfld, theRec, centroidX) ptFTab.SetValue(ptYfld, theRec, centroidY) ptFTab.SetEditable(False) End ptFTab.Refresh