You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects General forum

Buffer using geoprocessor object   Ken Berglund Jun 13, 2007
Re: Buffer using geoprocessor object   Michael Knight Jun 13, 2007
Re: Buffer using geoprocessor object   Ken Berglund Jun 13, 2007
Re: Buffer using geoprocessor object   Gary Bushek Sep 05, 2007
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Buffer using geoprocessor object 
Author Ken Berglund 
Date Jun 13, 2007 
Message Hi All,
I want to buffer a polygon shapefile using the GP object but it keeps on failing. I think it has to do with the input shapefile not having Z values. How do I go about buffering this shapefile? Do I have to go back to where I create the shapefile and do something there, or can I set the environments in the Buffer button to disable the M values or something? The code below is what I have for the Buffer button. 
 
' Create the Geoprocessor object
  Dim GP As Object
  Set GP = CreateObject("esriGeoprocessing.GPDispatch.1")

  ' Load required toolboxes...
  GP.Toolbox = "D:\ArcGIS\ArcToolbox\Toolboxes\Analysis Tools.tbx"

  ' Set the Geoprocessing environment...
' This dosen't work!!!!!
'  GP.outputZFlag = "Same As Input"
'  GP.outputMFlag = "Disabled"

  ' Process: Buffer...
 GP.Buffer "G:\kamloops\analysis\Cruise_Model_Test\Export_test.shp", _
  "G:\kamloops\analysis\Cruise_Model_Test\Buffer.shp", "10"
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Buffer using geoprocessor object 
Author Michael Knight 
Date Jun 13, 2007 
Message Capture the messages from the GP object and post what they say.
What does the input not having z values have to do with anything? 
  Michael Knight
GIS Solutions Architect
Contract Land Staff, LLC
Stafford, Texas

http://www.contractlandstaff.com

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Buffer using geoprocessor object 
Author Ken Berglund 
Date Jun 13, 2007 
Message I have encountered this before pertaining to Z-values and M-values. I am not sure if it is more to do with disabling the M-value (I think it is) or something with the Z (I dont think). But it happened previousy when doing geoprocessing with a Python script. The error I get when I hit the buffer button is an "unspecified error", but when I use the specified .shp file as input in a model and run it I get the error: "The geometry has no Z values. Failed to execute Buffer."

Now I agree, I don't think it is the Z value. I think it is the M value that needs to be disabled because that is what I did with the python script, I disabled the M and it worked. I say this because if you look at the input .shp in ArcCatalog the shape field reads "Polygon M". And this caused a problem when I was using a Python script before and disabling M worked. So my question I guess is, how do you disable M in VBA and I guess it has to be done when I create the shapefile. The problem being I created in a way I am not familiar with.
thanks for the help.
Code below is where I created the .shp. 
 
'====================
  ' Perform attribute query of selected field and attribute
  ' The attribute is the value entered in the textbox
  '=====================
  Dim mxDoc As IMxDocument
  Set mxDoc = ThisDocument
  Dim pActiveView As IActiveView
  Dim pFeatureLayer As IFeatureLayer
  Dim pFeatureSelection As IFeatureSelection
  Dim pMap As IMap

  Set pMap = mxDoc.FocusMap
  Set pActiveView = pMap

  '======================
  'For simplicity sake let's use the first layer in the map
  '=====================
  If Not TypeOf pMap.Layer(0) Is IFeatureLayer Then Exit Sub
  
  Set pFeatureLayer = pMap.Layer(0)
  Set pFeatureSelection = pFeatureLayer 'QI

  '===============
  'Create the query filter
  '===============
  LicenseID = DatabaseConnection.LicenseBox.Value
  CP = DatabaseConnection.CPBox.Value
  
  Dim pFieldname As String
  Dim pQFilter As IQueryFilter
  Set pQFilter = New QueryFilter
