How to change PenStyle for all objects in a table using MapBasic.

522 views
Skip to first unread message

Mark Dorney

unread,
Feb 17, 2008, 6:45:31 PM2/17/08
to MapInfo-L
Hello MapInfo-L people

I'm written some MapBasic code to process tables supplied to us for
the DCDB each quarter. Just nice simple stuff like indexing, appending
and querying out subsets.

I'd also like to change the pen style of all objects in a table, and
this doesn't seem simple.

I trawled through the old MapInfo-L discussion lists and a few people
had posted code but I couldn't get it to work. Maybe I was missing a
few Dim clauses or the like. (I'm not exactly a MapBasic expert.)

Any help would be appreciated. I know I could do it manually instead,
but it lacks elegance, as well as being slooooow.

Cheerful Regards

Mark Dorney
Queensland Transport

Peter Horsbøll Møller

unread,
Feb 18, 2008, 1:46:05 AM2/18/08
to mapi...@googlegroups.com

Mark,

Have a look at this thread. It contains all you need:
http://groups.google.com/group/mapinfo-l/browse_thread/thread/3e18e37b70e97e99/ffc1d58de7820e70?hl=en

The only thing you need to do is to change the BRUSH to a PEN

I have done this is this sample here:
'*****************************
Sub Main

Dim p As Pen
b=MakePen(2,1,YELLOW)

Update Selection
        Set obj = STYLChangePen(OBJ, b)

End Sub

'*****************************
Function STYLChangePen(ByVal oLine As Object, ByVal pNew As Pen)

        STYLChangePen = oLine

                '**You might want to add a check here to see if oLine really is a linear object

        Alter Object oLine
                Info OBJ_INFO_PEN, pNew

        STYLChangePen = oLine

End Function

HTH

Peter Horsbøll Møller
GIS Developer, MTM GeoInformatics
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  p...@cowi.dk
http://www.cowi.dk/gis

Reply all
Reply to author
Forward
0 new messages