Thanks heaps to all who replied.
This code worked a treat >
Sub Main
Dim nRow as Integer
SELECT obj From ObjectsToMap
INTO objObjectsToMap NoSelect
Fetch first From objObjectsToMap
Do Until EOT(objObjectsToMap)
nRow = objObjectsToMap.rowid
SELECT * From objObjectsToMap
WHERE RowID = nRow
INTO objCurrent NoSelect
Fetch first From objCurrent
Set Map Center (CentroidX(objCurrent.obj),
CentroidY(objCurrent.obj))
Add Map Layer objCurrent
Set Map Zoom Entire Layer objCurrent
Remove Map Layer objCurrent
Run Menu Command 112 'Print Command
Fetch next from objObjectsToMap
Loop
End Sub
________________________________
From: Peter Horsbøll Møller [mailto:[EMAIL PROTECTED]
Sent: Friday, 16 June 2006 6:20 PM
To: Ellingham Morgan; [email protected]
Subject: RE: [MI-L] Zoom to Extents of Selection - MapBasic Code
Morgan,
Your idea with zooming to the layer is correct. The problem is that MapInfo
can't find the layer in the map, so you need to add the layer to the map before
zooming to the extent of this layer/selection.
Something like this:
'**selecting all objects into a named temp table
Select * From ObjectsToMap
Where OBJ
Into TO__PRINT NoSelect
Fetch first From TO__PRINT
Do Until EOT(TO__PRINT)
nRow = TO__PRINT.OBJ 'remember to Dim this integer variable
'*Selecting the current record into a temp table
Select * From TO__PRINT
Where ROWID = nRow
Into CUR__OBJECT Noselect
Fetch First From CUR__OBJECT
Set Map
Center (CentroidX(CUR__OBJECT.obj), CentroidY(CUR__OBJECT.obj)) 'center
map on selected object
'**Adding the layer to be able to zoom to its extent
Add Map
Layer CUR__OBJECT
Set Map Zoom Entire Layer CUR__OBJECT
'**Removing the layer from the map again
Remove Map
Layer CUR__OBJECT
Run Menu Command 112 'Print Command
Fetch Next from TO__PRINT
Loop
HTH,
Peter Horsbøll Møller
GIS Developer, MTM
Geographical Information & IT
COWI A/S
Odensevej 95
DK-5260 Odense S.
Denmark
Tel +45 6311 4900
Direct +45 6311 4908
Mob +45 5156 1045
Fax +45 6311 4949
E-mail [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
http://www.cowi.dk/gis
________________________________
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ellingham Morgan
Sent: Friday, June 16, 2006 9:06 AM
To: [email protected]
Subject: [MI-L] Zoom to Extents of Selection - MapBasic Code
Hi all,
Am trying to create a batch to print off a series of maps automatically, I need
it to cycle through a series of mapped objects, print, then move to the next
object. I can get it to center at each object but the zoom extent stays the
same. Trying below code;
Select * From ObjectsToMap
Fetch first From ObjectsToMap
Do Until EOT(ObjectsToMap)
Set Map Center (CentroidX(Selection.obj), CentroidY(Selection.obj))
'center map on selected object
Set Map Window WindowID(1) Zoom Entire Layer
SelectionInfo(SEL_INFO_SELNAME) 'THIS IS WHERE THE ERROR IS "INVALID VIEW
LAYER" TRIED Layer Selection et al
Run Menu Command 112 'Print Command
Fetch next from ObjectsToMap
Loop
Any ideas?
Regards...
Morgan Ellingham
Citywide Service Solutions
GIS Technician
Level 1, 150 Jolimont Rd, East Melbourne
Ph: (03) 9261 5065
Mob: 0419 145 666
Email: [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l