Hi List,
I don't know if I've got all answers yet. So I will sum up tomorrow.
As nobody provided what I was really searching for, I decided to solve the problem by myself. You see, the Shapefile was a little more complex. So most of the "do-it-by-hand"-solutions weren't really suitable for my problem. Here's a little quick 'n' dirty code that solved the problem. Careful with multipart polygons where the single parts lie apart from another. The script takes only the largest parts into the new shape. It's just ment for donut polygons.
Have fun, Till
theView = av.GetActiveDoc holeTheme = theView.GetActiveThemes.Get(0) holeFTab = holeTheme.GetFTab holeFldShp = holeFTab.FindField("Shape") holeFldId = holeFTab.FindField("id") ' insert name of the field with numeric id-values you want to transfer
outFTab = FTab.MakeNew(("/<path>/<name>.shp").AsFileName,Polygon) ' insert desired path and filename outFTab.SetEditable(True) outFldShp = outFTab.FindField("Shape") outFldVp = Field.Make("id",#FIELD_DECIMAL,7,0) outFTab.AddFields({outFldVp})
cnt = holeFTab.GetNumRecords ctr = 0
for each k in holeFTab oVp = holeFTab.ReturnValue(holeFldId,k) oShp = holeFTab.ReturnValue(holeFldShp,k) rec = outFTab.AddRecord outFTab.SetValue(outFldVp,rec,oVp) if (oShp.CountParts = 1) then outFTab.SetValue(outFldShp,rec,oShp) else aLst = oShp.AsList areaLst = {} for each i in 0..(aLst.Count -1) areaLst.Add(polygon.Make({aLst.Get(i)}).ReturnArea) end areaLst.Sort(False) maxarea = areaLst.Get(0) for each i in 0..(aLst.Count -1) if (polygon.Make({aLst.Get(i)}).ReturnArea = maxarea) then outFTab.SetValue(outFldShp,rec,polygon.Make({aLst.Get(i)})) end end end ctr = ctr + 1 av.ShowStopButton av.SetStatus((100/cnt)*ctr) av.ShowMsg("Removing holes...") end av.ClearMsg av.ClearStatus outFTab.SetEditable(False) outTheme = FTheme.Make(outFTab) theView.AddTheme(outTheme) outTheme.SetVisible(True)
_______________________________________________ gislist mailing list gislist@lists.geocomm.com http://lists.geocomm.com/mailman/listinfo/gislist
_________________________________ This list is brought to you by The GeoCommunity http://www.geocomm.com/
Get Access to the latest GIS & Geospatial Industry RFPs and bids http://www.geobids.com
|