Код для объединения 2D тем
theview = av.getactivedoc
theGraphics = theview.GetGraphics
theProjection = theView.GetProjection
if ( (theView.GetActiveThemes.Count=0) or (theView.GetActiveThemes.Get(0).Is(ITheme)) ) then
msgbox.error("An Active Feature Theme is Required","Exiting")
return(nil)
end
themelist=theView.getthemes
if (TheView.getactiveThemes.count=0) then exit end
s=TheView.getactiveThemes.count
SrcTheme = theView.GetActiveThemes.Get(0)
'+++++++++++++++++++++++++++++++++++++++++++++++++++
'Ñîçäàåì íîâóþ Ftab
'+++++++++++++++++++++++++++++++++++++++++++++++++++
outFName = av.GetProject.MakeFileName(SrcTheme.GetName, "shp")
' outFName=("d:\gis_prj\"+(SRCTheme.GetName)).AsFileName
outFName = FileDialog.Put(outFName, "*.shp", "Output Clipped Shapefile")
if (outFName = Nil) then
exit
end
shapeType = SRCTheme.GetFTab.FindField("Shape").GetType
if (shapeType = #FIELD_SHAPELINE) then
outClass = POLYLINE
elseif (shapeType = #FIELD_SHAPEMULTIPOINT) then
outClass = MULTIPOINT
elseif (shapeType = #FIELD_SHAPEPOINT) then
outClass = POINT
elseif (shapeType = #FIELD_SHAPEPOLY) then
outClass = POLYGON
else
MsgBox.Error("Invalid shape field type.", "Clip Theme")
exit
end
OutputFTab = FTab.MakeNew( outFName, outClass )'Ñîçäàíèå íîâîé òàáëèöû
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
'Äîáàâëÿåì â íîâóþ FTab îñòàëüíûå ïîëÿ (åñëè åñòü) èç òàáëèöû òåìû
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
SRCfields = List.Make
for each f in SRCTheme.GetFTab.GetFields 'ïåðåíîñ ïîëåé èç ñòàðîé òàáëèöû â íîâóþ
if (f.GetName = "Shape") then
continue
else
fCopy = f.Clone
SRCfields.Add(fCopy)
end
end
if (SRCFields.Count > 0) then 'Äîáàâëåíèå ïîëåé, åñëè òàêèå åñòü
OutputFTab.AddFields( SRCFields )
end
'++++++++++++++++++++++++++++
'Äîáàâëÿåì çàïèñè
'++++++++++++++++++++++++++++
for each r in 0..(s-1)
theFtab = theView.GetActiveThemes.Get(r).GetFTab
for each c in 0..(theFTab.GetNumRecords-1)
aValue=theFTab.ReturnValue(theFTab.FindField("Shape"),c)
theoutrec=outputftab.addrecord
outputFtab.SetValue(theFTab.FindField("Shape"),theoutrec,aValue)
for each afield in SRCfields 'Äîáàâëåíèå çíà÷åíèé âñåõ ïîëåé, êðîìå shape
oldfield=Theftab.findfield(afield.getname)
oldvalue=TheFtab.returnvalue(oldfield,c)
outputftab.setValue(afield, theoutrec, oldvalue)
end
end
end
Outputftab.seteditable(false)
if (MsgBox.YesNo("Add shapefile as theme to a view?",
"Clip Theme", true).Not) then
exit
end
viewList = {}
for each d in av.GetProject.GetDocs
if (d.Is(View)) then
viewList.Add( d )
end
end
viewList.Add("<New View>")
addToView = MsgBox.ListAsString( viewList,"Add Theme to:", "Clip Theme" )
if (addToView <> nil) then
if (addToView = "<New View>") then
addToView = View.Make
addToView.GetWin.Open
end
mergeTheme = FTheme.Make( OutputFTab )
addToView.AddTheme( mergeTheme )
' Bring the View to the front...
addToView.GetWin.Activate
end
av.clearstatus
Для 3D тем:
theview = av.getactivedoc
theGraphics = theview.GetGraphics
theProjection = theView.GetProjection
if ( (theView.GetActiveThemes.Count=0) or (theView.GetActiveThemes.Get(0).Is(ITheme)) ) then
msgbox.error("An Active Feature Theme is Required","Exiting")
return(nil)
end
themelist=theView.getthemes
if (TheView.getactiveThemes.count=0) then exit end
s=TheView.getactiveThemes.count
SrcTheme = theView.GetActiveThemes.Get(0)
'+++++++++++++++++++++++++++++++++++++++++++++++++++
'Ñîçäàåì íîâóþ Ftab
'+++++++++++++++++++++++++++++++++++++++++++++++++++
outFName = av.GetProject.MakeFileName(SrcTheme.GetName, "shp")
' outFName=("d:\gis_prj\"+(SRCTheme.GetName)).AsFileName
outFName = FileDialog.Put(outFName, "*.shp", "Output Clipped Shapefile")
if (outFName = Nil) then
exit
end
shapeType = SRCTheme.GetFTab.FindField("Shape").GetType
if (shapeType = #FIELD_SHAPELINE) then
outClass = POLYLINEZ
elseif (shapeType = #FIELD_SHAPEMULTIPOINT) then
outClass = MULTIPOINTZ
elseif (shapeType = #FIELD_SHAPEPOINT) then
outClass = POINTZ
elseif (shapeType = #FIELD_SHAPEPOLY) then
outClass = MULTIPATCH
' elseif (shapeType = #FIELD_MULTIPATCH) then
' outClass = MULTIPATCH
else
MsgBox.Error("Invalid shape field type.", "Clip Theme")
exit
end
OutputFTab = FTab.MakeNew( outFName, outClass )'Ñîçäàíèå íîâîé òàáëèöû
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
'Äîáàâëÿåì â íîâóþ FTab îñòàëüíûå ïîëÿ (åñëè åñòü) èç òàáëèöû òåìû
'+++++++++++++++++++++++++++++++++++++++++++++++++++++
SRCfields = List.Make
for each f in SRCTheme.GetFTab.GetFields 'ïå