AnsweredAssumed Answered

Use InsertCursor to copy geometry from one dataset to another

Question asked by leftieant76 on Jan 13, 2015
Latest reply on Jan 13, 2015 by xander_bakker

Hi

 

I'm trying to write a script that needs to copy geometry from one FC to another, and also write some attributes. The way I see it is that an insert cursor on the dataset I'm writing to needs to be nested within a search cursor on the dataset I'm writing from.

 

It's an iterative script that needs to sequentially work through features via an attribute value.

 

I could use arcpy.Append_management for this, but if I can get the search/insert cursor nesting working, I think it will be a much neater solution for the job at hand.

 

The crux of the code is:

 

scur = arcpy.SearchCursor(fc)

>>> for row in scur:

...     icur = arcpy.InsertCursor(plm)

...     irow = icur.newRow()

...     irow.SHAPE = row.getValue("SHAPE")

...     irow.MMTGEN = row.getValue("MMTGEN")

...     irow.HANDLED = "Y"

...     icur.insertRow(irow)

...     del irow, icur

 

...which seems very logical to me, but it keeps falling over with generic error 99999.

 

This is the first time I've used Insert Cursors, so I'm unsure if what I am proposing is possible, and if I've gone about this the right way.

 

Can anyone provide some insight for me?

Outcomes