POST
|
I'm trying to use a call to the GPUtilities class 3 times in 2 modules in the VB.NET addin I'm developing (ArcGIS 10.0, VS 2010). Since it is a singleton object, each time it is declared with: Dim t As Type = Type.GetTypeFromProgID("esriGeoprocessing.GPUtilities")
Dim obj As System.Object = Activator.CreateInstance(t)
Dim pGPU As ESRI.ArcGIS.Geoprocessing.IGPUtilities3 = obj It is working for the first 2 occurrances in the first module, but when the code gets to the third occurrance in the second module Dim pHELLayer As IFeatureLayer = pGPU.OpenFeatureLayerFromString("F:\SD_Tools\HEL_Tool\HEL_Data.shp") I get this message: [ATTACH=CONFIG]27240[/ATTACH] Any ideas on how to fix this error? Do I need to go back to using a WorkspaceFactory to access this shapefile?
... View more
09-05-2013
01:07 PM
|
0
|
3
|
638
|
POST
|
Basically, I need the second routine to do the same thing as the Add Table to Layout command: [ATTACH=CONFIG]27017[/ATTACH]
... View more
08-27-2013
07:17 AM
|
0
|
0
|
250
|
POST
|
I have a featureclass that represents the soils data for a field. My goal is to only show the soil mapunit and acreage fields from the attribute in an existing layout. The following code makes the desired changes to the table: Private Sub btnAddTable_Click(sender As Object, e As System.EventArgs) Handles btnAddTable.Click
'Add a table to the layout for the selected tract/field
Dim intASD As Integer = GetASDLayer() 'Returns the layer's position in the TOC
If intASD >= 0 Then
Dim pLayer As ILayer = pMxDoc.FocusMap.Layer(intASD)
'Reduce the visible columns to just MUSYM and SUMACRES
Dim pTableFields As ITableFields = pLayer
Dim pFieldInfo As IFieldInfo3
Dim pField As IField
For x = 0 To pTableFields.FieldCount - 1
pField = pTableFields.Field(x)
pFieldInfo = pTableFields.FieldInfo(x)
If pField.Name = "MUSYM" Then
'Keep and rename
pFieldInfo.Alias = "Soil Type"
ElseIf pField.Name = "SUMACRES" Then
'Ditto
pFieldInfo.Alias = "Acres"
Else
'Don't display anything else
pFieldInfo.Visible = False
End If
Next
AddTableFrame(pLayer)
End If
End Sub And if I open the attribute table from the TOC after running this routine, the table appears with the undesired fields removed. But when I add the table to the layout with this code: Public Sub AddTableFrame(pTable As ITable)
'Adapted from http://forums.esri.com/Thread.asp?c=93&f=992&t=57798&mc=22#msgid293581
Dim pPageLayout As IPageLayout = pMxDoc.PageLayout
Dim pGContainer As IGraphicsContainer = pPageLayout
'Get the table of the first featureclass
Dim pMap As IMap = pMxDoc.FocusMap
'Create a new tableframe
Dim pTableFrame As ITableFrame = New TableFrame
Dim pElement As IElement = pTableFrame
'Setup table properties
pTableFrame.Table = pTable
pTableFrame.StartCol = 0
pTableFrame.StartRow = 0
'Define frame bounds
Dim pEnv As IEnvelope = New Envelope
'Allow enough space for each row in the table + the header
pEnv.PutCoords(0.5, 2.75 - (pTable.RowCount(Nothing) * 0.165 + 0.1875), 8, 2.75)
Dim userRECT As tagRECT
userRECT.top = 0
userRECT.left = 0
userRECT.right = pEnv.Width
userRECT.bottom = pEnv.Height
'Setup tableview properties
Dim pTableView2 As ITableView2 = pTableFrame.TableView
pTableView2.Table = pTable
pTableView2.Show(0, userRECT, True)
'Add the element to the specified spot
pElement.Geometry = pEnv
pGContainer.AddElement(pElement, 0)
pMxDoc.ActiveView.Refresh()
End Sub The entire, unaltered table is displayed. How do I get the abridged table to appear in the layout?
... View more
08-23-2013
12:19 PM
|
0
|
1
|
834
|
POST
|
Since you're using forward slashes in your strings, don't make them raw strings (lose the leading 'r') r"C:\Temp" = "C:\\Temp" = "C:/Temp"
... View more
04-17-2013
08:52 AM
|
0
|
0
|
413
|
POST
|
Duncan, Sorry I didn't respond sooner. I had kinda given up on getting any response from this thread. You are correct. On the second run Intersect doesn't report an error. The source layers are always the same, and the CALCACRES field is always in one of the intersected layers. Here's the odd thing I've found since the original post: If I run the code on another button between runs of this code, the second run of this code will complete.
... View more
04-08-2013
07:42 AM
|
0
|
0
|
148
|
POST
|
The answer depends on if you are running this script standalone, or as a tool from ArcMap. As a standalone, the raw_input should work: import arcgisscripting
# create the geoprocessor object
gp = arcgisscripting.create(9.3)
gp.workspace = raw_input('please enter path to workspace')
# process
layer1 = raw_input('please enter first layer')
layer2 = raw_input('please enter second layer')
gp.PointDistance_analysis(layer1, layer2, "output.dbf", "1000 meters")
etc.
If this script is being run as a tool from ArcMap, you will need to set up tool parameters, then use the appropriate gp command to insert them into the script: import arcgisscripting
# create the geoprocessor object
gp = arcgisscripting.create(9.3)
gp.workspace = gp.getparameterastext(0)
# process
layer1 = gp.getparameterastext(1)
layer2 = gp.getparameterastext(2)
gp.PointDistance_analysis(layer1, layer2, "output.dbf", "1000 meters")
etc.
FYI, if you're going to use backslashes in a hard-coded path name, either designate it as a raw string (r"I:\PDtest") or use a double backslash ("I:\\PDtest"). Using a forwardslash ("I:/PDtest") is acceptable as well.
... View more
03-22-2013
10:13 AM
|
0
|
0
|
237
|
POST
|
I have the code (VBA) below hooked up to a button in ArcMap 10.0. The first time it is used it runs successfully. If I try to run it a second time, the Intersect tool doesn't create the in_memory featureclass as expected and the code fails when it tries to run CalculateField. Any ideas as to why?
(Identify and validate pLayer & pLayer2)
...
'Intersect the PLU/soils data with the Sections
Dim pGp As IGeoProcessor
Set pGp = New GeoProcessor
pGp.OverwriteOutput = True
Dim pParams As IVariantArray
Set pParams = New VarArray
Dim PTS As String
PTS = "PlanningToolSoils"
pParams.RemoveAll
pParams.Add pLayer.Name & "; " & pLayer2.Name
pParams.Add "in_memory\" & PTS
pParams.Add "NO_FID"
pGp.Execute "Intersect_Analysis", pParams, Nothing
'Update the CALCACRES Column
pParams.RemoveAll
pParams.Add PTS
pParams.Add "CALCACRES"
pParams.Add "!shape.area@acres!"
pParams.Add "PYTHON"
pGp.Execute "CalculateField_management", pParams, Nothing
'Export the tabular portion of the FeatureClass to C:\temp\data.dbf
pParams.RemoveAll
pParams.Add PTS
pParams.Add "C:\temp\Data.dbf"
pGp.AddOutputsToMap = False
pGp.Execute "CopyRows_management", pParams, Nothing
'Delete the temporary featureclass
pMap.DeleteLayer FindLayerByName(pMap, PTS) 'A home-built function that searches for an ILayer in the TOC
pParams.RemoveAll
pParams.Add "in_memory\" & PTS
pGp.Execute "Delete_management", pParams, Nothing
... View more
03-18-2013
12:49 PM
|
0
|
2
|
644
|
POST
|
Thanks for pointing me in the right direction. Here's the code I ended up using: Dim EXCELApplication As Object
Set EXCELApplication = CreateObject("Excel.Application")
EXCELApplication.workbooks.Open <spreadsheet name>
EXCELApplication.Visible = True
... View more
02-04-2013
09:33 AM
|
0
|
0
|
501
|
POST
|
Thanks, Duncan. But what if I want to open an existing spreadsheet?
... View more
01-26-2013
05:25 PM
|
0
|
0
|
501
|
POST
|
I need to open an Excel Spreadsheet in a VBA script; I don't have access to Visual Studio, yet. When I did this before in Arc 9.x & Visual Studio 2005, I would use Process.Start(<spreadsheet path>). Is there a similar command in VBA for ArcGIS 10.0, or do I have to use the VBA Shell function?
... View more
01-25-2013
10:30 AM
|
0
|
4
|
6087
|
POST
|
I've always used the CatalogPath property of a FeatureClass or Layer's Describe object.
... View more
01-08-2013
06:40 AM
|
0
|
0
|
596
|
POST
|
1. Have you tried the Exists geoprocessing tool? 2. Take a look at some of the 'Open...' methods available in the GPUtilities class
... View more
11-07-2012
05:50 AM
|
0
|
0
|
396
|
POST
|
I would use the Topo to Raster tool in Spatial Analyst to create a raster from each of your contour layers, then calculate the difference using the raster calculator.
... View more
09-25-2012
12:06 PM
|
0
|
0
|
609
|
POST
|
Is the tool providing the string to your script written by Esri, or was it developed by someone else?
... View more
09-05-2012
04:29 AM
|
0
|
0
|
379
|
Title | Kudos | Posted |
---|---|---|
1 | 08-16-2012 01:21 PM | |
1 | 07-29-2011 07:46 AM | |
1 | 01-03-2012 07:42 AM | |
1 | 01-22-2014 11:35 AM | |
2 | 05-21-2012 04:24 AM |
Online Status |
Offline
|
Date Last Visited |
04-07-2023
09:52 PM
|