Try this:
Sub NewCoord
Run Command "Run application " & Chr$(34) & "C:\Documents and
Settings\user\Application Data\MapInfo\MapInfo\changecoord.wor" & Chr$(34)
End Sub
Peter Horsb�ll M�ller
GIS Developer
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]
http://www.cowi.dk/gis
Sidste frist for tilmelding til MapInfo Konferencen er den 6. august 2004.
Tilmelding samt yderligere information kan ses p�: http://www.cowi.dk/GIS
-----Original Message-----
From: Nicolas Muszynski [mailto:[EMAIL PROTECTED]
Sent: Monday, August 09, 2004 8:56 PM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: MI-L Didn't Work RE: MI-L Changing projections with MapBasic -
Jacques' suggestion seemed like it should work but it doesn't. If I run his suggested
workspace from a MapBasic application through the "run application" command the
centroidX and CentroidY functions still works in the default projection. However if I
run the workspace from the
File->open workspace it works??? Doesn't make sense to me...
All I want to do is create a Menu item to change it with the chooseprojection$
function as opposed to writing the whole projection in the MapBasic Window each time
(I use UTM, MTM and custom projections often and they have lots of parameters to
write...). Everything seems to work except for what I described above.
Thank you!
The code I use is:
Include "MapBasic.def"
Declare Sub Main
Declare Sub NewCoord
Sub Main
Alter Menu "Options" Add
"Change Global Projection" Calling NewCoord
End Sub
Sub NewCoord
Run application "C:\Documents and Settings\user\Application
Data\MapInfo\MapInfo\changecoord.wor"
End Sub
And the workspace is as suggested by Jacques:
!Workspace
!Version 600
!Charset WindowsLatin1
Dim a as string
a="set "+chooseprojection$("",1)
run command a
undim a
Nicolas Muszynski
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: 9 ao�t 2004 09:31
To: [EMAIL PROTECTED]
Subject: RE: MI-L Changing projections with MapBasic
If you are running MapInfo Pro 7.0 & later there are now two Projection preferences
that will do the following:
Table Projection - Use for Importing MIF, IMG, MBI, MMI, and SHP files. When you are
importing MIF files that don't have a projection specified, they will have their
projection set to Default Table projection. When using the ChooseProjection$(
initial_coordsys, get_bounds ) function, if initial_coordsys is not valid or is empty,
the dialog will have Default Table projection selected. The default projection is
also used in the Create Points dialog, the New Table dialog, the New Table Structure
dialog, the Modify Table Structure dialog, the Image Registration dialog, and the Make
Table Mappable dialog.
Session Projection - The Default Session Projection is the projection that is used for
returning coordinate values in a MapBasic function executed using the MapBasic window
and via the GUI (e.g.: Update Column with
CentroidX(obj) ).
Compiled MapBasic applications do not use projection preferences and are not affected
by them.
You would use the Set Coordsys statement to effect a change in the Current MapBasic
Coordsys which is only in effect during running of that MapBasic program. When
program exits, MI Pro Session Coordsys reverts to Lon\Lat (no datum), or the session
projection prerference in MI Pro 7.0 & later. A startup.wor to set the session
coordsys would not be necessary in these newer versions.
MapBasic 7.x also has a SessionInfo() function that can give you the following info to
determine and set the global MapBasic Coordsys, Area, Distance, and Paper units within
a running program.
SessionInfo(1) - returns current MapInfo Pro Session Coordsys
SessionInfo(2) - returns current MapInfo Pro Distance Units
SessionInfo(3) - returns current MapInfo Pro Area Units
SessionInfo(4) - returns current MapInfo Pro Paper Units
If you are using version MI Pro 6.5 & earlier, then Jacques' suggestions would work
fine in setting the session projection.
Regards,
-Bill
Mail List:
[EMAIL PROTECTED]
From: on 08/06/2004 04:48 PM AST
To: "Nicolas Muszynski" <[EMAIL PROTECTED]>, "MIL"
<[EMAIL PROTECTED]>
cc:
Subject: RE: MI-L Changing projections with MapBasic
You are talking about two domains that do not communicate. The "global" one is used
for the internal working of MapInfo and is accessed by the MapBasic window. The
"application" domain is totally independent and several coordsys can thus exist in
parallel.
If you were to add at the end of your NewCoord sub "print centroidx(selection.obj)"
and open a table and select one object before running the mbx, you will see that the
measure is in the new coordsys, but that the "global" one has not changed.
That may indeed look strange given the fact that it is said that the "run command" is
processed outside the application domain...
But if you were to run from the MB window the following lines
Dim a as string
a=coordsys$()
run command "set "+a
the "global" coordsys will be changed
One way to do it without writing it each time would be to prepare a wor and use a run
application "fullpath\changeglobalcoordsys.wor". That wor would look something like
!Workspace
!Version 600
!Charset WindowsLatin1
Dim a as string
a="set "+chooseprojection$("",1)
run command a
undim a
You can of course use that wor-based function from within a compiled mbx with the "run
application"
Jacques Paris
e-mail [EMAIL PROTECTED]
MapBasic-MapInfo support http://www.paris-pc-gis.com
-----Original Message-----
From: Nicolas Muszynski [mailto:[EMAIL PROTECTED]
Sent: 6-Aug-04 12:00
To: [EMAIL PROTECTED]
Subject: MI-L Changing projections with MapBasic
Hello,
I am trying to make a very simple MapBasic program to change the "Global" MapInfo
projection, the equivalent of typing: "Set Coordsys Earth projection (whatever the
projection may be)" In the MapBasic Window.
When I execute the line:
Run Command "Set Coordsys Earth projection "whatever the projection may be"
It changes the current application Projection but does not change the "global" Mapinfo
projection.
The reason I want to do this is that when objects are labelled with the function
CentroidX or CentroidY they automatically take the "Global" MapInfo Projection and do
not use the table projection, Layout Projection or map projection. The same happens
when you want to update a column with the same CentroidX or CentroidY Functions.
I included the program below for reference,
Include "MapBasic.def"
Declare Sub Main
Declare Sub NewCoord
Sub Main
Dialog
Title "Set a Global Projection"
Control StaticText
Title "Choose a Projection"
Control Button
Title "Choose Projection"
Calling NewCoord
End Sub
Sub NewCoord
Dim NewSys as String
NewSys=ChooseProjection$("",True)
NewSys="Set " + NewSys
Dialog Remove
Note NewSys
Run Command NewSys
End Sub
Thank you for taking the time to at least read,
Nicolas Muszynski
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe,
e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12867
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe,
e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12872
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com | To unsubscribe,
e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12895
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 12897