arcobjects update mdb file geometry

615
10
Jump to solution
02-07-2013 04:34 AM
magdaw
by
New Contributor
Hi,
I have vb.net code that works fine and updates geometry of a polyline shapefile.
What do I need to change/add to the code in order to perform similar operations on personal geodatabase *.mdb file?
Database Name= AllFeatures.mdb
Feature Dataset=LineFeatures
Feature Class = Lines

When I run this program on a mdb personal geodatabase the "Feature.Store" line of code does not work and throws an error "Items not found in this collection"
Any help or hints much appreciated.

  Do While Not id = -1                     pFeature = pFLayer.FeatureClass.GetFeature(id)                      pPolyline = pFeature.Shape                     pPointColl = pPolyline                      For lPnt = 0 To (pPointColl.PointCount - 1)                         Dim newPoint As IPoint = SetZValueOnPoint(pPointColl.Point(lPnt), Convert.ToDouble(txtZValue.Text))                         pPointColl.UpdatePoint(lPnt, newPoint)                     Next                     pFeature.Shape = pPointColl                     pFeature.Store()
0 Kudos
1 Solution

Accepted Solutions
AlexanderGray
Regular Contributor II
That might happen if you try to add values outside of the z domain.  In ArcCatalog, if you open the properties of the featureclass and go to the domain tab, A. Do you see a 'Z Domain' box below the XY domain, and B. If it is there are the values you are entering within that domain?

Another thing, if you are doing this within an edit session in ArcMap, you need to bracket this with a startoperation and stopoperation on the ieditor extension interface.

View solution in original post

0 Kudos
10 Replies
NeilClemmons
Regular Contributor III
Since you're setting z-values on the geometry my first guess would be the feature class you're saving to isn't z-aware.  If a feature class isn't z-aware then trying to save a geometry with z-values will throw an error.
0 Kudos
magdaw
by
New Contributor
Hi Neil,

I am using SetZValueOnPoint function below to make feature class ZAware:

Public Function SetZValueOnPoint(ByVal point As IPoint, ByVal zValue As Double) As IPoint

        Dim zAware As IZAware
        zAware = point
        zAware.ZAware = True
        point.Z = zValue

        Return point

    End Function
0 Kudos
NeilClemmons
Regular Contributor III
That makes the point geometry z-aware.  It doesn't make the feature class z-aware.  The feature class is made z-aware when you create it in the database.
0 Kudos
magdaw
by
New Contributor
Hi Neil,

Thanks for your hints.
I have made some changes within the code but pZAware = pFeature gives me an error now.
How can i make my feature class z-aware?

Do While Not id = -1
                    Dim pZAware As IZAware
                    pFeature = pFLayer.FeatureClass.GetFeature(id)
                    pZAware = pFeature
                    pZAware.ZAware = True

                    pPolyline = pFeature.Shape


                    pPointColl = pPolyline

                    For lPnt = 0 To (pPointColl.PointCount - 1)
                        Dim newPoint As IPoint = SetZValueOnPoint(pPointColl.Point(lPnt), Convert.ToDouble(txtZValue.Text))
                        pPointColl.UpdatePoint(lPnt, newPoint)
                    Next
0 Kudos
NeilClemmons
Regular Contributor III
You can't.  The M and Z aware properties have to be set at the time you create the feature class in the geodatabase.  Once a feature class has been created you cannot change its geometry type.
0 Kudos
magdaw
by
New Contributor
I can change manually Z values (of the feature class I want to access and update through code) within Edit Sketch Property window and then save my changes.
Is it correct to assume that the feature class must be z-aware in this case?
0 Kudos
AlexanderGray
Regular Contributor II
sounds like you have a z-aware featureclass...  The ZAware property should return true before you set it.  If it doesn't there is a problem with the featureclass, setting it won't help.  In my experience, I have found that creating a new polyline and setting the coordinate system reference same as the old one and then adding new points as you read the points from the original polyline and then calling simplify and setting the feature shape property to the new shape has yielded better results.
0 Kudos
magdaw
by
New Contributor
Hello,

Thanks for suggestion Alex I will try to create a new polyline.

However, I think we are moving away from the main problem...
The issue could be more related to the "Feature.Store()" line within my code.
I can see that Z values get updated when I pres "update Z" button despite the error message "Item not found in this collection"  but as soon as I press "save changes" button Z values change back to their original values. It looks like database is not allowing me to commit the changes and rollbacks to its original state as soon as i press save button.

And ideas much appreciated.
0 Kudos
AlexanderGray
Regular Contributor II
That might happen if you try to add values outside of the z domain.  In ArcCatalog, if you open the properties of the featureclass and go to the domain tab, A. Do you see a 'Z Domain' box below the XY domain, and B. If it is there are the values you are entering within that domain?

Another thing, if you are doing this within an edit session in ArcMap, you need to bracket this with a startoperation and stopoperation on the ieditor extension interface.

View solution in original post

0 Kudos