Select to view content in your preferred language

Help: Trying to Add points to shapefile

673
1
Jump to solution
10-28-2013 05:43 AM
CraigGraham
Occasional Contributor
Good Morning,
I'm trying to add points to a shapefile in ArcPad.  I found this script example that does it from the position of the mouse pointer....

Set objPoint = Application.CreateAppObject("Point") Set objRS = Map.Layers(???<<Layer Name>>???).Records Call objRS.AddNew objPoint.X = Map.PointerX objPoint.Y = Map.PointerY Set objRS.Fields.Shape = objPoint objRS.Fields ???<<Field Name>>???).Value = CStr(???<<Information or Variable>>???) objRS.Update


I made some alterations to it so that it is looking at the X and Y values from photos in a folder.

' Snipped is a bunch of code creates a shp, then in a loop... opens the image, reads the lat/long and projects it to the current map's projection. Set pPoint= Application.CreateAppObject("Point") Set rs = Map.Layers(sPhotoSHPLayerName).Records Call rs.AddNew pPoint.X = dProjectedX pPoint.Y = dProjectedY Set rs.Fields.Shape = pPoint rs.Fields "PhotoName").Value = CStr(file.name) rs.Fields "Long").Value = CDbl(dLong) rs.Fields "Lat").Value = CDbl(dLat) rs.Update


I keep getting a very unhelpful error message at "Set rs.Fields.Shape = pPoint".  It says something like "Unavailable".  Does anyone know what I'm missing. 

I have messaged boxed dProjectedX and dProjectedY and they are valid coordinates that make sense for the study area.  The reference to sPhotoSHPLayerName seems correct.

I feel like this is the one little step I need to finish to get this project over with.  At this point all suggestions will be tried.  Thanks in advance for any help.

Take care,
Craig
Tags (3)
0 Kudos
1 Solution

Accepted Solutions
CraigGraham
Occasional Contributor
So the example on the ArcScripts site is likely out of date.  With 10.1 the following works great. 


Set pPoint= Application.CreateAppObject("Point") Set rs = Map.Layers(sPhotoSHPLayerName).Records pPoint.X = dProjectedX pPoint.Y = dProjectedY rs.AddNew pPoint rs.Fields "PhotoName").Value = CStr(file.name) rs.Fields "Long").Value = CDbl(dLong) rs.Fields "Lat").Value = CDbl(dLat) rs.Update


Have a good day.

View solution in original post

0 Kudos
1 Reply
CraigGraham
Occasional Contributor
So the example on the ArcScripts site is likely out of date.  With 10.1 the following works great. 


Set pPoint= Application.CreateAppObject("Point") Set rs = Map.Layers(sPhotoSHPLayerName).Records pPoint.X = dProjectedX pPoint.Y = dProjectedY rs.AddNew pPoint rs.Fields "PhotoName").Value = CStr(file.name) rs.Fields "Long").Value = CDbl(dLong) rs.Fields "Lat").Value = CDbl(dLat) rs.Update


Have a good day.
0 Kudos