Re: MI Updating Object Styles

2000-01-19 Thread Bill Thoen

A much faster way to do this is to write a function to do the
update. Take a look at ALterObject() here:

include "mapbasic.def"
declare sub main
declare Sub ResymbolizeRoad
declare function AlterObject(
   byval objLine as object,
   byval penObj as pen)
   as object

sub main
   call ResymbolizeRoad
end sub

Sub ResymbolizeRoad
dim penObj as Pen
   penObj = MakePen(1,2,RED)

   select * from dcdb where object into dcdbroad noselect
   update dcdbroad set obj=AlterObject(dcdbroad.obj, penObj)

End Sub

function AlterObject (
   byval objLine as object,   'original object
   byval penObj as pen)   'pen style desired
   as object  'altered object

dim objRoad as object
   objRoad = objLine
   alter object objRoad Info OBJ_INFO_PEN, penObj
   AlterObject = objRoad
end function
'--- end

- Bill Thoen


Paul Grambauer wrote:
> 
> Eric,
> Try this
> 
> '   Change the border of all road parcels to color Red
> 
> Sub ResymbolizeRoad
> 
> Dim objElem As Object
> Dim penObj As Pen
> 
> select * from dcdb where object into dcdbroad
> for i = 1 to tableinfo(dcdbroad,TAB_INFO_NROWS)
> fetch rec i from dcdbroad
> penObj = MakePen(1,2,RED)
> objElem = DCDBROAD.obj
> Alter Object objElem Info OBJ_INFO_PEN, penObj
> Update DCDBROAD Set obj = objElem Where RowID = i
> next
> 
> End Sub
> 
> Hope it helps,
> 
> Paul Grambauer
> Cessnock City Council
> PO Box 152,
> 68-72 Vincent St,
> Cessnock, 2325
> Phone : +61 02 49934192
> Fax : +61 02 49934200
> Email : [EMAIL PROTECTED]
> 
> --
> From:   Eric Frost[SMTP:[EMAIL PROTECTED]]
> Sent:   Wednesday, January 19, 2000 9:16 AM
> To: [EMAIL PROTECTED]
> Subject:MI Updating Object Styles
> 
> Mappers:
> 
> Is there a way to update an object's style programmatically
> without recreating the object?
> 
> A snippet of sample code from the MapBasic Help file says:
> 
> 'set a new "current symbol style"
> sSymbolAttr = "(35,65280,22)"
> sCmd = "Set Style Symbol MakeSymbol" + sSymbolAttr
> Run Command sCmd
> 
> ' use an Update statement to create a new Point for
> ' every row in the Selection table.  Each new Point
> ' will use the new "current symbol style"
> Update "Selection"
>   Set obj = CreatePoint(CentroidX(obj),CentroidY(obj))
> 
> However, I need to do this for polygons!
> 
> When working in MapInfo, I can go to "Options | Region Style"
> and modify editable, selected objects in the current window..
> but that doesn't seem to work from within MapBasic (?)
> 
> I understand maybe I need to loop through each polygon and
> modify them using Alter Object?
> 
> Thanks in advance for any insight!
> 
> Eric
> 
> --
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
> 
> --
> To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
> "unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]
--
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]



Re: MI Updating Object Styles

2000-01-18 Thread Michel Larue

Hello,

I made a little utility that can copy and paste a style from object to 
selected objects. It might help you.

Cheers

Michel Larue

At 16:16 18/01/2000 -0600, you wrote:
>Mappers:
>
>Is there a way to update an object's style programmatically
>without recreating the object?
>
>A snippet of sample code from the MapBasic Help file says:
>
>'set a new "current symbol style"
>sSymbolAttr = "(35,65280,22)"
>sCmd = "Set Style Symbol MakeSymbol" + sSymbolAttr
>Run Command sCmd
>
>' use an Update statement to create a new Point for
>' every row in the Selection table.  Each new Point
>' will use the new "current symbol style"
>Update "Selection"
>   Set obj = CreatePoint(CentroidX(obj),CentroidY(obj))
>
>However, I need to do this for polygons!
>
>When working in MapInfo, I can go to "Options | Region Style"
>and modify editable, selected objects in the current window..
>but that doesn't seem to work from within MapBasic (?)
>
>I understand maybe I need to loop through each polygon and
>modify them using Alter Object?
>
>Thanks in advance for any insight!
>
>Eric
>
>
>
>--
>To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
>"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

 ID_STYLE.MBX

'
'* Name:ID_STYLE1.MB  *
'* Author:  B.M. Larue  *
'* Company: SOPAC  *
'* Date:26/8/95
*
'


Include "c:\mapinfo\mapbasic\mapbasic.def"
Include "c:\mapinfo\mapbasic\menu.def"

Declare sub Main
Declare Sub Copy_Style
Declare Sub Paste_Style
Declare Sub About
Declare Sub Quit
Declare Sub Null

