import arcpy, sys a = sys.argv[1] b = sys.argv[2] try: result = arcpy.Buffer_analysis(a, b, "1000 meters") sys.stdout.write(str(result.getOutput(0))) except: sys.stdout.write("Error")
protected override void OnClick() { IMap map = ArcMap.Document.FocusMap; IDataset dset = (IDataset)((IFeatureLayer)map.get_Layer(0)).FeatureClass; string workspace = dset.Workspace.PathName; string inputFC = workspace + "\\" + dset.BrowseName; string outputFCName = "myOutput1"; string outputPath = workspace + "\\" + outputFCName; object command = @C:\techLead_incidents\user_forums\Script1.py; System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command + " " + inputFC + " " + outputPath); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; System.Diagnostics.Process proc = new System.Diagnostics.Process(); proc.StartInfo = procStartInfo; proc.Start(); string result = proc.StandardOutput.ReadToEnd(); addLayer(map, result); ArcMap.Application.CurrentTool = null; } private void addLayer(IMap map, string fullPath) { string[] pathPart = fullPath.Split('\\'); string fcName = pathPart[pathPart.Length -1]; string workspace = fullPath.Replace(('\\' + fcName).ToString(), ""); IWorkspaceFactory pWSFactory = new FileGDBWorkspaceFactoryClass(); IWorkspace pWorkspace = (IWorkspace)pWSFactory.OpenFromFile(workspace, ArcMap.Application.hWnd); IFeatureWorkspace pFWorkspace = (IFeatureWorkspace)pWorkspace; IFeatureClass pFClass = (IFeatureClass)pFWorkspace.OpenFeatureClass(fcName); IFeatureLayer pFLayer = new FeatureLayerClass(); pFLayer.FeatureClass = pFClass; pFLayer.Name = fcName; pFLayer.ShowTips = true; map.AddLayer(pFLayer); }
サインインしたメンバーは投稿、更新のフォローなどができます。初めてですか?無料アカウントを登録してください。
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.