POST
|
Hello, I attempted to use this code to create a grid from a constant (4137.37). I have inserted a MsgBox in the snippet where I get an error. The error message is: Error HRESULT E_FAIL has been returned from a call to a COM component. Can anyone tell me what I am doing wrong? thanks tlh 'make stagegrid using IRasterMakerOp.MakeConstant method: 'StageMeters is a variable containing the value of 4137.37 Dim pRMakerOp As ESRI.ArcGIS.GeoAnalyst.IRasterMakerOp = New RasterMakerOp Dim pStageGrid As IGeoDataset = pRMakerOp.MakeConstant(StageMeters, False) Dim pLayerStage As IRasterLayer = New RasterLayer MsgBox("Code is good up to here") pLayerStage.CreateFromRaster(pStageGrid) pLayerStage.Name = "StageGrid" pMap.AddLayer(pStageGrid) pMxDoc.ActiveView.Refresh()
... View more
03-09-2011
08:58 AM
|
0
|
0
|
579
|
POST
|
Hello I'm new to vb.net and arcobjects, using arcgis10. I have posted a subroutine below that should load featureclasses from one or many featuredatasets inside a single geodatabase. The geodatabase has a featuredataset for each parcel. Inside each featuredataset there are several inundation polygons for that parcel. The for loop is supposed to loop through each selected parcel and load the specified inundation area from the geodatabase. After running the code with 2 parcels selected, it appears that inundation areas for both parcels are loaded into the map document, but the names of the layers are the same, when they should be unique. When I turn off one inundation polygon the other still remains, but one I turned off won't turn back on and the source path breaks. Or, when viewing the layers in the table of contents by order displayed and then by source, the source path breaks. Also one of the parcel inundation layer disappears completely. I've inserted msgbox comments throughout to confirm the names of the featureclasses and other variables, they all appear correct when running the code. The tables appear to be loading correctly, but not the featureclasses. I tried setting all variables to nothing at the bottom of the loop to try to clear this up, but no luck. If I retrieve a featureclass from one featuredataset inside a geodatabase and then switch to a different featuredataset in the same geodatabase, do I have to somehow close the first featurdataset? I presume I can use the same workspace factory for both featuredatasets within the same geodatabase. If anyone can see something I'm doing wrong, please advise. many thanks. tlh Public Sub LoadParcel() Try Dim pMxDoc As IMxDocument = DirectCast(m_app.document, IMxDocument) Dim pMap As IMap = pMxDoc.FocusMap Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer = New FeatureLayer Dim pWSFactory As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory = New FileGDBWorkspaceFactory Dim pFWS As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace Dim pFDSet As ESRI.ArcGIS.Geodatabase.IFeatureDataset Dim pFCContainer As ESRI.ArcGIS.Geodatabase.IFeatureClassContainer Dim pFClass As ESRI.ArcGIS.Geodatabase.IFeatureClass Dim tableCollection As ITableCollection = TryCast(pMap, ITableCollection) Dim pTable As ITable Dim strGDBName As String = strDefaultWorkspace & "\Processed_Data\ShorelineManagementTool_" & LStageDat & ".gdb" Dim OneParcelList() As String = SelParc.Split(",") For i = 0 To intNumParcelsSel - 1 Dim intParcNum As Integer = OneParcelList(i) MsgBox("intParcNum: " & intParcNum) Dim strFDSetName As String = "InundationAreasParcel_" & intParcNum MsgBox("strFDSetName: " & strFDSetName) Dim dblStage As Double = LStage intInundationStage = (Int((dblStage + 0.05) * 10) * 10) Dim strFClassName As String = "p" & intParcNum & intInundationStage & "_polygon" MsgBox("strFClassName: " & strFClassName) pFWS = pWSFactory.OpenFromFile(strGDBName, 0) pFDSet = pFWS.OpenFeatureDataset(strFDSetName) pFCContainer = CType(pFDSet, ESRI.ArcGIS.Geodatabase.IFeatureClassContainer) pFClass = pFCContainer.ClassByName(strFClassName) pFLayer.FeatureClass = pFClass pFLayer.Name = strFClassName pMap.AddLayer(pFLayer) 'pFLayer.Name = strFClassName MsgBox("pFLayer.Name: " & pFLayer.Name) pTable = pFWS.OpenTable("p" & intParcNum & intInundationStage & "_cf") tableCollection.AddTable(pTable) strFDSetName = Nothing strFClassName = Nothing pFDSet = Nothing pFCContainer = Nothing pFClass = Nothing pFLayer.FeatureClass = Nothing pFLayer.Name = Nothing pTable = Nothing Next Catch ex As Exception MsgBox(ex.Message) End Try End Sub End Class
... View more
02-17-2011
06:57 AM
|
0
|
0
|
675
|
POST
|
Jeff: It worked! I just needed to modify the code as you stated and add the display reference. thank you so much! tlh
... View more
02-09-2011
05:52 AM
|
0
|
0
|
222
|
POST
|
Hi Jeff I get an error "Implementing class ESRI.ArcGIS.Carto.FeatureLayerClass for interface ESRI.ArcGIS.Carto.FeatureLayer can not be found. thanks for your help tlh
... View more
02-08-2011
12:43 PM
|
0
|
0
|
222
|
POST
|
This code below that rwelikal provided saved the document in the folder. I'm not savy enough to understand what Neil was telling me. I would like my addin to continue working with the saved map (I think Neil was trying to tell me that this code won't accomodate that.) If anyone can elaborate on what Neil is explaining, I would appreciate it. thanks tlh Dim pMxDoc As IMxDocument = DirectCast(m_app.document, IMxDocument) Dim pMap As IMap = pMxDoc.FocusMap Dim pMapDoc As IMapDocument = New MapDocument Dim pMxdContents As IMxdContents = pMap Directory.CreateDirectory(strDefaultWorkspace & "\" & frmWSIn.txtOutFolderName.Text) pMapDoc.[New](strDefaultWorkspace & "\" & frmWSIn.txtOutFolderName.Text & "\map_document.mxd") pMapDoc.ReplaceContents(pMxdContents) pMapDoc.SetActiveView(pMxDoc.ActiveView) pMapDoc.Save(True, False)
... View more
02-08-2011
12:32 PM
|
0
|
0
|
1040
|
POST
|
Hello I'm new to vb and dotnet. I'm running arcgis 10. I think I am close but need help finishing my procedure below. The code below works up to the point where I have the message box. The error I get is "Unable to cast COM object of type 'System.__ComObject" to interface type 'ESRI.ArcGIS.Carto.IFeatureLayer'" I've tried several variations on the last few lines but can't figure it out. I'm inexperienced in casting, which I think is what I need to do here. Any help is appreciated. I just want to add the featureclass that is inside the geodatabase featuredataset to the map document. thanks tlh Private Sub LoadInundationLayers() Dim pMxDoc As IMxDocument = DirectCast(m_app.document, IMxDocument) Dim pMap As IMap = pMxDoc.FocusMap Dim pFLayer As ESRI.ArcGIS.Carto.IFeatureLayer Dim pWSFactory As ESRI.ArcGIS.Geodatabase.IWorkspaceFactory = New FileGDBWorkspaceFactory Dim pFWS As ESRI.ArcGIS.Geodatabase.IFeatureWorkspace Dim pFDSet As ESRI.ArcGIS.Geodatabase.IFeatureDataset Dim pFCContainer As ESRI.ArcGIS.Geodatabase.IFeatureClassContainer Dim pFClass As ESRI.ArcGIS.Geodatabase.IFeatureClass Dim intParcNum As Integer = 9 intInundationStage = 413000 Dim strGDBName As String = strDefaultWorkspace & "\Processed_Data\ShorelineManagementTool_" & frmScenSet.lblVertDatStage.Text & ".gdb" Dim strFDSetName As String = "InundationAreasParcel_" & intParcNum Dim strFClassName As String = "p" & intParcNum & intInundationStage & "_polygon" Try pFWS = pWSFactory.OpenFromFile(strGDBName, 0) pFDSet = pFWS.OpenFeatureDataset(strFDSetName) pFCContainer = CType(pFDSet, ESRI.ArcGIS.Geodatabase.IFeatureClassContainer) pFClass = pFCContainer.ClassByName(strFClassName) MsgBox("code works up to here") pFLayer = pFClass pMap.AddLayer(pFLayer) Catch ex As Exception MsgBox(ex.Message) End Try End Sub
... View more
02-08-2011
11:28 AM
|
0
|
4
|
2924
|
POST
|
thanks to all who responded. I will try out the suggestions and let you know what worked. I appreciate everyone's help. tlh
... View more
02-03-2011
11:00 AM
|
0
|
0
|
1040
|
POST
|
Thanks, but the try structure did not reveal any errors. Anyone have other ideas? thanks! tlh
... View more
02-01-2011
09:50 AM
|
0
|
0
|
1040
|
POST
|
Hello I am new to VB and .NET, can anyone tell me what I am doing wrong? I am using arcmap v10 with MS Visual Studio Express 2008. I just want to save my map document without presenting a dialog box to the user. The code snippet below does not produce an error, but the map document does not get saved either. Thanks tlh Dim pMxDoc As IMxDocument = DirectCast(m_app.document, IMxDocument) Dim pMap As IMap = pMxDoc.FocusMap Dim pMapDoc As IMapDocument = pMap Dim mxdPathName As String mxdPathName = strDefaultWorkspace & "\" & frmWSIn.txtMapDocName.Text pMapDoc.SaveAs(mxdPathName)
... View more
02-01-2011
06:05 AM
|
0
|
10
|
4662
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|