Thanks Dino. But now I get
>>> shapefile1 = MapWinGIS.Shapefile() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: Cannot create instances of Shapefile because it is abstract So then I poked around a bit and found ShapeFileClass, but then I get a different error. >>> s=MapWinGIS.ShapefileClass() >>> tst = s.Open(a,None) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Could not convert argument 0 for call to Open. I guess its time to add IronPython in Action back to my Safari account and read the C# stuff I skipped over before. On Thu, Jul 1, 2010 at 9:34 PM, Dino Viehland <[email protected]> wrote: > My guess is you need to change: > >>>> shapefile1 = MapWinGIS.Shapefile > > To: > >>>> shapefile1 = MapWinGIS.Shapefile() > > You've just gotten a reference to the class whereas the C# code has > created an instance of that class. > >> -----Original Message----- >> From: [email protected] [mailto:users- >> [email protected]] On Behalf Of Bruce Bromberek >> Sent: Thursday, July 01, 2010 6:22 PM >> To: Discussion of IronPython >> Subject: [IronPython] Conflicting information with Ironpython and >> MapWindowGIS interop >> >> 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 >> [email protected] >> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ > Users mailing list > [email protected] > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com > _______________________________________________ Users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
