MapBasic program to convert graphic text to labels

482 views
Skip to first unread message

Tom

unread,
Mar 12, 2007, 12:33:31 PM3/12/07
to MapInfo-L
I import ACAD DXF files into MapInfo. When I import street files, the
street names come in as graphics. I want to convert the graphic street
name obj into a label in the MapInfo table. I had a short MBX file
that would do this but seem to have lost it. Can anyone help?

Spencer Simpson

unread,
Mar 12, 2007, 2:52:39 PM3/12/07
to mapi...@googlegroups.com
Because DXF files can contain just about anything, there's no way that
general list members can tell precisely what you mean without more
information. Perhaps the vendor of your street files (whoever that is) can
help you.

We have to be really careful with terminology here, because it can lead to
confusion.

In MapInfo terminology, "tables" don't have "labels" -- "Labels" are text
graphics automatically placed by MapInfo in a Map window, and not saved in a
"table".

You may already know that a "table" is a collection of data and not the same
thing as a "Browser window", which is just a way of looking at the data
values. Although a Browser window looks exactly like something you'd call a
"table" in other applications, they're totally different things.

"Labels" are more properly associated with a "layer" (i.e. a given set of
rendering settings for a table, associated with a particular Map window).

Although you can adjust "labels" using tools in MapInfo Professional, you
can only save them in a workspace.

On the other hand, rows in mappable MapInfo tables can have "text objects"
associated with them. A "text object" can be moved around, resized, and
have its drawing settings changed, and the changes are saved in the table,
and pertain only to the affected row. However, a row can only have one
object, and if it's a text object, it can't also have, say, a polyline
representing a street centerline.

I might interpret

> When I import street files, the street names come in as graphics.

as meaning the DXF import process brought the street names in as text
objects (or, God forbid, as polylines). But I can't be sure. Do you want to
take the text string from each text object and assign it to a data value in
a table?

Now, MapInfo comes with a "Labeler" tool, which runs through a layer's
internal list of labels and creates a table containing text objects that
look just like the labels.

I'm sure there's a MB app which works in an analogous fashion, selecting all
of the rows in a table with text objects, extracting the text string out of
each selected row's object, and storing the string as a data value in the
row.

Once you have extracted street names out of the text objects, you can
transfer them to street centerlines if the rows containing street
centerlines and the rows with text objects have a common data value
associating each text object row with a particular centerline object row.

HTH
Spencer

Tom

unread,
Mar 12, 2007, 3:41:48 PM3/12/07
to MapInfo-L
Sorry for my ineptness in terminology and my short coming in
explaining my self. Let's forget about the DXF issue.

I have a MapInfo table showing streets with street names. The street
names are, I assume graphic. I want to make the street names available
as labels so I can search, sort and select by street name.

I had a short MapBasic .MB program (only 3 or 4 lines) that one of the
members provided me about a year ago that took the object that
represented the street name and put in a column adjacent to the ID
column.

Through table maintenance, I would add a Character column in the
streets table called "NAME" I would then open the MB file and enter
the proper table name, compile the program and run it. Through this
process the MBX program would enter the street name in the "NAME"
column in the row adjacent to the ID column.

I am also inept in MapBasic but I remember one of the lines of code
referred to obj 3.

Sorry again for the terminology, just thought someone might be able to
help me with my problem.

Spencer Simpson

unread,
Mar 13, 2007, 1:40:44 PM3/13/07
to mapi...@googlegroups.com
It's probably something like:

select * from mytable where str$(obj) = "Text" into mytextobjects noselect
update mytextobjects set name=ObjectInfo (obj,3)
close table mytextobjects

You can simply

1. Copy the code above
2. In MapInfo Professional, open the MapBasic window (using Options->Show
MapBasic Window)
3. Paste the code into the MapBasic window.
4. In the pasted text, replace "mytable" with the actual name of your table.
To update a different column, replace "name" with the other column's name.
5. Select all three lines
6. Hit ENTER

If you're confident that your table contains nothing but text objects, you
only need the middle ("update") line (in which case, step 4 would change to
'replace "mytextobjects" with the actual name of your table').

In case you didn't already know, the "MapBasic Window" is different from
"MapBasic". The window is a component of MapInfo Professional. It acts as
a sort of command-line interpreter, and lets you do a subset (actually,
most) of the things you can put into a MapBasic application. "MapBasic"
refers to the MapBasic development environment, a separate product from
MapInfo. It's used for developing canned applications (with an extension of
.MBX) containing dialogs, menus, and buttons. You don't need MapBasic to
use the MapBasic window.

Hope this helps
Spencer

-----Original Message-----
From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On
Behalf Of Tom
Sent: Monday, March 12, 2007 3:42 PM
To: MapInfo-L

Tom

unread,
Mar 13, 2007, 5:05:08 PM3/13/07
to MapInfo-L
Yes, Spencer, That's it. I knew it was something simple.

Thanks for your input.

Tom Halbrook

On Mar 13, 12:40 pm, "Spencer Simpson" <ssimp...@baltometro.org>
wrote:

> > that would do this but seem to have lost it. Can anyone help?- Hide quoted text -
>
> - Show quoted text -

Reply all
Reply to author
Forward
0 new messages