|
Installation: 1) Create twoscripts, named dF.View.MakeRelTab, and dF.View.MakeRelTabUpdate, with the following source code. 2) In GUI project, click on customize, and create a new menu option in the vue menu, with following options (except for HelpTopic: keep it empty):
'---Create a table of selected objects from one theme by each object from a second theme. '---Copyright Daniel FAIVRE 1999 - www.geomaticien.com - Freeware with this notice only '---A newer version may exist on the site. This is dF.View.MakeRelTab version 1.0 '---No warranty of any kind. 'Must be a "click" property of a custom menu option in GUI view 'It's a good idea to use the dF.View.MakeRelTabUpdate script as Update script for this menu option. Work of course only for features themes, not for images ;-) theView = av.GetActiveDoc theThemes = theView.GetActiveThemes if (theThemes.Count <> 2) then MsgBox.Warning ("Work only if TWO themes selected","") return nil end the1stTheme = theThemes.Get(0) the2ndTheme = theThemes.Get(1) theChoiceList = {the1stTheme,the2ndTheme} theChoice = MsgBox.Choice (theChoiceList,"Which theme will be on the ONE size of the relation ? (This theme entities each contains several objects from the other theme)","Source choice") if (nil=theChoice) then return nil end if (theChoice = the2ndTheme) then the1stTheme = theThemes.Get(1) the2ndTheme = theThemes.Get(0) end '---Create the new table: rel1 = the1stTheme.GetName.Left(the1stTheme.GetName.IndexOf(".")).Substitute(" ","_") relN = the2ndTheme.GetName.Left(the2ndTheme.GetName.IndexOf(".")).Substitute(" ","_") theNewTabName = FileDialog.Put(av.GetProject.MakeFileName(Rel1 + relN,"dbf"), "*.dbf", "New relation between" ++ rel1 ++ "and" ++ relN) if (theNewTabName = NIL) then return nil end theNewTab = VTab.MakeNew(theNewTabName,dBase) '---Create fields from the two attributes tables of the selected themes: the1stTab = the1stTheme.GetFTab for each aField in the1stTab.GetFields if (aField.GetName = "Shape") then Continue end theNewTab.AddFields({aField.Clone}) end theNewTab.AddFields({Field.Make("Num",#FIELD_LONG,16,0)}.Clone) the2ndTab = the2ndTheme.GetFTab for each aField in the2ndTab.GetFields if (aField.GetName = "Shape") then Continue end theNewTab.AddFields({aField.Clone}) end '---Loop to process selections: for each rec1 in the1stTab '---Select each record, one by one: the1stTab.GetSelection.Set(rec1) the1stTab.UpdateSelection '---Search entities from theme 2 which intersects selected entity from theme 1: the2ndTheme.SelectByTheme(the1stTheme, #FTAB_RELTYPE_INTERSECTS, 0, #VTAB_SELTYPE_NEW) '--Export fields from selected entities: nb = 0 for each rec2 in the2ndTab.GetSelection nb = nb + 1 newRecNo = theNewTab.AddRecord for each F1 in the1stTab.GetFields if (F1.GetName = "Shape") then Continue end theDestField = theNewTab.FindField(F1.GetName) theNewTab.SetValue(theDestField,newRecNo,the1stTab.ReturnValue(F1,rec1)) end theNewTab.SetValue(theNewTab.FindField("Num"),newRecNo,nb) for each F2 in the2ndTab.GetFields if (F2.GetName = "Shape") then Continue end theDestField = theNewTab.FindField(F2.GetName) theNewTab.SetValue(theDestField,newRecNo,the2ndTab.ReturnValue(F2,rec2)) end end '---Unselect processed record: the1stTab.GetSelection.Clear(rec1) the1stTab.UpdateSelection end
'--- Two themes must be selected theView = av.GetActiveDoc SELF.SetEnabled((2 = theView.GetActiveThemes.Count)) |