Title: Meddelelse
Jacob,
 
I would recommend using a function to alter the style of the object in stead of looping yourself.
If you use a function, you can use the Update statement and let MapInfo do the looping.
 
Sub Main
 
Update Selection
    Set OBJ = AlterLineStyle(OBJ, P_Penstyle)
 
End Sub
 
Function AlterLineStyle(ByVal oLine As Object, ByVal pNew As Pen) As Object
 
 Alter Object  oLine 
        Info  OBJ_INFO_PEN, pNew
 
AlterLineStyle = oLine
 
End Function
 
But do make sure that the selection:
- only contains records with an object (could be done with a select statement prior to doing the update)
- the objects support the line style (could be done with a select statement prior to doing the update or in the function)

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  [EMAIL PROTECTED]
http://www.cowi.dk/gis

"For enden af regnbuen..." - hvordan kommer man dertil og er det overhovedet muligt?
Læs mere om årets MapInfo konference på www.cowi.dk/mapinfokonference

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Watertech - Jacob K. Jørgensen
Sent: Monday, August 28, 2006 1:55 PM
To: [email protected]
Subject: [MI-L] Change pen style on selected objects through MapBasic orWOR-file

Hi all,
 
I would like to change the line style which is invoked in MapInfo by selecting all relevant objects in a map window from an editable layer and then choosing the icon "Line Style" in the drawing buttonpad.
 
Alas, I cannot find the MapBasic command for calling this button, so I cannot write a simple WOR file to do the job for me or a simple MapBasic program.
 
I have to loop through all the relevant records and change the object attribute by the command  Alter Object MyCurrentObj Info:
 
Dim P_Penstyle As Pen
Dim MyCurrentObj As Obj
 
P_Penstyle = MakePen (1, 2, 16711680)
For i = 1 To nRecords    'in current selection
    Fetch rec i From Selection
    MyCurrentObj = Selection.obj
    Alter Object  MyCurrentObj 
        Info  OBJ_INFO_PEN, P_Penstyle
    Update Selection Set obj = MyCurrentObj where RowID = i
Next
 
This way is rather slow when there are many records in the selection, so do any of you GISmo's out there have a better solution?
 
Thanks in advance

Jacob K. Jørgensen
Engineer, M.SC. in GeoInformatics
__________________________________________

Watertech
Soendergade 53
DK-8000 Aarhus C

Phone: +45 8732 2020
Direct phone: +45 8732 2078
Fax: +45 8732 2021


[EMAIL PROTECTED]
www.watertech.dk

_______________________________________________
MapInfo-L mailing list
[email protected]
http://www.directionsmag.com/mailman/listinfo/mapinfo-l

Reply via email to