AnsweredAssumed Answered

Writing from/to Z values from fields

Question asked by mlou on May 18, 2014
Latest reply on May 19, 2014 by rfairhur24
Hi all,

I have some Z-enabled lines that have no values currently set in the Z property, however I have FromLevel and ToLevel fields as attributes in the feature class.  I'd like to have a script that loops through all my lines and populates the Start Vertex with the value in the "FromLevel" field, and the End Vertex with the value in the "ToLevel" field.  Is this possible?  I started playing around with an UpdateCursor as I thought this would be the quickest/easiest way to get it done, but am unsure how to write to the Z property through the UpdateCursor.

I'm using ArcGIS Desktop 10.2.2

import arcpy, sys, string, os, fpformat  mxd = arcpy.mapping.MapDocument("CURRENT")  layers = arcpy.mapping.ListLayers(mxd)  for layer in layers:  [/FONT][FONT=Consolas]  if == "3dLine":     layerexists = 1          fields = ["SHAPE@Z","FromLevel","ToLevel"]      if layerexists == 1:       strLineFC = "3dLine"          lineRows = arcpy.da.UpdateCursor(strLineFC, fields)          lineRow =          while lineRow:           linePointsArray = lineRow.Shape.getPart(0)           pt_count = linePointsArray.count           pt_begin = # First Vertex on line            row[0] = row[1]           vertices = 2            while vertices < pt_count:             pt_end =             vertices = vertices + 1                      pt_end = # Last Vertex on line           row[0] = row[2]

This tells me there is no Shape property to get the vertex info from... (this script was butchered from another similar script, however that script writes to an attribute, not the Z property, and uses arcpy.updatecursor not arcpy.da.updatecursor.  Can I write to the Z property through the arcpy.updatecursor?

I'd appreciate any tips/suggestions to allow me to do this.