R7: rs.IsLinetype() returns True no matter what

Hi @dale I see that rs.IsLinetype() returns true on all inputs. Can you please check it out?

Even the example for the command returns “The linetype exists” on all inputs.

import rhinoscriptsyntax as rs
name = rs.GetString("Linetype name")
if rs.IsLinetype(name): print "The linetype exists."
else: print "The linetype does not exist"

Yep, definitely something wrong there. What is happening:

rs.IsLinetype() calls the following code:

def __getlinetype(name_or_id):
    id = rhutil.coerceguid(name_or_id)
    if id: return scriptcontext.doc.Linetypes.FindId(id)
    return scriptcontext.doc.Linetypes.FindName(name_or_id)

The last line is the equivalent of
Rhino.DocObjects.Tables.LinetypeTable.FindName()

Here’s what it does:

Notice that it returns Continuous if the linetype is not found… So it will never return something like False. Guess that particular function needs to be fixed.

1 Like

Nice digging Mitch, thanks.

I see that if I run

    lineTypeName = "name_of_choise"
    print rs.IsLinetype(lineTypeName)
    print sc.doc.Linetypes.FindName(lineTypeName)

Then it prints:

True
Linetype: Continuous (-1)

So this works fine:

if sc.doc.Linetypes.FindName(lineTypeName).Index == -1:
    #Do some stuff

Thanks @Holo.

https://mcneel.myjetbrains.com/youtrack/issue/RH-85401

– Dale