POST
|
Hi, I have some vb.net code which worked in ArcMap 9.3.1 but fails in 10.2, and was hoping someone may be able to shed some light on the matter. I'm using code which started its life as part of the DS Mapbook add on. It creates a new ESRI.ArcGIS.esriSystem.CategoryFactory and sets the CategoryID to esriExportsCat. It then loops thought the CategoryFacotry creating an exporter object for supported export file type (in this case the target is PDF). However after, creating exporter objects for BMP, GIF and EPS, the loop crashes with the following error: Unable to cast COM Object of type 'System._ComObject to interface type 'ESRI.ArcGIS.Output.IExport'... [ATTACH=CONFIG]31969[/ATTACH] Can anybody help? I've posed the function below. The parameter string "PDF" is being passed to the function. Private Function GetTheLastExport(ByRef sExportType As String) As ESRI.ArcGIS.Output.IExport
On Error GoTo ErrorHand
Dim pTempExport As ESRI.ArcGIS.Output.IExport
Dim i As Short
Dim esriExportsCat As New ESRI.ArcGIS.esriSystem.UID
Dim pCategoryFactory As ESRI.ArcGIS.esriSystem.ICategoryFactory
Dim TempExportersCol As New Collection
Dim pSettingsInRegistry As ESRI.ArcGIS.Output.ISettingsInRegistry
Dim sLastUsedExporterName As String
Dim lLastUsedExporterPriority As Integer
'Use a Category Factory object to create one instance of every class registered
' in the "ESRI Exports" category.
'Component Category: "ESRI Exports" = {66A7ECF7-9BE1-4E77-A8C7-42D3C62A2590}
344: esriExportsCat.Value = "{66A7ECF7-9BE1-4E77-A8C7-42D3C62A2590}"
345: pCategoryFactory = New ESRI.ArcGIS.esriSystem.CategoryFactory
346: pCategoryFactory.CategoryID = esriExportsCat
'As each exporter object is created, add it to a vb collection object for later use.
' Use each exporter object's Priority property as a unique static key for later
' access to each object in the collection. Because some exporters change their file
' extension based on settings (eg. SVG), we should read and sync the registry values
' for each exporter after it is created.
353: pTempExport = pCategoryFactory.CreateNext
354: Do While Not pTempExport Is Nothing
355: If pTempExport.Name = sExportType Then
356: Exit Do
357: End If
MsgBox(pTempExport.Name)
'XXX crashing on next line (never gets to PDF)
359: pTempExport = pCategoryFactory.CreateNext
360: Loop
'Set the exporter properties to whatever they were for the last user
363: pSettingsInRegistry = pTempExport
364: If Not pSettingsInRegistry Is Nothing Then
365: pSettingsInRegistry.RestoreForCurrentUser("Software\ESRI\Export\ExportObjectsParams")
366: End If
368: GetTheLastExport = pTempExport
Exit Function
ErrorHand:
372: MsgBox("DSMapBookExt_GetTheLastExport - " & Erl() & " - " & Err.Description)
End Function
... View more
03-05-2014
03:48 PM
|
0
|
0
|
471
|
POST
|
Hi All, I have a polyline feature class in a geodatabase. This feature class is registered as versioned and has Archiving enabled. I would like to know if/how one would go about editing the history/archive table using ArcObjects. I am interested in adding new records to the history/archive table programmatically. I???m sure doing so probably does not come highly recommended, but none the less, it???s an avenue which I would like to prove/disprove. Here???s what I have tried, without luck (ArcMap Crashes): Private Sub editHistoryTable()
' set and conect to the database workspace
Dim pFeatureWorkspace As IFeatureWorkspace = dbConnection()
Dim pFeatureClass As IFeatureClass = Nothing
' access the history table
Dim pTable As ITable = pFeatureWorkspace.OpenTable("Road_H")
pFeatureClass = pTable
Dim pRow As IRow
' set the edit envionment
Dim pMultiuserWorkspaceEdit As IMultiuserWorkspaceEdit = CType(pFeatureWorkspace, IMultiuserWorkspaceEdit)
Dim pWorkspaceEdit As IWorkspaceEdit = CType(pFeatureWorkspace, IWorkspaceEdit)
' start nonversioned edit (I assume the history table itself is not versioned)
pMultiuserWorkspaceEdit.StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned)
' start an edit operation
pWorkspaceEdit.StartEditOperation()
' add a new row
pRow = pTable.CreateRow
pRow.Store()
' save/end the edit operation
pWorkspaceEdit.StopEditOperation() ' CRASHES HERE
pWorkspaceEdit.StopEditing(True)
End Sub I am using 9.3.1 SP1 and a SDE Personal Geodatabase. Any help would be much appreciated. Regards. Rob.
... View more
07-17-2010
11:01 PM
|
0
|
0
|
267
|
POST
|
Hi Stefan, Thanks for the reply. Your code is certainly a lot simpler than the example I was working from. Having said this, ArcMap is still crashing each time it gets to the final line (see attachment for error). Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim GP As IGeoProcessor = New GeoProcessor
'Declare variables for input
Dim in_features As String
Dim out_path As String
Dim out_name As String
in_features = "C:\temp\TR_ROADS.shp"
out_path = "C:\temp"
out_name = "aaa.shp"
GP.FeatureclassToFeatureclass_conversion(in_features, out_path, out_name)
End Sub I also found another example which supposedly take a shape file, creates a Personal GDB and writes the shape file to a feature class within: Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim GP As Object = CreateObject("esriGeoprocessing.GpDispatch.1")
Dim filepath As String = "c:\temp\"
GP.workspace = filepath
GP.CreatePersonalGDB_management(filepath, "aaa.mdb")
GP.FeatureclassToFeatureclass_conversion("TR_ROADS.shp", "aaa.mdb", "roads")
End Sub This code created the the MDB OK, but again crashes on the final line (an MDA error is also displayed via visual studio). Can anyone help me get to the bottom of this? Regards. Rob.
... View more
06-13-2010
06:35 PM
|
0
|
0
|
513
|
POST
|
Hi, I am writing an extension for ArcMap using ArcObjects and VB.Net. As part of this extension I would like to access the �??Feature Class to Feature Class�?? geoprocessing tool using ArcObjects. Using the example in http://edndoc.esri.com/arcobjects/9.2/CPP_VB6_VBA_VCPP_Doc/COM/gp/Using%20Geoprocessing%20Tools%20in%20VB.pdf as a guide, I have managed to come up with the code below. This code however causes ArcMap to crash at the GP.Execute line. I have read the help file for this tool which suggests that the �??in_features�?? and �??out_path�?? need to be of types IFeatureLayer and IWorkspace respectively. Unfortunately I don�??t know how to set the properties correctly for this interface. http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/conversion_tools/feature_class_to_feature_class_conversion_.htm Also am I correct in setting the optional parameters to Nothing? Or should I not declare/set these at all? To start with I�??m just looking to go from SHP to SHP, but ultimately the goal will be SHP to SDE. Can anyone help me out? Thanks. Rob. Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
Dim GP As IGeoProcessor = New GeoProcessor
'Dim gp As ESRI.ArcGIS.Geoprocessor.Geoprocessor = New ESRI.ArcGIS.Geoprocessor.Geoprocessor
'Declare variables for input
Dim in_features As String
Dim out_path As String
Dim out_name As String
Dim where_clause As String
Dim field_mapping As String
Dim config_keyword As String
'Define the input/output parameter
in_features = "C:\temp\roads.shp"
out_path = "C:\temp"
out_name = "aaa.shp"
where_clause = Nothing
field_mapping = Nothing
config_keyword = Nothing
'Declare and set a variant array
Dim parameters As IVariantArray
parameters = New VarArray
'Populate the variant array with
parameters.Add(in_features)
parameters.Add(out_path)
parameters.Add(out_name)
parameters.Add(where_clause)
parameters.Add(field_mapping)
parameters.Add(config_keyword)
'GP.FeatureclassToFeatureclass_conversion(in_features, out_path, out_name)
GP.Execute("FeatureclassToFeatureclass_conversion", parameters, Nothing)
End Sub
... View more
06-11-2010
12:02 AM
|
0
|
2
|
3916
|
POST
|
Hi Neil, Thanks for your reply. Good to know that my code calling the form was correct. You were right - there was something wrong with my form class. Couldn't put my finger on exactly what was causing it, but when I deleted the form and recreated it everything worked fine. Thanks again for our help. Regards. Rob.
... View more
05-20-2010
06:29 PM
|
0
|
0
|
176
|
POST
|
Hi, I am having trouble doing something which I would have thought to be pretty straight forward. I have a form (frmUpdate) which I cannot get to display. I want the form to show when the user selects a particular item from a custom menu. I can get a msgbox to display when the user clicks on the menu item, but the subsequent call to show the form does nothing. Any thoughts? I am using VB.Net, VS2008, ArcMap 9.3.1
Public Overrides Sub OnClick()
MsgBox("ping!") ' this is working so I know the code is getting this far
'Dim form As frmUpdate = New frmUpdate() ' tried this and it didn't work
Dim form As frmUpdate
form = New frmUpdate()
form.Show() ' nothing happens
End Sub
Regards. Rob.
... View more
05-19-2010
10:40 PM
|
0
|
2
|
587
|
POST
|
Thanks for the info! I was about to reply and ask where I would find the 'Start external program' setting... ...I then discovered that should be under Debug tab in the projects properties, but wasn't. I'm running the Express edition of VS 2008 which by all reports should have this functionality but doesn't. http://social.msdn.microsoft.com/Forums/en-US/Vsexpressinstall/thread/e81a20c3-ebc5-4b53-b8cf-34cbca47b9c7 Given that some of the samples I have been working with debug in ArcMap and others don't, I suspect that the projects were probably initially created in the full version of VS and had the Start External Program pointing to ArcMap. I can only assume that the Express edition honors such a setting but does not itself allow the stetting to be set or changed. The outcome may not be favorable for me, but a least I now have a better understanding of what's going on. Thanks for the tip. Regards. Rob.
... View more
05-09-2010
07:02 PM
|
0
|
0
|
228
|
POST
|
Hi, I have been fiddling around with VS2008 and VB.Net for a little while now. Usually just taking samples and modifying to suit my needs. I have noticed that when using the �??Run�?? button from within VS, sometimes ArcMap will launch, for other projects the VS �??Test Container�?? will launch. I have a project which uses ArcObjects I wish to have launch in ArcMap when debugging. I have found the following information on solving this issue: http://forums.esri.com/thread.asp?t=154133&f=1170&c=93 http://msdn.microsoft.com/en-us/library/1ktzfy9w.aspx But have had no luck in getting it to work. Can anyone help me? I have provided a screen dump (attached) of the options I am trying to set. Regards. Rob.
... View more
05-06-2010
08:17 PM
|
0
|
2
|
628
|
POST
|
Hi Kirk, Thanks for your reply. I�??m still fairly green when it come to VB.Next/ArcObjects so I�??ve been trying to find an example of showing such a use of IExtension to try and better understand your suggestion. So far I have failed to find such an example. Do you know of any such resources or have any pointers as to how I might go about implementing IExtension in this scenario? Regards. Rob.
... View more
04-15-2010
04:12 PM
|
0
|
0
|
164
|
POST
|
Hi, I have a VB.Net customisation (see attached) which is a toolbar for ArcMap. Each item on the toolbar resides on its own UserControl (to help improve the ???display stability??? of the toolbar). My problem is that I can???t seem to communicate effectively between the UserControls. More specifically I want the second ComboBox to be enabled and be aware of value of the selected value in the first ComboBox when the SelectedIndexChanged Event of the first ComboBox occurs (such that the second ComboBox can be populated with values relating to the selection in the first). Does anyone know how to get a handle on what???s happening in one UserControl from another UserControl? And thoughts or examples would be most appreciated. I am using 9.3.1 and VS 2008 (ToolAndControlSampleVB2008.sln ??? from the attachment). Regards. Rob.
... View more
04-14-2010
09:18 PM
|
0
|
2
|
1831
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|