Let me start by saying I have already contacted my VAR, and was told "our Support team does not assist with implementing or troubleshooting custom scripts".
The question is not how to deal with this as I already have a solution. However, is this unexpected behavior, or more typical of all Solidworks API methods that return a Boolean? In other words, is this what I should expect, or is this a bug? That is a question for the SolidWorks API team.
How do I submit this as an issue?
Details below:
I ran into a question about the Solidworks 2023 API, specifically about the behavior of the ICurve.IsCircle() method. I was writing a VBA macro and was using the IsCircle method to determine if an edge was circular. The issue comes up because the result returned looks like it is supposed to be Boolean according to the API help, but it does not fully behave that way. If I use it with the NOT operator, the results are wrong.
Example (For a curve that IS circular, so ICurve.IsCircle returns True) –
If swCurve.IsCircle Then do Something
‘expecting to execute Something since swCurve.IsCircle is evaluated 'True'
[works properly and the program executes Something.]
If (Not swCurve.IsCircle) Then do Something
‘not expecting to execute Something since (Not True) should evaluate to False
[does not work properly, and the program still executes Something.]
It appears the problem is that the return value is actually “1” or “0” behind the scenes. ‘IF’ testing against the value works if testing directly, since “1” is interpreted as “True” and “0” is interpreted as “False”. In fact, any non-zero value is interpreted as True. However, the logical NOT operation is really a bitwise flip of ALL the bits, including the sign bit. Therefore, although 1 = True, (NOT 1) = (-2) and in a boolean test, -2 is interpreted as True because it is non-zero.
