Copying multiple shapes

Dazzer
04-21-2004, 06:54 AM
We have 3 seperate maps that each contain a set of pushpins and around each pushpin is drawn a shape (catchment area).
I am trying to merge these 3 maps into 1 and I can import all of the ushpins from each map ok.
Where i'm having trouble is copying the shapes into the single map, I can copy them one at a time but this isn't really practical as there are over 10,000 of these. Is it possible to copy multiple shapes from one map to another, if not through mappoint then programaticaly through vb.

I really could do with some help on this, going through 10,000 of them one at a time is going to be a nightmare!

Eric Frost
04-21-2004, 09:15 AM
Dazzer,

There's a mif/mid exporter, it's not perfect but it would allow you to get the shapes out programmatically, manipulate them as text or with a GIS program, and re-import them.

Walt Cygan wrote the mif/mid exporter, it is here:
http://www.mp2kmag.com/importersub01.asp
There's also a compiled version in one of the old newsletters, look for "three new utilities".

You may encounter some errors, but it should give you a good starting point.

Eric

Anonymous
04-21-2004, 10:07 AM
Excellent, thanks for your help

I'll have a look at this and see what I can do with it.

Thanks again for your help

Martel
04-21-2004, 09:47 PM
I had to copy a bunch of shapes (freeform lines) that had been hand-drawn to represent areas on the map. You should be able to adapt this to your needs or use it as a start. MapPoint is nice in that the shapes paste to the same location from which they were copied.

'** g_App is a reference to the current application **
Private Sub btnCopyAllShapes_Click()
Dim oSrcApp As mappoint.Application
Dim oSrcMap As mappoint.Map
Dim oTargMap As mappoint.Map
Dim oShape As mappoint.Shape
Dim sFiles() As String
Dim i As Integer

'set current map as target
Set oTargMap = g_App.ActiveMap

On Error GoTo ErrorHandler
'get source map
With CmnDlg
.Flags = cdlOFNLongNames Or cdlOFNExplorer
.DialogTitle = "Select Target Map:"
.CancelError = True
.Filter = "MapPoint Files (*.ptm)|*.ptm"
.ShowOpen
End With
If Len(CmnDlg.FileName) > 0 Or Not IsNull(CmnDlg.FileName) Then
'set up target files
Set oSrcApp = CreateObject("MapPoint.Application")
Set oSrcMap = oTargApp.OpenMap(CmnDlg.FileName)
'make the application visible so the user can compare shapes and locations
oSrcApp.UserControl = True
oSrcApp.Visible = True

'copy shapes to target files
For Each oShape In oSrcMap.Shapes
'either add the type of shape to copy or remove completely to get all shapes
'I was only looking for particular shapes
If oShape.Type = geoAutoShape Or geoFreeform Then
'copy from source
oShape.Copy
'paste to target
oTargMap.Paste
End If
Next
End If


Exit_:
'set focus back to target app
If IsObject(oTargApp) Then
oTargApp.Activate
End If
'dereference everything
Set oTargApp = Nothing
Set oTargMap = Nothing
Set oSrcMap = Nothing
Set oShape = Nothing

'close form
Unload Me
Exit Sub

ErrorHandler:
If Err.Number <> CancelErr Then
MsgBox Err.Number & " " & Err.Description & vbCrLf _
& "Sub: btnCopy"
Err.Clear
End If
GoTo Exit_
End Sub

Dazzer
04-22-2004, 03:35 AM
I think this solution is what I had in mind, it just depends how long it takes with 10,000+ shapes but I shouldn't think it would take that long.

The mif/mid exporter is interesting I'll have a look at this as well, could be useful for something else.

Thanks both for your help

 
Web mp2kmag.com
mapforums.com