POST
|
I'm afraid I don't understand what's going on on those pages Duncan enough to understand how to apply it to my situation.
... View more
10-11-2021
08:29 AM
|
0
|
0
|
685
|
POST
|
pUID is referencing the ClassID of the tool itself. pUID.Value = "{" & SelectPoint1.ClassId & "}" SelectPoint1 or SelectPoint2 are the two tools being referenced. The full code of point of those two tools is here, it's SelectPoint1. As noted above, the other tool is the same, it just writes to a different part of the form. Imports System.Runtime.InteropServices Imports System.Drawing Imports ESRI.ArcGIS.ADF.BaseClasses Imports ESRI.ArcGIS.ADF.CATIDs Imports ESRI.ArcGIS.Framework Imports ESRI.ArcGIS.ArcMapUI Imports System.Windows.Forms Imports System.Windows.Forms.Application Imports ESRI.ArcGIS.ArcScene Imports ESRI.ArcGIS.Analyst3D <ComClass(SelectPoint1.ClassId, SelectPoint1.InterfaceId, SelectPoint1.EventsId), _ ProgId("NAME.SelectPoint1")> _ Public NotInheritable Class SelectPoint1 Inherits BaseTool #Region "COM Registration Function(s)" <ComRegisterFunction(), ComVisibleAttribute(False)> _ Public Shared Sub RegisterFunction(ByVal registerType As Type) ' Required for ArcGIS Component Category Registrar support ArcGISCategoryRegistration(registerType) 'Add any COM registration code after the ArcGISCategoryRegistration() call End Sub <ComUnregisterFunction(), ComVisibleAttribute(False)> _ Public Shared Sub UnregisterFunction(ByVal registerType As Type) ' Required for ArcGIS Component Category Registrar support ArcGISCategoryUnregistration(registerType) 'Add any COM unregistration code after the ArcGISCategoryUnregistration() call End Sub #Region "ArcGIS Component Category Registrar generated code" ''' <summary> ''' Required method for ArcGIS Component Category registration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Register(regKey) End Sub ''' <summary> ''' Required method for ArcGIS Component Category unregistration - ''' Do not modify the contents of this method with the code editor. ''' </summary> Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type) Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Unregister(regKey) End Sub #End Region #End Region #Region "COM GUIDs" ' These GUIDs provide the COM identity for this class ' and its COM interfaces. If you change them, existing ' clients will no longer be able to access the class. Public Const ClassId As String = "a38b65c3-255c-4578-ab06-2e00c59efa2d" Public Const InterfaceId As String = "042a7209-0920-4531-95be-9bcbb0f4a64d" Public Const EventsId As String = "c94af36c-0e76-43ad-96ad-28d77b008c17" #End Region Private m_application As IApplication ' A creatable COM class must have a Public Sub New() ' with no parameters, otherwise, the class will not be ' registered in the COM registry and cannot be created ' via CreateObject. Public Sub New() MyBase.New() MyBase.m_category = Work tools" MyBase.m_caption = "Select Point" MyBase.m_message = "Select Point" MyBase.m_toolTip = "Select Point1" MyBase.m_name = "SelectPoint1" Try Dim bitmapResourceName As String = Me.GetType().Name + ".bmp" MyBase.m_bitmap = New Bitmap(Me.GetType(), bitmapResourceName) MyBase.m_cursor = New System.Windows.Forms.Cursor(Me.GetType(), Me.GetType().Name + ".cur") Catch ex As Exception System.Diagnostics.Trace.WriteLine(ex.Message, "Invalid Bitmap") End Try End Sub Public Overrides Sub OnCreate(ByVal hook As Object) If Not hook Is Nothing Then m_application = CType(hook, IApplication) 'Disable if it is not ArcMap or ArcScene If TypeOf hook Is IMxApplication Or TypeOf hook Is ESRI.ArcGIS.ArcScene.ISxApplication Then MyBase.m_enabled = True Else MyBase.m_enabled = False End If End If ' TODO: Add other initialization code End Sub Public Overrides Sub OnClick() 'TODO: Add SelectPoint1.OnClick implementation End Sub Public Overrides Sub OnMouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) Dim pPoint As ESRI.ArcGIS.Geometry.IPoint = Nothing Dim pFeatures As Collection = Nothing Dim pFeature As ESRI.ArcGIS.Geodatabase.IFeature = Nothing If TypeOf m_pApp Is ESRI.ArcGIS.ArcMapUI.IMxApplication Then ' If the tool applies to an active view make sure the right map is showing pPoint = m_pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y) Dim pMap As ESRI.ArcGIS.Carto.IMap pMap = m_pActiveView.HitTestMap(pPoint) If pMap Is Nothing Then Exit Sub If Not pMap Is m_pActiveView.FocusMap Then m_pActiveView.FocusMap = pMap m_pActiveView.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGraphics, Nothing, Nothing) End If NAME.GetClosestFeature((m_pActiveView.FocusMap), pPoint, pFeatures, pFeature) ElseIf TypeOf m_pApp Is ESRI.ArcGIS.ArcScene.ISxApplication Then Dim pSxDoc As ESRI.ArcGIS.ArcScene.ISxDocument pSxDoc = m_pApp.Document Dim pScene As IScene pScene = pSxDoc.Scene Dim pSG As ESRI.ArcGIS.Analyst3D.ISceneGraph pSG = pScene.SceneGraph Dim pOwner As stdole.IUnknown = Nothing Dim pObject As stdole.IUnknown = Nothing pSG.Locate(pSG.ActiveViewer, X, Y, ESRI.ArcGIS.Analyst3D.esriScenePickMode.esriScenePickGeography, True, pPoint, pOwner, pObject) If (pPoint Is Nothing) Then Beep() Exit Sub End If NAME.GetClosestSceneFeature(pScene, pPoint, pFeatures, pFeature) End If Dim SelectDistanceForm As frmSelectDistance If OpenForms.Item("frmSelectDistance") IsNot Nothing Then 'exists SelectDistanceForm = OpenForms.Item("frmSelectDistance") Else SelectDistanceForm = Nothing 'not exists End If If (pFeature Is Nothing) Then SelectDistanceForm.txtLatitude1.Text = "" SelectDistanceForm.txtLongitude1.Text = "" Exit Sub End If Dim lngField As Integer lngField = pFeature.Fields.FindField(SelectDistanceForm.cbxLatitude.Text) SelectDistanceForm.txtLatitude1.Text = CStr(pFeature.Value(lngField)) lngField = pFeature.Fields.FindField(SelectDistanceForm.cbxLongitude.Text) SelectDistanceForm.txtLongitude1.Text = CStr(pFeature.Value(lngField)) End Sub Public Overrides Sub OnMouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) 'TODO: Add SelectPoint1.OnMouseMove implementation End Sub Public Overrides Sub OnMouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Integer, ByVal Y As Integer) 'TODO: Add SelectPoint1.OnMouseUp implementation End Sub End Class
... View more
10-04-2021
11:39 AM
|
0
|
1
|
718
|
POST
|
hello I have a custom extension created in VB.NET for ArcGIS. In one of the forms I have two tools which do very similar things (select a point from the map area) and so the code is rather similar. One of the tools works but the other throws a NullReferenceException. It happens because the following line returns nothing: pCommandItem = Application.Document.CommandBars.Find(pUID, False, False) However, and this is what is confusing to me - apart of course from why the two tools with similar wording has one not work ... If I add the tool to the ToolBar for the whole extension then it works in this form. This is not a good solution since I do not want the tool in the ToolBar - it only works in relation to what the form is doing. But why should it be working if it is added to the ToolBar, but not if it, and the similar tool are added to the Form? Any ideas? cheers shawn
... View more
09-08-2021
01:38 PM
|
0
|
4
|
839
|
POST
|
hey Weifang Thanks very much, that worked. I didn't think to try doing it that way at all. That's so simple, and so elegant - exactly what I was hoping for. cheers shawn
... View more
10-29-2020
09:21 AM
|
0
|
0
|
741
|
POST
|
hello, I have some VB.NET code which is constructing a line piece by piece from a set of coordinates in a table. I was creating the separate iLine and then adding those to a Path object. Once the series of point composing the line is finished then I add that Geometry into a Polyline. And that works. It has recently transpired that creating that I want to create the line as geodesics or loxodromes, depending upon the line. I found the ConstructGeodeticLineFromPoints member of the IConstructGeodetic interface. But this creates Polylines so the previous code I had with Paths is no longer working. I am trying to Union my spearate geodetically accurate polyline segments with a TopologicalOperator but that is taking a whole lot longer and runs into problems after a while. I was trying to look into SegmentCollections and GeometryCollections to mimic what I had been doing previously with iLines and Paths, but it doesn't seem to be working. Does anybody have any experience with easily joining together polyline elements programatically together? cheers shawn
... View more
10-15-2020
01:55 PM
|
1
|
2
|
798
|
POST
|
hello I have a .net script where I am clipping and then merging rasters based on user input. I notice that for one raster that everything is working fine, but for another raster that the Merge or Mosaic command shifts the resultant merged raster slightly. The offending line of code is: pRasterGeometryProc.Mosaic(strFile, pRasterWorkspace, "GRID", pRasterInfo.CellSize.X, pSR, pRaster) The two individual rasters which are part of the RasterBandCollection are in the correct location, but once merged they're not. Has anybody else experienced this?
... View more
01-25-2018
09:02 AM
|
0
|
1
|
552
|
POST
|
aha a bit more hunting found the answer. It's a known bug in 10.4 and 10.4.1 BUG-000099718 -> Numeric values stored in DOUBLE and FLOAT fields are corrupted in shapefiles created in ArcGIS for Desktop 10.4 and 10.4.1. Shapefiles that are created at earlier versions perform correctly when opened in ArcGIS for Desktop 10.4. cheers shawn
... View more
11-21-2016
09:30 AM
|
0
|
0
|
974
|
POST
|
hello Neil I am creating some data as part of a process in VB.NET and then I want to add that data to an existing shapefile. I didn't think that the actual particulars of what I was doing was relevant to the underlying question that I had and didn't want to obscure my question. Thanks for the link, although my reading of it is that it can support precision and scale. This also supports my recollection that my script used to add the field with precision and scale values in the past. Although we don't have earlier versions of ArcGIS installed here at work we do have ArcView 3.3 still working. So I tested in that the addition of a field with precision and scale values to a shapefile. The shapefile when opened in ArcGIS 10.4.1 reports the precision and scale correctly. When I tried to add a new field directly through the table interface in ArcMap it did not create the field with precision and scale values. regards shawn
... View more
11-21-2016
08:27 AM
|
0
|
0
|
974
|
POST
|
hello All I have a VB.NET set of tools and part of it which used to work does not seem to work any more as it used to. The part of the script which is not working properly anymore is when adding a field to an existing shapefile. Although I am setting the precision and scale properties of the ifieldedit interface the resultant field displays in ArcMap as having precision and scale values of 0. The type of the field is esriFieldTypeDouble. What am I missing here? regards shawn
... View more
11-18-2016
01:30 PM
|
0
|
5
|
1729
|
POST
|
When Visual Studio compiles your ESRI components, it registers them in the ESRI component categories. In order to do this, it must have write access to the system registry. You have a couple of options - run Visual Studio as an administrator every time you start it up or turn off UAC on your machine. If you're registering your component via Add from File on the Customize dialog in ArcMap (not the optimal way of doing it if you're actively developing) then ArcMap must be running as an administrator (or turn off UAC). This will not impact your users. When your application is deployed, the Windows installer will kick off the registration. Of course, it must be running with elevated privileges but that is standard. Installing software is a task that should only be performed by an administrator. The only way around all of this is to rewrite your application as an addin. Addins do not require admin privileges to deploy. hello Neil and Agray1 It wasn't the running of Visual Studio as an administrator, or installing the extension as an administrator which was a problem. As the UAC policy is controlled centrally here I don't have any ability to control that. What the problem was, and my apologies for not being clear, is that a tool in the extension which brought up a window and allowed a number of things to be done. One of those things calls another tool (the second tool is not visible in the tool bar). This second tool was not working. I tried adding it to the extensions toolbar - and it worked. I tried running ArcGIS with administrator rights (when the second tool was not in the extensions toolbar - and it worked). Neither of these were acceptable. This morning I looked back at the setup project and then started comparing it to what it should look like - Neil, your comment in another thread make me think about this option http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/How_to_deploy_a_custom_component_using_a_setup_project/00010000016r000000/ For some reason I had stopped before the Registering the CustomComponent .dll file using ESRIRegAsm.exe step of the process. So I did this step of the process. And now it works. cheers shawn
... View more
09-25-2013
08:27 AM
|
0
|
0
|
743
|
POST
|
I finally figured out what the problem was. Unfortunately, I was doing everything properly with regard to registration of tool being accessed. After going back, and forth, and back and forth again I noticed in the code generated code on the tool the following: Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID) MxCommands.Register(regKey) most particularly I noticed the word Register One of the new things about our organisations move to Windows 7 has been greater security restrictions set on the computers. If I run ArcGIS with administrator privileges, then everything runs OK. The tool is now registered and can be accessed from another tool. Is there anything I can do to get around this? Note, that running ArcGIS with administrator privileges is not an option for all of the intended users of the extension. cheers shawn
... View more
09-24-2013
12:42 PM
|
0
|
0
|
743
|
POST
|
Hello We have recently moved our computers from Windows NT to Windows 7, and at the same time we've upgraded from ArcGIS 10.1 to 10.2. I have an ArcGIS extension created in Visual Basic 2010, which had been running well in the previous set up. I have moved things over onto my new computer in this new environment, and now something is not working. I have on some of my forms a click event which access one of the tools elsewhere in the same extension. When the click event is accessed now a unhandled exception error comes up "Object reference not set to an instance of an object". I've obviously missed, or forgotten doing something which I had previously done. Could anyone help with what that might be. Here is the offending click event ... Private Sub cmdSelect1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles cmdSelect1.Click Dim pUID As ESRI.ArcGIS.esriSystem.UID = New ESRI.ArcGIS.esriSystem.UID Dim pCommandItem As ESRI.ArcGIS.Framework.ICommandItem = Nothing Dim Application As ESRI.ArcGIS.Framework.IApplication = m_pApp pUID.Value = "{" & SelectFPoint.ClassId & "}" pCommandItem = Application.Document.CommandBars.Find(pUID, False, False) pCommandItem.Execute() End Sub
... View more
09-23-2013
01:38 PM
|
0
|
5
|
1156
|
POST
|
Is it possible to programatically add a new 'data frame' into ArcScene? cheers shawn
... View more
01-11-2012
11:27 AM
|
0
|
1
|
929
|
POST
|
If your Command/Tool does not have any registration code and you are manually "Add From File" via the Customize dialog, then try to add the type library (.tbl) file instead of the .dll file. http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#//00010000040v000000 thanks James, that worked perfectly ... will worry about proper deployment of the whole thing once I've reached that stage ...
... View more
10-31-2011
12:55 PM
|
0
|
0
|
219
|
POST
|
hello I have been updating an ArcGIS extension which I created in VB6 into VB.NET using Visual Studio 2008. I have been working on the ArcMap tools and commands and everything is working well so far - the tools etc are working. I started to today with an ArcScene tool and when I tried to add the dll file of the extension in ArcScene I get the following message: "Can't load type library from specified file." What I have missed? cheers shawn
... View more
10-14-2011
07:44 AM
|
0
|
2
|
807
|
Title | Kudos | Posted |
---|---|---|
1 | 10-15-2020 01:55 PM |
Online Status |
Offline
|
Date Last Visited |
01-02-2024
04:15 PM
|