I'm trying to drive MapWindows GIS from an Ironpython script to automate some tasks. Â MapWindow is in C#, and I have generated the Interop Assembly, and I can load the MapWinGIS namespace. Following this example in C#
//create a new instance for MapWinGIS.Shapefile //MapWinGIS.Shapefile is a data provider for ESRI Shapefile MapWinGIS.Shapefile shapefile1 = new MapWinGIS.Shapefile(); //Define the data source for MapWinGIS.Shapefile instance shapefile1.Open(@"D:\GISSampleData\base.shp", null ); So I did the following: >>> import clr >>> clr.AddReference('MapWindow.Interfaces') >>> clr.AddReference('MapWinGeoProc') >>> clr.AddReference('MapWinUtility') >>> clr.AddReference('MapWinInterfaces') >>> clr.AddReference('Interop.MapWinGIS') >>> import MapWinGIS >>> shapefile1 = MapWinGIS.Shapefile >>> help(shapefile1.Open) Help on method_descriptor: Open(...) Open(self, str ShapefileName, ICallback cBack) -> bool >>> shapefile1.Open(r"G:\DLS\BAB\2010 USPS >>> GIS\ADC_Layer\ADC_ALBANY_NY_120.shp",None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: expected IShapefile, got str Not being a C# master, I thought maybe I'm accessing the objects correctly. Try again using IShapefile instead of Shapefile and I got this >>> t = MapWinGIS.IShapefile >>> dir(t) ['BeginPointInShapefile', 'CacheExtents', 'CanUseSpatialIndex', 'CdlgFilter', 'CellValue', 'Close', 'CreateNew', 'CreateNewWithShapeID', 'CreateSpatialIndex', 'Dissolve', 'EditCellValue', 'EditClear', 'EditDeleteField', 'EditDeleteShape', 'EditInsertField', 'EditInsertShape', 'EditingShapes', 'EditingTable', 'EndPointInShapefile', 'ErrorMsg', 'Extents', 'Field', 'FieldByName', 'FileHandle', 'Filename', 'GenerateLabels', 'GetIntersection', 'GlobalCallback', 'HasSpatialIndex', 'InvertSelection', 'IsSpatialIndexValid', 'Key', 'Labels', 'LastErrorCode', 'NumFields', 'NumSelected', 'NumShapes', 'Open', 'PointInShape', 'PointInShapefile', 'Projection', 'QuickExtents', 'QuickPoint', 'QuickPoints', 'QuickQueryInEditMode', 'RefreshExtents', 'RefreshShapeExtents', 'Resource', 'Save', 'SaveAs', 'SelectAll', 'SelectByShapefile', 'SelectNone', 'SelectShapes', 'SelectionDrawingOptions', 'Shape', 'ShapeSelected', 'ShapefileType', 'SpatialIndexMaxAreaPercent', 'StartEditingShapes', 'StartEditingTable', 'StopEditingShapes', 'StopEditingTable', 'UseQTree', 'UseSpatialIndex', '__doc__', '__repr__', 'numPoints'] >>> t.Open.__doc__ 'Open(self, str ShapefileName, ICallback cBack) -> bool' >>> a = r"C:\2010 USPS GIS\Shapefiles\ADC ATLANTA GA 303.shp" >>> t.Open(a,None) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: expected IShapefile, got str Can anyone tell me what I'm missing? Thanks. Bruce _______________________________________________ Users mailing list Users@lists.ironpython.com http://lists.ironpython.com/listinfo.cgi/users-ironpython.com