'    If UserForm1.ListBox1.Value <> "" Then
'      pFieldname = UserForm1.ListBox1.Value
'      Else
'      MsgBox ("Please Enter a Field.")
'    End If
  '==================
  ' If user entered text then contiue
  '==================
  If LicenseID <> "" And CP <> "" Then
    pQFilter.WhereClause = "KHGIS.VWM_LIC_CP_BLK.LICN_LICENCE_ID = '" & LicenseID & "'" _
    & " And " & "KHGIS.VWM_LIC_CP_BLK.PERM_PERMIT_ID = '" & CP & "'"

    'MsgBox pQFilter.WhereClause
    '====================
    'Invalidate only the selection cache
    'Flag the original selection
    '====================
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing

    '==================
    'Perform the selection
    '==================
    pFeatureSelection.SelectFeatures pQFilter, esriSelectionResultNew, False

    '=================
    'Flag the new selection
    '=================
    pActiveView.PartialRefresh esriViewGeoSelection, Nothing, Nothing

    '========================
    ' Get the selected features
    '========================
    Dim pSelSet As ISelectionSet
    Set pSelSet = pFeatureSelection.SelectionSet

    Dim pEnumGeom As IEnumGeometry
    Dim pEnumGeomBind As IEnumGeometryBind

    Set pEnumGeom = New EnumFeatureGeometry
    Set pEnumGeomBind = pEnumGeom
    pEnumGeomBind.BindGeometrySource Nothing, pSelSet
  
    Dim pGeomFactory As IGeometryFactory
    Set pGeomFactory = New GeometryEnvironment
  
    Dim pGeom As IGeometry
    Set pGeom = pGeomFactory.CreateGeometryFromEnumerator(pEnumGeom)

    '===================
    'Zoom in to selected feature
    '==================
    mxDoc.ActiveView.Extent = pGeom.Envelope
    mxDoc.ActiveView.Refresh
    
    
    Dim pFLayer As IFeatureLayer
    Dim pDataset As IDataset
    Dim pDSName As IDatasetName
    Dim pDispTable As IDisplayTable
    Dim pShapeFCName As IDatasetName
    Dim pShapeWSF As IWorkspaceFactory
    Dim pShapeWS As IDataset
    Dim pShapeWSName As IWorkspaceName
    Dim pExportOp As IExportOperation

    Set pFLayer = mxDoc.FocusMap.Layer(0)
    Set pDispTable = pFLayer
    Set pDataset = pDispTable.DisplayTable
    Set pDSName = pDataset.FullName
    Set pShapeWSF = New ShapefileWorkspaceFactory
    Set pShapeWS = pShapeWSF.OpenFromFile("G:\kamloops\analysis\Cruise_Model_Test", 0)
    Set pShapeWSName = pShapeWS.FullName
    Set pShapeFCName = New FeatureClassName
    pShapeFCName.Name = "Export_test"
    Set pShapeFCName.WorkspaceName = pShapeWSName

    ' Set up query sub fields: a comma-delimited list of the fields you want
    ' Or "*" for all fields in the joined feature class
    'Dim strFld As String
    'strFld = "*"

    'Set pQFilter = New QueryFilter
    'pQFilter.SubFields = strFld

    Set pExportOp = New ExportOperation
    pExportOp.ExportFeatureClass pDSName, pQFilter, Nothing, Nothing, pShapeFCName, 0

    'pMap.AddLayer pShapeFCName.WorkspaceName
    
    Dim pWorkspaceFactory As IWorkspaceFactory
    Dim pFeatureWorkspace As IFeatureWorkspace
    'Dim pFeatureLayer As IFeatureLayer
    
    '=========================================================================
    'Create a new ShapefileWorkspaceFactory object and open a shapefile folder
    '=========================================================================
    Set pWorkspaceFactory = New ShapefileWorkspaceFactory
    Set pFeatureWorkspace = pWorkspaceFactory.OpenFromFile("G:\kamloops\analysis\Cruise_Model_Test", 0)
    '======================================================
    'Create a new FeatureLayer and assign a shapefile to it
    '======================================================
    Set pFLayer = New FeatureLayer
    Set pFLayer.FeatureClass = pFeatureWorkspace.OpenFeatureClass("Export_test")
    pFLayer.Name = pFeatureLayer.FeatureClass.AliasName
    '=====================================
    'Add the FeatureLayer to the focus map
    '=====================================
    Set mxDoc = Application.Document
    Set pMap = mxDoc.FocusMap
    pMap.AddLayer pFLayer
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Buffer using geoprocessor object 
Author Gary Bushek 
Date Sep 05, 2007 
Message did you figure this out? I am doing a dissolve and it fails intermittently.