AnsweredAssumed Answered

Unbelievable wrong result from surface.IsCylinder

Question asked by Keaton Weir-McPherson on Mar 11, 2020
Latest reply on Mar 12, 2020 by Keaton Weir-McPherson



Below is a snippet of code from a simple function I am working on. cyl is a face2 object which is passed in, and it is a cylinder. When the snipped below is run, the first four Trace# lines print in the immediate window, but the fifth and sixth ones don't. The seventh one does print as well! When I step through the code I can see check takes on the value of True, but when check is compared with true (If check = True Then ...) it is somehow not True.


Dim surf As SldWorks.Surface
Dim check As Boolean

Set surf = cyl.GetSurface

check = surf.IsCylinder

If check Then Debug.Print "Trace1"
If Not check Then Debug.Print "Trace2"

If surf.IsCylinder Then Debug.Print "Trace3"
If Not surf.IsCylinder Then Debug.Print "Trace4"


If check = True Then Debug.Print "Trace5"

If CBool(check) = True Then Debug.Print "Trace6"

If CBool(check) Then Debug.Print "Trace7"


The output in the immediate window is:



Can anyone help me with the bizzare error? I feel like I'm in opposite world all of a sudden.