yousef2233 Posted October 14, 2012 Author Report Share Posted October 14, 2012 yes, my codes are for already added layers in TOC. Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 14, 2012 Report Share Posted October 14, 2012 I'm newbie in gis programming, I'm sorry if I have a lot of question about it.. first, in the code of : [quote][color=#282828][font=helvetica, arial, sans-serif]Set pDoc = ThisDocument[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]If Not pDoc.SelectedLayer Is Nothing Then[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]Set pLayer = pDoc.SelectedLayer[/font][/color] [color=#282828][font=helvetica, arial, sans-serif] Else[/font][/color] [color=#282828][font=helvetica, arial, sans-serif]MsgBox "No Layers Selected in TOC"[/font][/color][/quote] [quote][/quote] do you mean that if there isn't feature selected, it will show nothing?? how about it..call feature that has declared before to process it after.. in this case, i have called 2 file and show them in arcmap..the i wanna call them is other step..i don't know how to use TOC. last, but not least.. How can I use arctool such analysis tool (extract, overlayand so on)? thank you very much Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 14, 2012 Author Report Share Posted October 14, 2012 the TOC in ArcMAP includes some layers you have added already, my codes checks if any of them has been selected. just run my code and you will see what i mean. 'Defining some pointers you should be familiar with them Dim pDoc As IMxDocument Dim pLayer As IFeatureLayer Dim pFeatClass As IFeatureClass 'Setting Pointers Set pDoc = ThisDocument 'Working with TOC : this part checks if there is any selected layer (Not selected feature) is TOC 'and if so, player = pdoc.selectedlayer. pdoc pointing to the document you are working ' if you have problem understanding this section i seriously suggest reading Getting to know Arcobjects If Not pDoc.SelectedLayer Is Nothing Then Set pLayer = pDoc.SelectedLayer Else MsgBox "No Layers Selected in TOC" Exit Sub End If 'declaring a string variable for path of featureclass or layer Dim LayerPath As String Set pFeatClass = pLayer.FeatureClasss 'here is a part for assigning featureclass path to the variable Dim pDataset As IDataset Set pDataset = pFeatClass Dim pWorkspace As IWorkspace Set pWorkspace = pDataset.Workspace Dim FCPath As String FCPath = pWorkspace.PathName & "/" & pLayer.Name 'MsgBox (FCPath) Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 14, 2012 Author Report Share Posted October 14, 2012 the following codes have been written for working with arctoolbox so easy to use Dim GP As Object Set GP = CreateObject("esriGeoprocessing.GpDispatch.1") 'if you going to make a buffer around features of a layer, the code will be sth like this FCpath is the path of the layer selected in the TOC and the "D:\GISAREA\Buffer.shp" the address of the output and obviously 50000 is the buffering distance GP.Buffer_analysis FCPath, "D:\GISAREA\Buffer.shp", "50000" good luck Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 14, 2012 Report Share Posted October 14, 2012 could I write something like this? 'take a map Private Sub Petadasar_Click() Dim p1MxDoc As IMxDocument Set p1MxDoc = ThisDocument Dim p1GxDialog As IGxDialog Set p1GxDialog = New GxDialog p1GxDialog.AllowMultiSelect = True p1GxDialog.Title = "Select Feature Classes to Add To Map" Dim p1GxFilter As IGxObjectFilter Set p1GxFilter = New GxFilterFeatureClasses Set p1GxDialog.ObjectFilter = p1GxFilter Dim p1GxObjects As IEnumGxObject p1GxDialog.DoModalOpen Thisdocument.Parent.hWnd, p1GxObjects If (p1GxObjects Is Nothing) Then Exit Sub p1GxObjects.Reset Dim p1Layer As IFeatureLayer Dim p1GxDataset As IGxDataset Set p1GxDataset = p1GxObjects.Next Do Until (p1GxDataset Is Nothing) Set p1Layer = New FeatureLayer Set p1Layer.FeatureClass = p1GxDataset.Dataset p1Layer.Name = p1Layer.FeatureClass.AliasName p1MxDoc.FocusMap.Addlayer p1Layer Set p1GxDataset = p1GxObjects.Next Loop p1MxDoc.ActiveView.PartialRefresh esriViewGeography, Nothing, Nothing End Sub 'determining a process Public Sub ComboBox1_DropButtonclick() With ComboBox1 .AddItem "Flood region" .AddItem "Urban distance" .AddItem "Roadway distance" .AddItem "Topograph" .AddItem "Slope" .AddItem "Environmental load" End With End Sub Private Sub CommandButton2_Click() Dim pDoc As IMxDocument Dim pLayer As IFeatureLayer Dim pFeatClass As IFeatureClass Dim GP As Object Set pDoc = ThisDocument Set pLayer = pDoc.SelectedLayer Set GP = CreateObject("esriGeoprocessing.GpDispatch.1") If ComboBox1 = "Flood region" Then GP.Buffer_analysis FCPath, pLayer, "50000" end if end sub 1 Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 15, 2012 Author Report Share Posted October 15, 2012 i think it should work good luck Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 15, 2012 Report Share Posted October 15, 2012 If ComboBox1 = "Flood region" Then GP.Buffer_analysis FCPath, pLayer, "50000" could I use pLayer there for reffering a map opened? because it respon nothing.. thenk you before, I'm sorry if I bother you Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 15, 2012 Author Report Share Posted October 15, 2012 1- the idea of GxDialogbox is a little weird, never seen sth like that before, all the programs ive seen they work with already added layers 2- FCpath, indicates the path of layer you are working with, and if you insist on using GxDialogbox it should have the path of layer you want to add 3- GP.Buffer_analysis FCPath, pLayer, "50000", FCPath is input layer path, pLayer is output layer Path, and 50000 is an argument in this case it's the buffering distance. good luck Quote Link to comment Share on other sites More sharing options...
selamat Posted October 18, 2012 Report Share Posted October 18, 2012 (edited) Hi, need opinion all u guys currently using VS 2008 with ArcGIS Engine Developer Kit 10, after compile and running the application on ArcGIS Engine 10 its work fine but after upgrading to ArcGIS Engine 10.1, the application cant run and error as below: Description: Stopped working Problem signature: Problem Event Name: CLR20r3 Problem Signature 01: apps.exe Problem Signature 02: 1.0.0.0 Problem Signature 03: 5051b6e5 Problem Signature 04: Microsoft.VisualBasic Problem Signature 05: 8.0.0.0 Problem Signature 06: 4ca2d138 Problem Signature 07: 6c Problem Signature 08: 46 Problem Signature 09: System.IO.FileNotFoundException OS Version: 6.1.7601.2.1.0.256.48 Locale ID: 17417 Could someone tell me what is happening here, thanks. Edited October 18, 2012 by selamat 1 Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 18, 2012 Author Report Share Posted October 18, 2012 @Selamat, are you sure about version of dotNet you are working with ? Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 18, 2012 Report Share Posted October 18, 2012 Hello all, i want to overlay any files, so I need intersect_analysis..but I get error comment when I write Dim GP As Object Set GP = CreateObject("esriGeoprocessing.GpDispatch.1") GP.Intersect_analysis "E:\3. STUDY\3. THESIS\2. DATA SPASIAL\utm\administratif\pemukiman.shp", "E:\3. STUDY\3. THESIS\2. DATA SPASIAL\utm\jalan\utama.shp", "D:\intest" Could you guide me how to write intersect analsis, Please? Thank you very much Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 18, 2012 Author Report Share Posted October 18, 2012 i just sent you the solution Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 18, 2012 Author Report Share Posted October 18, 2012 i'm sure about the coma and semicolon besides try not to use dot in your addresses and do not use numbers for the first characters Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 18, 2012 Report Share Posted October 18, 2012 filename(1) = pWorkspace.PathName + "\" + pFeatureLayer.Name + ".shp" MkDir ("D:\IPAL_Location_process" + CStr(Counter)) Dim GP As Object Set GP = CreateObject("esriGeoprocessing.GpDispatch.1") GP.Intersect_analysis filename(1) ; "D:\IPAL_Location_process\ur" + CStr(Counter) + ".shp", "D:\IPAL_Location_process\urban distance" + CStr(Counter) + ".shp" but it doesn't work.. Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 18, 2012 Author Report Share Posted October 18, 2012 which line doesnt work ? Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 18, 2012 Report Share Posted October 18, 2012 semi colon ( alert error.. Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 18, 2012 Report Share Posted October 18, 2012 which line doesnt work ? line 5 desn't work Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 18, 2012 Author Report Share Posted October 18, 2012 check this dim parameter1 = "D:\A.shp;D:\B.shp" dim parameter2 = "D:\res.shp" GP.Intersect_analysis parameter1, parameter2 Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 19, 2012 Report Share Posted October 19, 2012 if A.shp and B.shp are lied in different partition? can I write like this? "E:\A.shp;D:\B.shp" Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 19, 2012 Report Share Posted October 19, 2012 (edited) I try to write Private Sub CommandButton1_Click() MkDir ("D:\IPAL_Location_processtest") 'spatial process Dim urbanprocess As String Dim GP As Object Set GP = CreateObject("esriGeoprocessing.GpDispatch.1") Select Case ComboBox1 'Case "Flood region" 'GP.Erase_analysis "E:\3. STUDY\3. THESIS\2. DATA SPASIAL\utm\administratif\batas pkl.shp", "E:\3. STUDY\3. THESIS\2. DATA SPASIAL\utm\banjir\80thn", "D:\IPAL_Location_process\Flood.shp" Case "Urban distance" GP.Buffer_analysis "E:\3. STUDY\3. THESIS\2. DATA SPASIAL\utm\administratif\pemukiman.shp", "D:\IPAL_Location_process\ur.shp", "150" urbanprocess = "D:\IPAL_Location_process\ur.shp" parameter1 = "urbanprocess;D:\B.shp" parameter2 = "D:\IPAL_Location_process\urban.shp" GP.Intersect_analysis parameter1, parameter2 End Select End Sub but it compile error in line 14 GP.Intersect_analysis parameter1, parameter2 Edited October 19, 2012 by Putri Yasmin Quote Link to comment Share on other sites More sharing options...
selamat Posted October 19, 2012 Report Share Posted October 19, 2012 (edited) @Selamat, are you sure about version of dotNet you are working with ? Hi yousef2233 image above show that i'm using visual studio 2008 is it true that ArcEngine Developer Kit 10.1 using VS2010 while ArcEngine Developer Kit 10 using VS2008 Edited October 19, 2012 by selamat Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 19, 2012 Author Report Share Posted October 19, 2012 @Putri Yasmin Dim urbanprocess As String Dim GP As Object Set GP = CreateObject("esriGeoprocessing.GpDispatch.1") parameter1 = "D:\GISAREA\test70.shp;D:\GISAREA\Temp8144.shp" parameter2 = "D:\GISAREA\RESULT111.shp" GP.Intersect_analysis parameter1, parameter2 Working fine here you need a little concentration i'll send you the rest 1 Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 19, 2012 Author Report Share Posted October 19, 2012 @Selamat it seems that way Before you can install the ArcGIS 10.1 ArcObjects .NET SDK, you must have Visual Studio 2010 installed on your machine. To build .NET applications with ArcGIS for Desktop or Engine, the Microsoft .NET Framework 3.5.1 must be installed on the machine. ArcGIS for Desktop and Engine installs the .NET 3.5.1 framework if it is not already on the machine. http://resources.arcgis.com/en/help/arcobjects-net/conceptualHelp/index.html#//0001000002ns000000 1 Quote Link to comment Share on other sites More sharing options...
yousef2233 Posted October 19, 2012 Author Report Share Posted October 19, 2012 thank you HaNoi, you always support me Quote Link to comment Share on other sites More sharing options...
Putri Yasmin Posted October 21, 2012 Report Share Posted October 21, 2012 (edited) dear all, I have searched in any website about the function GP.CopyFeatures_management but I haven't found yet why my vba arcgis notices require = after GP.CopyFeatures_management(filename(1),"D:\wwtp\basemap.shp") but in any arcgis help, esriforum etc don't need it in my arcgis 9.3, VBA compiles error after after GP.CopyFeatures_management(filename(1),"D:\wwtp\basemap.shp") and it needs = but when I write = true, it is error. and once more, for replacing folder, I use : Dim sFullPath As StringsFullPath = "D:\GISAREA" Dim myFSO As Object Set myFSO = CreateObject("Scripting.FileSystemObject") FolderExists = myFSO.FolderExists(sFullPath) if FolderExists = False then MkDir(sFullPath) end if MkDir(sFullPath) was used for replacing exists directory, how about replacing file? I just found like this : If GP.Exists("D:\directory_wwtp\Flood.shp") = False Then GP.Erase_analysis "D:\WWTP_directory\basemap.shp", filename(2), "D:\directory_wwtp\Flood.shp" Else MkDir (Directory + "\" + ".shp") End If but it respons nothing.. would you like to help me, please? Edited October 21, 2012 by Putri Yasmin Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.