I am trying to use ArcObject in Python. I do have problem with assigning an interface (i.e. IZ.InterpolateZsBetween) to my object with geometry data, code is:
from Comtypes.client import CreateObject, GetModule
import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.setproduct("ArcInfo")
esriSystem = GetModule("C:/Program Files (x86)/ArcGIS/com/esriSystem.olb")
esriGeometry = GetModule("C:/Program Files (x86)/ArcGIS/com/esriGeometry.olb")
esriDataSourcesGDB = GetModule("C:/Program Files (x86)/ArcGIS/com/esriDataSourcesGDB.olb")
esriGeoDatabase = GetModule("C:/Program Files (x86)/ArcGIS/com/esriGeoDatabase.olb")
sPath ="c:/temp/test.gdb"
pWSF = CreateObject(esriDataSourcesGDB.FileGDBWorkspaceFactory,\
interface=esriGeoDatabase.IWorkspaceFactory)
pWS = pWSF.OpenFromFile(sPath, 0)
pFWS = pWS.QueryInterface(esriGeoDatabase.IFeatureWorkspace)
pFClass = pFWS.OpenFeatureClass("test_z")
pFCursor = pFClass.Search(None, True)
pFeat = pFCursor.NextFeature()
pIZ = pFeat.QueryInferface(esriGeometry.IZ2)
Why this is not working? The output is:
Traceback (most recent call last):
File "<pyshell#175>", line 1, in <module>
pIZ = pFeat.QueryInterface(esriGeometry.IZ2)
File "C:\Python25\lib\site-packages\comtypes\__init__.py", line 1078, in QueryInterface
self.__com_QueryInterface(byref(iid), byref(p))
COMError: (-2147467262, 'Taki interfejs nie jest obs\xb3ugiwany.', (None, None, None, 0,
None))
So I tried:
pShape = pFeat.ShapeCopy
pIZ = pShape.QueryInterface(esriGeometry.IZ2)
pShape.InterpolateZsBetween(0, 0, 0, 4)
And this is working. But how to stick it back and save it in my feature? I am learning Python and ArcObjects, so please be understandful. Any help will be appreciated.