|
POST
|
VBA is on the install CD, it's on the main install screen called "ArcGIS Desktop VBA Resources for Developers". Click on setup and let it install its stuff. THEN you need to license it, to do this you need to contact ESRI to get a free license code which you enter via the desktop administrator. Your organisation may have already obtained these license codes already so worth asking you GIS administrator. Duncan
... View more
06-03-2011
07:56 AM
|
0
|
0
|
786
|
|
POST
|
Mathew, Here is the code you seek, make sure you adjust the myFolder string. Duncan import zipfile, sys, os, glob
# Set the folder that contains the ShapeFiles
myFolder = "C:/Scratch/FWS/"
def zipShapefile(myFolder):
# Check if folder exists
if not (os.path.exists(myFolder)):
print myFolder + ' Does Not Exist!'
return False
# Get a list of shapefiles
ListOfShapeFiles = glob.glob(myFolder + '*.shp')
# Main shapefile loop
for sf in ListOfShapeFiles:
print 'Zipping ' + sf
# Create an output zip file name from shapefile
newZipFN = sf[:-3] + 'zip'
# Check if output zipfile exists, delete it
if (os.path.exists(newZipFN)):
print 'Deleting '+newZipFN
os.remove(newZipFN)
if (os.path.exists(newZipFN)):
print 'Unable to Delete' + newZipFN
return False
# Create zip file object
zipobj = zipfile.ZipFile(newZipFN,'w')
# Cycle through all associated files for shapefile adding them to zip file
for infile in glob.glob( sf.lower().replace(".shp",".*")):
print 'zipping ' + infile + ' into ' + newZipFN
if infile.lower() != newZipFN.lower() :
# Avoid zipping the zip file!
zipobj.write(infile,os.path.basename(infile),zipfile.ZIP_DEFLATED)
# Close zipfile
print 'ShapeFile zipped!'
zipobj.close()
# Got here so everything is OK
return True
# Call function to zip files
b = zipShapefile(myFolder)
if b:
print "Zipping done!"
else:
print "An error occurred during zipping."
... View more
05-25-2011
08:52 AM
|
0
|
0
|
5898
|
|
POST
|
Just a thought but is the feature object you are passing into the function actually a valid object?
... View more
05-24-2011
06:43 AM
|
0
|
0
|
500
|
|
POST
|
Cristian, Use the IFeatureLayer2 Interface it has a property called DataSourceType which returns a string that describes the source type. Duncan
... View more
05-24-2011
06:18 AM
|
0
|
0
|
549
|
|
POST
|
Hello, This is one for the creators of ArcHydro. I have used a component of ArcHydro (the stream burning tool) and wish to reference ArcHydro in my report. What would be the official line on the preferred way of referencing ArcHydro? Duncan
... View more
05-24-2011
03:40 AM
|
0
|
0
|
666
|
|
POST
|
Duncan, I see you are loading layer files, you are better off using the ILayerFile interface in my opinion. It would certainly simplify your code and that is always a good thing if you are learning code. Also you are wasting your time learning VBA as ESRI have decided to bin it in favour of Python, so you should make the effort to learn that instead. Duncan
... View more
04-27-2011
06:36 AM
|
0
|
0
|
504
|
|
POST
|
Justin, If your attribute query is selecting more than 1 polygon then you need to bind your selection into a "single" geometry which you pass to an object of type ISpatialFilter. Below is some code that I have used to achieve this, alternatively you could call the SelectByLocation Geo-Processing tool to achieve the same thing... Dim pSelectionSet_Nodes As ISelectionSet
Set pSelectionSet_Nodes = pFeatureSelection_Nodes.SelectionSet
Dim pEnumGeometry As IEnumGeometry
Dim pEnumGeometryBind As IEnumGeometryBind
Set pEnumGeometry = New EnumFeatureGeometry
Set pEnumGeometryBind = pEnumGeometry
pEnumGeometryBind.BindGeometrySource Nothing, pSelectionSet_Nodes
Dim pGeometryFactory As IGeometryFactory
Set pGeometryFactory = New GeometryEnvironment
Dim pGeometry As IGeometry
Set pGeometry = pGeometryFactory.CreateGeometryFromEnumerator(pEnumGeometry)
Dim pSpatialFilter As ISpatialFilter
Set pSpatialFilter = New SpatialFilter
With pSpatialFilter
Set .Geometry = pGeometry
.GeometryField = "SHAPE"
.SpatialRel = esriSpatialRelIntersects
End With
pFeatureSelection_Rivers.SelectFeatures pSpatialFilter, esriSelectionResultNew, False Duncan
... View more
04-26-2011
07:55 AM
|
0
|
0
|
1430
|
|
POST
|
Lorna, Try setting your spatialfilter SpatialRel property to esriSpatialRelIntersects? Duncan
... View more
04-15-2011
04:15 PM
|
0
|
0
|
1266
|
|
POST
|
Matt, What is the format of your data? I tried your code on some random shapefile I have and it worked. Your data isn't some sort of compressed (hence read only) dataset? Duncan
... View more
04-15-2011
04:11 PM
|
0
|
0
|
878
|
|
POST
|
So you are saying the first time it enters the loop it says false and does not do the split but the next 4 dams do split their respective polylines? May be the issue is with the polyline for the first split, may be it's multipart? Duncan
... View more
04-15-2011
09:01 AM
|
0
|
0
|
1266
|
|
POST
|
Try setting this line: pSelectionSet.Update Nothing, True, pFeatureCursor to: pSelectionSet.Update Nothing, False, pFeatureCursor Also help file says: All edits to features that participate in a Topology or Geometric Network must be bracketed within an edit operation.
... View more
04-15-2011
08:31 AM
|
0
|
0
|
878
|
|
POST
|
Jeff, Your code above worked and the path did include the cryptic guid number when I displayed it in a message box. I was then able to connect to the LayerFile. So thanks for your help! It's a shame that the ESRI help hints at this method of packaging up other files but provides no example code, if they do it's well hidden! Duncan
... View more
04-13-2011
02:05 AM
|
0
|
0
|
2246
|
|
POST
|
Try calling your "Id" field the traditional name "FID" and set its type to ObjectID and that it is a required field and editable through the IFieldEdit interface? Duncan
... View more
04-12-2011
03:00 PM
|
0
|
0
|
489
|
|
POST
|
Jeff, Thanks for the advice, I will test that code you suggested. I have looked inside the esriAddin file with winzip and they are in there in. But I'm having second thoughts about where one is actually "going" to get the layerfiles from. I was thinking that you give it a path name (when I finally get it working) that points inside the esriaddin file but the help file talks about setting the copy to output directory. So when you build the visual studio project and look in the bin directory you get the folder with layer files, the esriaddin file then a bunch of other files, but all these are also inside the esriaddin file. Sooo... if for example I take the esriaddin file only and put it in c:\temp am I developing code that is actually looking for a sub folder in c:\temp rather than inside the esriaddin file? Duncan
... View more
04-12-2011
10:46 AM
|
0
|
0
|
2246
|
|
POST
|
This may be an issue with the dpi setting of the machine. People often bump this up as they have difficultly reading text on the screen. In XP goto Control panel > Display > Settings tab > advance button and make sure dpi is normal
... View more
04-12-2011
08:10 AM
|
0
|
0
|
460
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a month ago | |
| 1 | a month ago | |
| 1 | a month ago | |
| 8 | 03-30-2026 10:12 AM | |
| 2 | 03-18-2026 08:16 AM |
| Online Status |
Offline
|
| Date Last Visited |
a week ago
|