I'm scripting with Python and ArcPy in ArcGIS 10.2. I want to create a offsetline from a polylineZ. ArcPy doesn't have such a function so far I know. Therefore I'm trying to use ArcObjects within my Pythonscript. My scripting is based on following VB.Net code:
pConstructCurve = New Polyline
pConstructCurve.ConstructOffset(pInPolyline, dOffset, esriConstructOffsetEnum.esriConstructOffsetRounded +
esriConstructOffsetEnum.esriConstructOffsetSimple)
ConstructOffset = pConstructCurve
I use snippets.py from Mark Cederholm for creating and using ArcObjects. That's going very well with exception of the statement pConstructCurve.ConstructOffset. A part of my code is:
pFeatureSelection = Snippits.CType(pFeatureLayer, esriCarto.IFeatureSelection)
pSelectionSet = pFeatureSelection.SelectionSet
pCursor = pSelectionSet.Search (None, False)
pFeatureCursor = Snippits.CType(pCursor, esriGeoDatabase.IFeatureCursor)
pFeat = pFeatureCursor.NextFeature()
while pFeat:
# Maak offsetlijnen:
dOffset = 2.00
# Maak offsetlijn aan de rechterkant
pPolyline = Snippits.NewObj(esriGeometry.Polyline, esriGeometry.IPolyline)
pConstructCurve = Snippits.CType(pPolyline, esriGeometry.IConstructCurve)
pInPolyline = Snippits.CType(pFeat.Shape, esriGeometry.IPolyline)
iOffsetHow = esriGeometry.esriConstructOffsetMitered + esriGeometry.esriConstructOffsetSimple
pConstructCurve.ConstructOffset(pInPolyline, dOffset, iOffsetHow)
pNewPolyline = Snippits.CType(pConstructCurve, esriGeometry.IPolyline)
pNewFeature = pFCOffsetLine.CreateFeature()
iLijnsoortField = pNewFeature.Fields.FindField(sLijnsoortFieldName)
pNewFeature.Value[iLijnsoortField] = "rechts"
pNewFeature.Store
The statement pConstructCurve.ConstructOffset doesn't return anything of a couple of points (most two) with faulty X and Y values. Sometimes an error message appears: "The Geometry has no Z values"
Questions:
- Is it right that AcPy doesn't have such a function?
- What is wrong in my scripting?
Best regards,
Wim