This message originated Externally. Use proper judgement and caution with attachments, links, or responses. |
Not quite.
If you aren’t using a MapBasic project, it will be easist to copy and paste these additional functions into your code:
I have modified these a bit compared to how they look in the MapBasic module I was referring to.
I have changed the error handling to be more simple to avoid including more modules/functions.
'**********************************************************************************************''
Function STLAlterClosedObject( ByVal oObj As Object 'Closed object whoes style to change
, ByVal penNew As Pen 'New Pen style to assign
, ByVal brsNew As Brush 'New Brush style to assign
) As Object
OnError GoTo ErrorOccured
STLAlterClosedObject = oObj
oObj = STLAlterPen(oObj, penNew)
oObj = STLAlterBrush(oObj, brsNew)
STLAlterClosedObject = oObj
Exit Function
'-------------------------
ErrorOccured:
Print Err() & “ “ & Error$() & " STLAlterClosedObject"
End Function
'**********************************************************************************************''
Function STLAlterPen( ByVal oObj As Object 'Object whoes style to change
, ByVal penNew As Pen 'New Pen style to assign
) As Object
OnError GoTo ErrorOccured
STLAlterPen = oObj
If STLObjectHasPen(oObj) Then
Alter Object oObj
Info OBJ_INFO_PEN, penNew
STLAlterPen = oObj
End If
Exit Function
'-------------------------
ErrorOccured:
Print Err() & " " & Error$() & " STLAlterPen"
End Function
'**********************************************************************************************''
Function STLAlterBrush( ByVal oObj As Object 'Object whoes style to change
, ByVal brsNew As Brush 'New Brush style to assign
) As Object
OnError GoTo ErrorOccured
STLAlterBrush = oObj
If STLObjectHasBrush(oObj) Then
Alter Object oObj
Info OBJ_INFO_BRUSH, brsNew
STLAlterBrush = oObj
End If
Exit Function
'-------------------------
ErrorOccured:
Print Err() & “ “ & Error$() & " STLAlterBrush"
End Function
'**********************************************************************************************''
Function STLObjectHasPen(ByVal oObj As Object) As Logical
OnError GoTo ErrorOccured
STLObjectHasPen = FALSE
Do Case ObjectInfo(oObj, OBJ_INFO_TYPE)
Case OBJ_TYPE_ARC, OBJ_TYPE_LINE, OBJ_TYPE_PLINE
STLObjectHasPen = TRUE
' Case OBJ_TYPE_TEXT
' Case OBJ_TYPE_POINT, OBJ_TYPE_MPOINT
Case OBJ_TYPE_REGION, OBJ_TYPE_RECT, OBJ_TYPE_ROUNDRECT, OBJ_TYPE_ELLIPSE
STLObjectHasPen = TRUE
Case OBJ_TYPE_COLLECTION
STLObjectHasPen = TRUE
Case OBJ_TYPE_FRAME
STLObjectHasPen = TRUE
End Case
Exit Function
'-------------------------
ErrorOccured:
Print Err() & " " & Error$() & " STLObjectHasPen"
End Function
'**********************************************************************************************''
Function STLObjectHasBrush(ByVal oObj As Object) As Logical
OnError GoTo ErrorOccured
STLObjectHasBrush = FALSE
Do Case ObjectInfo(oObj, OBJ_INFO_TYPE)
' Case OBJ_TYPE_ARC, OBJ_TYPE_LINE, OBJ_TYPE_PLINE
' Case OBJ_TYPE_TEXT
' Case OBJ_TYPE_POINT, OBJ_TYPE_MPOINT
Case OBJ_TYPE_REGION, OBJ_TYPE_RECT, OBJ_TYPE_ROUNDRECT, OBJ_TYPE_ELLIPSE
STLObjectHasBrush = TRUE
Case OBJ_TYPE_COLLECTION
STLObjectHasBrush = TRUE
Case OBJ_TYPE_FRAME
STLObjectHasBrush = TRUE
End Case
Exit Function
'-------------------------
ErrorOccured:
Print Err() & " " & Error$() & " STLObjectHasBrush"
End Function
And you need to declare these functions at the top of your code similar to declaring your Sub Main:
Declare Function STLAlterClosedObject( ByVal oObj As Object 'Closed object whoes style to change
, ByVal penNew As Pen 'New Pen style to assign
, ByVal brsNew As Brush 'New Brush style to assign
) As Object 'Return the same object with a different style
Declare Function STLAlterPen( ByVal oObj As Object 'Object whoes style to change
, ByVal penNew As Pen 'New Pen style to assign
) As Object 'Return the same object with a different style
Declare Function STLAlterBrush( ByVal oObj As Object 'Object whoes style to change
, ByVal brsNew As Brush 'New Brush style to assign
) As Object 'Return the same object with a different style
Declare Function STLObjectHasPen( ByVal oObj As Object 'Object to check for style
) As Logical 'Returns true if oObj has a Pen style
Declare Function STLObjectHasBrush( ByVal oObj As Object 'Object to check for style
) As Logical 'Returns true if oObj has a Brush style
You need all 5 functions, as they are used by “each other”.
The first function call the second two, and they each call one of the last two functions.
I hope these makes sense
Peter
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/33a34839-4039-426c-a9f0-a50fb43bd836n%40googlegroups.com.
Hi Matthew
I put it all into a MapBasic module. I think that makes it easier for all of us 😊
I compiled it and ran it with a table of mine.
And it works. My buffers “disappeared” as their style now got invisible.
All you need to do is change the path and file name in line 27.
And potentially change the pen and brush style if required.
Cheers
To view this discussion on the web visit https://groups.google.com/d/msgid/mapinfo-l/585721ae-c2c7-478f-aa46-b28e2625722dn%40googlegroups.com.