POST
|
Damn. It's so easy to make it work in Python with 1 line of code and I can't make it with VBScript ...
... View more
06-23-2016
01:51 AM
|
0
|
0
|
661
|
POST
|
Hello, Yes, I also made the change for the "Dim pArea" line. With no success. I tried to execute this code manually in ArcGis desktop. But unfortunately, it did'nt work. I'm realizing that I should write the good script here before trying to program it. . I made many tries in VB. Tthe only thing that were working correctly (manually, in desktop ) was in Python with that code : !shape.centroid.X! But I just can't make it work in the program.
... View more
06-21-2016
03:34 AM
|
0
|
0
|
661
|
POST
|
Hello, Thank you. I just made the change you proposed without any success. The following error is still showing : "Error -2147467259 HRESULT E_FAIL has been returned from a call to a COM component"
... View more
06-20-2016
04:58 AM
|
0
|
1
|
661
|
POST
|
Hello, I have migrated an toolbar initially developped for ArcGis 9,3. This tool is used by non-programmer or cartographers. One procedure is called to generate centroids of attributes table and after to launch an calculation. Anyway, The source code used in 9,3 was : (A) 'instantiating new calculator and cursor pCalculator = New Calculator pCursor = CType(pFeatureClass.Update(Nothing, True), ICursor) 'Centroid Y With pCalculator .Cursor = pCursor .PreExpression = "Dim pGeomShp as IGeometry" & vbNewLine & "Set pGeomShp = [shape]" & vbNewLine & "Dim pArea as IArea" & vbNewLine & "Set pArea = pGeomShp" & vbNewLine .Expression = "pArea.Centroid.Y" .Field = "centroidY" End With 'try & catch ************************************************* Try pCalculator.Calculate() Catch ex As System.Exception MessageBox.Show("Error: " + ex.Message) End Try This was working until moving to ArcGis 10 (an upper). A crash was observed while launching pCalculator.Calculate(). I’ve migrated this code that way (like proposed here http://gis.stackexchange.com/questions/52983/syntax-for-arcgis-icalculator-object/198681#198681 ) : (B) Dim nCentroidXFieldIndex As Integer = pFeatureClass.FindField("centroidX") Dim nCentroidYFieldIndex As Integer = pFeatureClass.FindField("centroidY") Dim nBldg_sizeFieldIndex As Integer = pFeatureClass.FindField("Bldg_size") If TypeOf pFeatureClass Is IFeatureClass Then If TypeOf pFeatureCursor Is IFeatureCursor Then Dim pArea As IArea Dim pFeature As IFeature = pFeatureCursor.NextFeature() Dim myProgressCalc As New FileProgressForm myProgressCalc.set_maximum(iTotalRecords) myProgressCalc.Show() myProgressCalc.Text = "Veuillez patienter svp" myProgressCalc.lblProgress.Text = "Calcul des données géographiques" myProgressCalc.Update() pArea = CType(pFeature.Shape, IArea) While pFeature IsNot Nothing pFeature.Value(nCentroidXFieldIndex) = pArea.Centroid.X pFeature.Value(nCentroidYFieldIndex) = pArea.Centroid.Y pFeature.Value(nBldg_sizeFieldIndex) = pArea.Area pFeature.Store() pFeature = pFeatureCursor.NextFeature myProgressCalc.Go() End While myProgressCalc.Close() End If End If It’s working but it’s working extremely slowly ! The first code (A) was executed in less than 3 minutes. The new one (B) in 25 minutes ! In fact, I just want to programmaticaly call a the new calculate geometry tool (when displaying attributes table - http://desktop.arcgis.com/fr/arcmap/10.3/manage-data/tables/calculating-area-length-and-other-geometric-properties.htm ) Screen capture 1 Too bad, can't upload PNG and JPEG files... or Arc tool => Data Management Tools => Entities => Add geometric attributes (http://pro.arcgis.com/fr/pro-app/tool-reference/data-management/add-geometry-attributes.htm ) Screen capture 2 or any other methods ! Both tools are working great in ArcGis Desktop but I can’t find my way to make them work in VB.NET. Please, any suggestions ? (It’s just driving me crazy). Thanks by advance for your answer, and sorry for screen capture in french and for poor english speaking Matthieu
... View more
06-17-2016
02:08 AM
|
0
|
6
|
2671
|
Online Status |
Offline
|
Date Last Visited |
11-13-2023
03:04 PM
|