1 Reply Latest reply on Dec 5, 2013 8:40 AM by mattd

    How do I update ArcFM objects using arcpy.da?

    Morten Grimnes

      I've tried to update geometries through Python using the new arcpy.da module in ArcGIS 10.1. I'm using this with ArcFM 10.1. The script I try looks like this:

       

      # -*- coding: utf-8 -*-

      import arcpy

       

       

      NewWorkSpace    = 'Database Connections/GeometriOppdateringSQL.sde'

      EditFC          = '/ressursbase_skog_arb.SKOGRESSURS.Bestand/ressursbase_skog_arb.SKOGRESSURS.Bestand'

      NewFC           = NewWorkSpace + EditFC

      Columns         = ('OBJECTID','TAKSTMETODE')

       

       

      edit = arcpy.da.Editor(NewWorkSpace)

      edit.startEditing(True,True)

      edit.startOperation ()

       

       

      with arcpy.da.UpdateCursor (NewFC,Columns) as cursor:

          for row in cursor:

              if row[0] == 267305:

                  row[1] = u'GeoMG'

                  try:

                      cursor.updateRow(row)

                  except:

                      print('Error updating')

                      print arcpy.GetMessages

       

       

      edit.stopOperation()

      edit.stopEditing(True)

      print('Finish')

       

      This works flawlessly with standard ESRI objects, but fails when I try the "cursor.updateRow(row)"-statement with ArcFM objects. What happens is that the statement is trapped by the "except:", but I do not see any messages...

       

      I've tried to look at the example I found regarding ArcFM and Python, but I'm not able to see how that fits with my use of arcpy.da. Is there also an equivalent to arcpy.GetMessages in ArcFM Python?

       

      Any help would be appreciated.

        • Re: How do I update ArcFM objects using arcpy.da?

          Hi Morten,

           

          If it's working with Esri objects, but not ArcFM objects, then it could be due to not having a license.

           

          You mentioned that you had looked at a sample.  Was it this article?  It's got some sample python code to check out an ArcFM license and set the AU mode to server (to suppress any UI popups that AUs may try and show - which could cause it to hang or crash).  You'll want the ArcFMSampleUpdated.py.zip attachment, and will need to preface the actual editing with the ArcFM license checkout and au-mode change.