Option Explicit Sub Test() Dim pWSF As IWorkspaceFactory Set pWSF = New FileGDBWorkspaceFactory Dim pFWS As IFeatureWorkspace Set pFWS = pWSF.OpenFromFile("D:\Projects\SAWS\data\EncinoPark.gdb", 0) Dim pFLayer As IFeatureLayer Set pFLayer = New FeatureLayer Set pFLayer.FeatureClass = pFWS.OpenFeatureClass("EARZ_ZONES2") pFLayer.Name = "mylayer" Dim pQF As IQueryFilter Set pQF = New QueryFilter pQF.WhereClause = """EARZ_ZONE"" = 'AREA 5'" Dim pFSel As IFeatureSelection Set pFSel = pFLayer pFSel.SelectFeatures pQF, esriSelectionResultNew, False Dim pFLD As IFeatureLayerDefinition Set pFLD = pFSel Dim pLayer As ILayer Set pLayer = pFLD.CreateSelectionLayer("mylayer", True, "", "") Dim pMxDoc As IMxDocument Set pMxDoc = ThisDocument pMxDoc.FocusMap.AddLayer pLayer End Sub
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.