Converting Polylines to Lines

30 views
Skip to first unread message

Reg Halstead

unread,
Jan 4, 2023, 5:42:26 AM1/4/23
to MapInfo-L
Hello again guys,

I'm guessing this should be a quick one to answer:

I'm trying to convert some polylines to lines by using the "run menu command" function to trigger the "Convert to Lines" tool. Is that possible, please?

I opened up MENU.DEF in Notepad and it seems that these are the only commands relating to objects:
Define M_OBJECTS_SET_TARGET                    1610
Define M_OBJECTS_CLEAR_TARGET                  1611
Define M_OBJECTS_COMBINE                       1605
Define M_OBJECTS_DISAGG                        1621
Define M_OBJECTS_BUFFER                        1606
Define M_OBJECTS_CONVEX_HULL                   1616
Define M_OBJECTS_ENCLOSE                       1617
Define M_OBJECTS_VORONOI                       1622
Define M_OBJECTS_DRIVE_REGION                  1627
Define M_OBJECTS_SPLIT                         1612
Define M_OBJECTS_ERASE                         1613
Define M_OBJECTS_ERASE_OUT                     1614
Define M_OBJECTS_POLYLINE_SPLIT                1623
Define M_OBJECTS_POLYLINE_SPLIT_AT_NODE        1626
Define M_OBJECTS_OVERLAY                       1615
Define M_OBJECTS_CHECK_REGIONS                 1618
Define M_OBJECTS_CLEAN                         1619
Define M_OBJECTS_SNAP                          1620
Define M_OBJECTS_OFFSET                        1624
Define M_OBJECTS_ROTATE                        1625
Define M_OBJECTS_SMOOTH                        1602
Define M_OBJECTS_UNSMOOTH                      1603
Define M_OBJECTS_CVT_PGON                      1607
Define M_OBJECTS_CVT_PLINE                     1604

So I'm assuming there isn't a way to trigger the "Convert to Lines" tool with MapBasic, but I thought I'd better ask to be on the safe side.

I've got a backup plan, but it's not ideal. A while ago, I wrote a loop that converts polylines to lines piece by piece, but sadly, it takes a long time to run.

Many thanks in advance,
Reggie

Peter Horsbøll Møller

unread,
Jan 4, 2023, 5:50:29 AM1/4/23
to mapi...@googlegroups.com

Hi Reggie

 

It’s one of these two:

Define M_OBJECTS_CVT_PGON                      1607
Define M_OBJECTS_CVT_PLINE                     1604

 

I think it’s the last one

 

You can also use a simple Update statement:

 

Update SomeTable Set OBJ = ConvertToPline(OBJ)

 

HTH

Peter

 

Peter Horsbøll Møller
Principal Sales Engineer - Distinguished Engineer

 

From: mapi...@googlegroups.com <mapi...@googlegroups.com> On Behalf Of Reg Halstead
Sent: Wednesday, 4 January 2023 11.42
To: MapInfo-L <mapi...@googlegroups.com>
Subject: [MI-L] Converting Polylines to Lines

 

This message originated Externally. Use proper judgement and caution with attachments, links, or responses.

--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

---
You received this message because you are subscribed to the Google Groups "MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mapinfo-l+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/cbe23874-0b1d-4817-9c3b-01ef10a4869fn%40googlegroups.com.

Uffe Kousgaard

unread,
Jan 4, 2023, 5:56:08 AM1/4/23
to mapi...@googlegroups.com
Hi,

I only see a "Convert to Polylines" tool in MapInfo and 1604 seems to be the corresponding menu item.

Anyway,my ToolBox (https://www.routeware.dk/download/toolbox_110.7z) has such a function.
It can convert in both directions, but in the end it is also a loop. Source code is included in link above.

Kind regards
Uffe Kousgaard

Reg Halstead

unread,
Jan 4, 2023, 6:04:29 AM1/4/23
to mapi...@googlegroups.com
Thanks a lot for the speedy reply but it's the Convert to Lines tool I'm trying to trigger, not the "Convert to Polylines" tool (equivalent to ConvertToPlines() as you say).

MapBasic includes a ConvertToPlines() function and a ConvertToRegions() function, but sadly there isn't a ConvertToLines() function as well. I'm guessing that's something to do with the fact that converting polylines to lines changes the number of objects.

I'm trying to split polylines into separate lines and the Convert to Lines tool does it very quickly, as opposed to the loop I've written. Is it possible to trigger any button/tool in MapInfo or only the ones that are listed in MENU.DEF?

Best wishes,
Reggie



--
Reg Halstead
GIS Project & Implementation Manager
RAH Services
Tel: 07790056983

Reg Halstead

unread,
Jan 4, 2023, 6:06:48 AM1/4/23
to mapi...@googlegroups.com
Thanks a lot for the fast reply as well Uffe.

I'm just about to open it now.

Many thanks,
Reggie

Uffe Kousgaard

unread,
Jan 4, 2023, 6:32:45 AM1/4/23
to mapi...@googlegroups.com
Hi Reggie,

I see it is a function in mapCAD you are after.
It does something differently than my ToolBox.

I assume mapCAD also uses mapbasic, so maybe it is just your loop which needs to be optimized?
Remember to set fastedit on and such. Makes a big difference.

Regards
Uffe

Reg Halstead

unread,
Jan 4, 2023, 6:35:29 AM1/4/23
to mapi...@googlegroups.com
Thanks a lot, Uffe. I’ll give it a try. And thanks a lot for those files too. That was very generous. Reading through them will help built my MapBasic skills.

Reg Halstead

unread,
Jan 5, 2023, 4:57:31 AM1/5/23
to MapInfo-L
Uffe,

Your recommendation to use a  mapCAD function yesterday worked just as I needed so I just wanted to say thanks.

The SplitToLines function worked perfectly.

Here's the syntax I used for anyone reading this thread at a later date. Note my table only contained polylines, otherwise more lines 
Select * from MYTABLE 
print Exec("MapCAD.MBX","SplitToLines") & " polylines have been converted into " & str$(tableinfo("MYTABLE",8)) & " lines."

Best wishes,
Reggie
Reply all
Reply to author
Forward
0 new messages