|
POST
|
What are the Geoprocesses that you're using to create these in memory tables? You mentioned that you have a problem when you run the process more than one time. Can you set the OverwriteOutput property to true? You can get the reference from an object created by a geoprocessing tool. Here's an example of creating a table and returning a reference for that table. This is from code I've written for ArcGIS 10, but hopefully the interfaces would be applicable for ArcGIS 9.2 (although you'd probably have to use previous versions, like IGeoProcessorResult instead of IGeoProcessorResult2)
Friend Function CreateNewTable(ByVal TableLocation As String, ByVal TableName As String) As ESRI.ArcGIS.Geodatabase.ITable
Dim NewTable As New ESRI.ArcGIS.DataManagementTools.CreateTable
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Try
Using releaser As New ESRI.ArcGIS.ADF.ComReleaser
releaser.ManageLifetime(NewTable)
NewTable.out_path = TableLocation
NewTable.out_name = TableName
Result = RunTool(NewTable, Nothing)
If Result Is Nothing Then Return Nothing
Return ReturnObjectfromResult(Result, "Table")
End Using
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString & vbNewLine & ex.StackTrace.ToString, "Create Table")
Return Nothing
End Try
End Function
Friend Function RunTool(ByVal Process As ESRI.ArcGIS.Geoprocessor.IGPProcess, ByVal TC As ESRI.ArcGIS.esriSystem.ITrackCancel2, Optional ByVal AddOutput As Boolean = False) As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Dim Result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2
Try
System.Windows.Forms.Cursor.Current = Windows.Forms.Cursors.WaitCursor
Dim GP As New ESRI.ArcGIS.Geoprocessor.Geoprocessor
GP.AddOutputsToMap = AddOutput
Result = CType(GP.Execute(Process, Nothing), ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2)
If Result.Status <> ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded Then ReturnMessages(Result, "Geoprocessing Error")
GP.ClearMessages()
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "Run Geoprocessor")
End Try
Return Result
End Function
Friend Function ReturnObjectfromResult(ByVal result As ESRI.ArcGIS.Geoprocessing.IGeoProcessorResult2, ByVal Type As String) As Object
Dim GPVal As ESRI.ArcGIS.Geodatabase.IGPValue
Dim InMemFC As String
Dim GPUtil As ESRI.ArcGIS.Geoprocessing.IGPUtilities3 = New ESRI.ArcGIS.Geoprocessing.GPUtilities
Try
GPVal = result.GetOutput(0)
InMemFC = GPVal.GetAsText()
Select Case Type
Case "Feature Class"
Return GPUtil.OpenFeatureClassFromString(InMemFC)
Case "Table"
Return GPUtil.OpenTableFromString(InMemFC)
Case "Feature Layer"
Return GPUtil.OpenFeatureLayerFromString(InMemFC)
Case Else
Return Nothing
End Select
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "ReturnObjectfromResult error")
Return Nothing
End Try
End Function
... View more
05-22-2012
11:37 AM
|
0
|
0
|
1981
|
|
POST
|
What does your Config.esriaddinx and Extension code look like?
... View more
05-22-2012
11:10 AM
|
0
|
0
|
1398
|
|
POST
|
Great. Don't forget to mark the question as answered.
... View more
05-22-2012
11:08 AM
|
0
|
0
|
840
|
|
POST
|
Since you're working in C#, try pLayer = pMap.get_Layer(i);
... View more
05-22-2012
09:12 AM
|
0
|
0
|
840
|
|
POST
|
Sure. Here's one way to do it in an edit session as an Add-in. And don't forget to mark the question as answered.
Private pEditLayers As ESRI.ArcGIS.Editor.IEditLayers = My.ArcMap.Editor
Private pEditor As ESRI.ArcGIS.Editor.IEditor = My.ArcMap.Editor
Private Sub SplitFeature(ByRef pfeature As ESRI.ArcGIS.Geodatabase.IFeature, ByRef pSplitPoints As ESRI.ArcGIS.Geometry.IPointCollection)
Dim pEnumVertex As ESRI.ArcGIS.Geometry.IEnumVertex
Dim pGeoColl As ESRI.ArcGIS.Geometry.IGeometryCollection
Dim pPolyCurve As ESRI.ArcGIS.Geometry.IPolycurve2
Dim pEnumSplitPoint As ESRI.ArcGIS.Geometry.IEnumSplitPoint
Dim pNewFeature As ESRI.ArcGIS.Geodatabase.IFeature
Try
pfeature.Shape.Project(pEditor.Map.SpatialReference)
pEnumVertex = pSplitPoints.EnumVertices
pPolyCurve = pfeature.Shape
pEnumSplitPoint = pPolyCurve.SplitAtPoints(pEnumVertex, True, True, -1)
If Not pEnumSplitPoint.SplitHappened Then Exit Sub
pGeoColl = pPolyCurve
pfeature.Shape = BuildPolyline(pGeoColl.Geometry(0))
pfeature.Store()
For i As Integer = 1 To pGeoColl.GeometryCount - 1
pNewFeature = pEditLayers.CurrentLayer.FeatureClass.CreateFeature
pNewFeature.Shape = BuildPolyline(pGeoColl.Geometry(i))
CopyAttributes(pfeature, pNewFeature)
pNewFeature.Store()
Next
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "SplitLine: SplitFeatures")
End Try
End Sub
Private Function BuildPolyline(ByRef pSegColl As ESRI.ArcGIS.Geometry.ISegmentCollection) As ESRI.ArcGIS.Geometry.IPolyline
Dim pPolyline As ESRI.ArcGIS.Geometry.IGeometryCollection = New ESRI.ArcGIS.Geometry.Polyline
Dim pGeometry As ESRI.ArcGIS.Geometry.IGeometry
Try
pGeometry = pPolyline
pGeometry.SpatialReference = pEditor.Map.SpatialReference
pPolyline.AddGeometries(1, pSegColl)
Return pPolyline
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "SplitLine: BuildPolyline")
Return Nothing
End Try
End Function
Private Sub CopyAttributes(ByRef pInFeature As ESRI.ArcGIS.Geodatabase.IFeature, ByRef pOutFeature As ESRI.ArcGIS.Geodatabase.IFeature)
Dim pField As ESRI.ArcGIS.Geodatabase.IField
Dim pFields As ESRI.ArcGIS.Geodatabase.IFields
Try
pFields = pInFeature.Fields
For i As Integer = 0 To pFields.FieldCount - 1
pField = pFields.Field(i)
If pField.Editable Then
If Not pField.Type = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID And Not pField.Type = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry Then
pOutFeature.Value(i) = pInFeature.Value(i)
End If
End If
Next
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.ToString, "SplitLine: CopyAttributes")
End Try
End Sub
... View more
05-17-2012
07:43 AM
|
1
|
0
|
2788
|
|
POST
|
Glad to help. Don't forget to mark the question as answered.
... View more
05-16-2012
06:07 AM
|
0
|
0
|
1393
|
|
POST
|
Here's how I split a polyline using points.
Private Sub SplitFeature(ByRef pfeature As ESRI.ArcGIS.Geodatabase.IFeature, ByRef pSplitPoints As ESRI.ArcGIS.Geometry.IPointCollection)
Dim pEnumVertex As ESRI.ArcGIS.Geometry.IEnumVertex
Dim pPolyCurve As ESRI.ArcGIS.Geometry.IPolycurve2
Dim pEnumSplitPoint As ESRI.ArcGIS.Geometry.IEnumSplitPoint
pEnumVertex = pSplitPoints.EnumVertices
pPolyCurve = pfeature.Shape
pEnumSplitPoint = pPolyCurve.SplitAtPoints(pEnumVertex, True, True, -1)
'You can check to see if the line was actually split if you need to do more things with the resultant polylines.
'If Not pEnumSplitPoint.SplitHappened Then Exit Sub
End Sub
... View more
05-15-2012
06:45 AM
|
0
|
0
|
2788
|
|
POST
|
Here's an example that ESRI support sent to me on using several inputs for the Intersect tool ESRI.ArcGIS.Geoprocessor.Geoprocessor GP = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); GP.OverwriteOutput = true; IGPUtilities2 gpUtils = new GPUtilitiesClass(); IFeatureClass inFeature1 = gpUtils.OpenFeatureClassFromString(@"E:\Test.gdb\states"); IFeatureClass inFeature2 = gpUtils.OpenFeatureClassFromString(@"E:\Test.gdb\us_rivers"); IGpValueTableObject vt = new GpValueTableObjectClass(); //vt.SetColumns(1); vt.SetColumns(2); object weight; weight = 1 as object; object obj1 = inFeature1; vt.AddRow(ref obj1); vt.SetValue(0, 1, ref weight); object obj2 = inFeature2; vt.AddRow(ref obj2); vt.SetValue(1, 1, ref weight); ESRI.ArcGIS.AnalysisTools.Intersect intersect = new ESRI.ArcGIS.AnalysisTools.Intersect(); intersect.in_features = vt; intersect.out_feature_class = "E:\testout.shp"; GP.Execute(intersect, null);
... View more
05-15-2012
06:04 AM
|
0
|
0
|
1393
|
|
POST
|
Actually, it doesn't mention Service Pack 1 for Visual Studios 2010: [TD="class: rteleft"] ArcGIS Desktop, ArcGIS Engine Runtime or ArcGIS Server is required to develop with the ArcObjects SDK. Microsoft .NET Framework 3.5 SP1 [/TD] ArcObjects SDK for the Microsoft .NET Framework Microsoft Visual Studio 2008 SP1 Visual Basic Express Microsoft Visual Studio 2008 SP1 Visual C# Express Microsoft Visual Studio 2008 SP1 (C#, VB.NET) Standard, Professional, Team Edition Microsoft Visual Studio 2010 (C#, VB.NET) Professional, Premium, Ultimate Edition
... View more
05-09-2012
04:56 AM
|
0
|
0
|
1993
|
|
POST
|
It's a little old (and not in C#), but here's an example of splitting a line with points
... View more
05-07-2012
01:49 PM
|
0
|
0
|
1279
|
|
POST
|
I have just gone through my code again using the Cut Polygon Features task. It tests the size of the newly cut polygon and if it doesn't meet the minimum size and I don't want to add it, it will delete the new feature and revert to the original polygon. This operation does not result in any additional vertices.
... View more
05-04-2012
05:41 AM
|
0
|
0
|
2839
|
|
POST
|
By the way, I was able to solve my problem with the view not refreshing after applying a renderer. In my case, I had a routine to create a new featureclass and apply a renderer, but new layer wouldn't get the renderer applied to it. I had a separate routine to just apply a renderer to a selected layer, which did work properly. So I ended up just calling that separate routine at the end of the create new featureclass routine and the renderer was applied as expected. Maybe it's a related bug.
... View more
05-03-2012
06:11 AM
|
0
|
0
|
2597
|
|
POST
|
That ID should work. In my add-in, I get a reference to the editor by using Dim theEditor As ESRI.ArcGIS.Editor.IEditor = My.ArcMap.Editor I noticed that you didn't delete createdFeature (createdFeature.Delete())
... View more
05-03-2012
06:00 AM
|
0
|
0
|
2839
|
|
POST
|
Here's an Add-in I'm working on that checks for a minimum polygon size (which is a setting found in a dictionary, theDict). In my OnCreateFeature sub, I check the minimum size. pInFeature = CType(obj, ESRI.ArcGIS.Geodatabase.IFeature) CanDelete = False pFClass = CType(pDataset, ESRI.ArcGIS.Geodatabase.IFeatureClass) If pFClass.ShapeType = ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon Then pArea = pInFeature.Shape If theDict.TryGetValue("HDX.MMU", MMUList) Then If pArea.Area < MMUList(1) Then If Windows.Forms.MessageBox.Show("The area of the polygon (" & Format(pArea.Area, "##,##0.00") & ") is less than the specified Minimum Mapping Unit." & vbNewLine & vbNewLine & "Do you want to add this polygon to your layer?", "Area Smaller than MMU", Windows.Forms.MessageBoxButtons.YesNo, Windows.Forms.MessageBoxIcon.Question) = Windows.Forms.DialogResult.No Then pInFeature.Delete() CanDelete = True Exit Sub End If End If End If End If Then in the OnStopOperation sub (one of the Editor2 events), I remove the last operation if the polygon will be deleted. I have stepped through this code and the OperationStack does have the last operation removed. Private Sub OnStopOperation() Dim LastOp As Integer Dim pOperation As ESRI.ArcGIS.SystemUI.IOperation Try LastOp = My.ArcMap.Document.OperationStack.Count - 1 If CanDelete Then If LastOp > -1 Then pOperation = My.ArcMap.Document.OperationStack.Item(LastOp) If pOperation.CanUndo Then pOperation.Undo() My.ArcMap.Document.OperationStack.Remove(LastOp) Else System.Windows.Forms.MessageBox.Show("Can't undo last operation", "", Windows.Forms.MessageBoxButtons.OK, Windows.Forms.MessageBoxIcon.Exclamation) End If End If End If Catch ex As Exception System.Windows.Forms.MessageBox.Show(ex.ToString, "EditorExtention: OnStopOperation") End Try End Sub
... View more
05-02-2012
07:27 AM
|
0
|
0
|
2839
|
|
POST
|
Glad to hear it worked and that you caught that extra "Globals." It was a remnant of the original code, which I modified for this example. I just didn't modify it well enough...
... View more
04-30-2012
07:18 AM
|
0
|
0
|
1863
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|