Global i,k,kmax,j,jmax,imax As Integer  ' Whole numbers from 
-2,147,483,647 to +2,147,483,647 
'Global j   As smallInt ' Whole numbers from -32767 to 32767 
(inclusive); stored in two bytes
Global xAs float' Floating point value; stored in eight-byte 
IEEE format
Global aAs string   ' Variable-length character string, up to 
32767 bytes long
Global bAs String * 100 ' Fixed-length character string (where length dictates 
the length of the string, in bytes, up to 32767 bytes); fixed-length strings  are 
padded with trailing blanks 
Global Poly As Object   '   Graphical object (Point, Region, Line, 
Polyline, Arc, Rectangle, Rounded Rectangle, Ellipse, Text, or Frame)
Global Esc  As Logical  ' TRUE or FALSE, stored in one byte (zero = 
FALSE, non-zero = TRUE)
Global DAs Date ' (MM/DD/), stored in four 
bytes: two bytes for the year, one byte for the month, one byte for the day

Global C As Alias   ' Column name 
Global P As Pen ' Pen (line) style setting 
Global Br As Brush  ' Brush (fill) style setting
Global F As Font' Font (text) style setting
Global S As Symbol  ' Symbol (point-marker) style setting

Global win_id As Integer
Global zoom_win As float
Global scale As float
Global xcenter As float
Global ycenter  As float
Global xmin As float
Global ymin As float
Global xmax As float
Global ymax As float
Global units As string
Global dist_unit As string 
Global scroll As logical
Global Win_x As float
Global Win_y As float
Global object As object
Global ObjColumn as alias
Global obj_type As Integer

Sub Main
  Create Menu "&ID_STYLE"
As  "Copy_Style"Calling Copy_Style,
"Past_Style"Calling Paste_Style,
"(-",
"About" Calling About,
"(-",
"Exit"  Calling Quit

  Alter Menu Bar Add "&ID_STYLE"

End Sub ' Main

sub Copy_Style
if selectioninfo(SEL_INFO_NROWS) <> 1 then
note "Select ONE object first"
exit sub
end if
P = CurrentPen()
Br = CurrentBrush()
F = CurrentFont()
S = CurrentSymbol()
ObjColumn = Selection + ".obj"
obj_type = ObjectInfo(ObjColumn , OBJ_INFO_TYPE)
object = ObjColumn 

Do case obj_type 
Case OBJ_PLINE 
P = ObjectInfo(object,OBJ_INFO_PEN ) 
Case  OBJ_REGION 
Br = ObjectInfo(object,OBJ_INFO_BRUSH )
P = ObjectInfo(object,OBJ_INFO_PEN ) 
Case OBJ_LINE
P = ObjectInfo(object,OBJ_INFO_PEN ) 
Case OBJ_POINT 
S = ObjectInfo(object,OBJ_INFO_SYMBOL ) 
Case OBJ_TEXT
F = ObjectInfo(object,OBJ_INFO_TEXTFONT )
Case OBJ_ARC 
P = ObjectInfo(object,OBJ_INFO_PEN ) 
Case OBJ_ELLIPSE
Br = ObjectInfo(object,OBJ_INFO_BRUSH )
P = ObjectInfo(object,OBJ_INFO_PEN ) 
Case OBJ_RECT

RE: MI Updating Object Styles

2000-01-18 Thread Paul Grambauer

Eric,
Try this

'   Change the border of all road parcels to color Red

Sub ResymbolizeRoad

Dim objElem As Object
Dim penObj As Pen

select * from dcdb where object into dcdbroad
for i = 1 to tableinfo(dcdbroad,TAB_INFO_NROWS)
fetch rec i from dcdbroad
penObj = MakePen(1,2,RED)
objElem = DCDBROAD.obj
Alter Object objElem Info OBJ_INFO_PEN, penObj
Update DCDBROAD Set obj = objElem Where RowID = i
next

End Sub

Hope it helps,

Paul Grambauer
Cessnock City Council
PO Box 152,
68-72 Vincent St,
Cessnock, 2325
Phone : +61 02 49934192
Fax : +61 02 49934200
Email : [EMAIL PROTECTED]

--
From:   Eric Frost[SMTP:[EMAIL PROTECTED]]
Sent:   Wednesday, January 19, 2000 9:16 AM
To: [EMAIL PROTECTED]
Subject:MI Updating Object Styles

Mappers:

Is there a way to update an object's style programmatically 
without recreating the object?

A snippet of sample code from the MapBasic Help file says:

'set a new "current symbol style" 
sSymbolAttr = "(35,65280,22)"
sCmd = "Set Style Symbol MakeSymbol" + sSymbolAttr
Run Command sCmd

' use an Update statement to create a new Point for 
' every row in the Selection table.  Each new Point
' will use the new "current symbol style" 
Update "Selection"  
  Set obj = CreatePoint(CentroidX(obj),CentroidY(obj))

However, I need to do this for polygons!

When working in MapInfo, I can go to "Options | Region Style"
and modify editable, selected objects in the current window..
but that doesn't seem to work from within MapBasic (?)

I understand maybe I need to loop through each polygon and
modify them using Alter Object?

Thanks in advance for any insight!

Eric



--
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]

--
To unsubscribe from this list, send e-mail to [EMAIL PROTECTED] and put
"unsubscribe MAPINFO-L" in the message body, or contact [EMAIL PROTECTED]