How to change a point's style from the MapBasic Window

986 views
Skip to first unread message

Tim Fast

unread,
May 23, 2007, 12:03:50 PM5/23/07
to MapInfo-L
Listers,

Is there a way to change a point's style from the MapBasic window? I
want to select a number of points and change their color, however, I
don't want to use the Symbol Style button.
In other words, clicking on the symbol style button and changing a
symbol style yields nothing in the MapBasic window. What command can I
issue in the window that would do the same thing as clicking on the
button?

Thanks,

Tim Fast

Peter Horsbøll Møller

unread,
May 23, 2007, 4:52:36 PM5/23/07
to mapi...@googlegroups.com

Hi Tim,

As long as you only are updating points this should do the trick:

Set Style Symbol MakeSymbol(34,12,0)
Set CoordSys Table Selection
Update Selection Set OBJ = Centroid(OBJ)

Here I have chosen a black dot as symbol. You just have to specify your own.
The trick here is that I update each record with the centroid of the object.
And the centroid of a point is actually the point it self.
So I recreate the points, but I use a different symbol style than the original point.

This is also why you can't do this with other object types. They are more that just a centroid.

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  p...@cowi.dk
http://www.cowi.dk/gis

siddahrtha kamasani

unread,
Feb 8, 2013, 8:23:23 AM2/8/13
to mapi...@googlegroups.com
Dim Selobj as object

If SelectionInfo(SEL_INFO_NROWS) = 1 then
  Fetch first from selection
  Selobj = Selection.obj
  Alter Object Selobj Info OBJ_INFO_PEN, Makepen (7,2,0)
  Update Selection Set Obj = Selobj  Where ROWID = 1
End If




On 8 February 2013 18:42, Andrew Aung <andrew...@googlemail.com> wrote:
Hi Peter,
 
I am trying to update the style of lines selected.
 
I know you say "This is also why you can't do this with other object types. They are more that just a centroid."
 
I'm using (without success):
 

set style pen makepen (7,2,0)

Update Selection Set obj = centroid(OBJ)

Cheers

Andy

--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Warm Regds
Sidharth Kamasani

Thomas Bacon

unread,
Feb 8, 2013, 8:51:48 AM2/8/13
to mapi...@googlegroups.com

Andy,

 

Why not just use the line style button in MapInfo’s toolbar? Or have I missed something?

 

Regards,

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility



Mouchel logo

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

Message has been deleted

Andrew Aung

unread,
Feb 8, 2013, 9:13:20 AM2/8/13
to mapi...@googlegroups.com

Tom,

I am doing this manually at the moment but I’m doing this on multiple selections of lines.

I'm also changing the styles of multiple region styles (polygons) manually so if I can find a way to use mapbasic to select and change mulpile line styles and region styles this would save me a lot of effort.

Cheers

Andy

Thomas Bacon

unread,
Feb 8, 2013, 9:39:24 AM2/8/13
to mapi...@googlegroups.com

So you want MapBasic to do the selections as well? Do you have a predetermined set of queries for your required selections? It would be fairly easy to write an MBX to carry out a number of queries and change object styles based on these queries at the push of a button.

Error! Filename not specified.

Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX.  The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. 

--

Eric Blasenheim

unread,
Feb 8, 2013, 9:55:33 AM2/8/13
to mapi...@googlegroups.com
Two quick points that may have been covered.  You can update multiple records with the same style via the UI or MapBasic (Update Selection) But with regions and polylines you have to change each object to the new style before updating. 
 
In my opinion, you might be better just using a theme and leave the geometries alone!
 
Eric Blasenheim
Pitney Bowes Software.

Andrew Aung

unread,
Feb 8, 2013, 10:06:58 AM2/8/13
to mapi...@googlegroups.com
Hi Tom,
 
Thanks for the quick reply.
 
I do have a set of quires that I am running one at a time then manually changing the line style (or region style).
 
What I would like is the code required to change the style of the line or region.
 
Cheers
 
Andy

Andrew Aung

unread,
Feb 8, 2013, 10:25:42 AM2/8/13
to mapi...@googlegroups.com
Hi Eric,
 
Thanks for the reply.  What code would I use to update multiple records with the same style via the UI or MapBasic (Update Selection)?
 
The application of this is for background layers which cannot have themes applied to them.

Cheers
 
Andy 

Thomas Bacon

unread,
Feb 8, 2013, 10:25:18 AM2/8/13
to mapi...@googlegroups.com

Andy,

 

Below is a small example of how you might do this using a compiled MapBasic script. Obviously you can use the same method to change brush styles as well, and you may want to run a check on each object before changing the style that it can accept the change (e.g. a line does not have a brush style). Hope this helps.

 

'=============================================================================================

Include "MapBasic.def"

 

Declare Sub Main

Declare Function UpdatePen(ByVal styleObj as Object, ByVal usePen as Pen) as Object

 

Sub Main

 

Dim strQueries(2) as String

Dim penStyle(2) as Pen

 

     strQueries(1) = "Select * from Example where RowID > 5 Into ChangePen"

     penStyle(1) = MakePen(1,2,BLACK)

     strQueries(2) = "Select * from Example where RowID <= 5 Into ChangePen"

     penStyle(2) = MakePen(1,2,RED)

 

     For i = 1 to UBound(strQueries)

           Run Command strQueries(1)

           Update ChangePen set Obj = UpdatePen(obj, penStyle(i))

           Commit table ChangePen

          Close table ChangePen

     Next

         

End Sub

 

Function UpdatePen(ByVal styleObj as Object, ByVal newPen as Pen) as Object

 

     Alter object styleObj Info OBJ_INFO_PEN, newPen

     UpdatePen = styleObj

 

End Sub

'=============================================================================================

Thomas Bacon

unread,
Feb 8, 2013, 10:29:35 AM2/8/13
to mapi...@googlegroups.com

Run Command strQueries(1)

 

should read…

 

 Run Command strQueries(i)

 

Tom Bacon

GIS Engineer, Mouchel

T 01444 472380 │ E thomas...@mouchel.com W www.mouchel.com

Our values: innovation │ excellence │ integrity │ responsibility

 

Andy Harfoot

unread,
Feb 8, 2013, 10:53:41 AM2/8/13
to mapi...@googlegroups.com
Hi Andrew,

Search for the Hard Code Thematics tool (mentioned on this list fairly regularly), this offers an alternative approach, defining multiple styles using the UI (as a theme) and then converting the theme into the default style for the objects.

You can find it here:
http://www.mapinfotools.com/index.php?option=com_sobi2&sobi2Task=sobi2Details&catid=2&sobi2Id=364&Itemid=72

Andy

Andrew Aung wrote:
--
--
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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 


-- 
Andy Harfoot

GeoData Institute
University of Southampton
Southampton
SO17 1BJ

Tel:  +44 (0)23 8059 2719
Fax:  +44 (0)23 8059 2849

www.geodata.soton.ac.uk
Reply all
Reply to author
Forward
0 new messages