How to know what the default linetype name is?

Hi,

I just found that the linetypes listed via rhinoscriptsyntax.LinetypeNames(), omits the linetype ‘Continuous’.
This appears to be the default, hardcoded linetype.

Is there a way to find the name of that default linetype? Is it always Continuous; is it always present in all files?

The issue I ran into is that when explicitly stating linetypes for layers and testing them against the existing linetypes in the document, the ‘continouos’ type is caught as non-existent.

Can someone shed some light on what can be expected so I can write a valid workaround.
Is there somewhere to know the name of the default linetype?

Thanks
-Willem

I think setting the layer linetype index to -1 will set it to default (continuous), but unfortunately, the following doesn’t seem to work here:

import scriptcontext as sc

layers=sc.doc.Layers
index=layers.Find("Default",True)
print layers[index].LinetypeIndex
layers[index].LinetypeIndex=-1
layers[index].CommitChanges()
print layers[index].LinetypeIndex
sc.doc.Views.Redraw()

Hmmm… --Mitch

@Willem, i guess it has no name. If you set a linetype instance to Default(), it is continuous.

@Helvetosaur, below seems to work, strange it uses -1 as index:

import Rhino
import scriptcontext

def DoSomething():

    # get the layer
    layer_index = scriptcontext.doc.Layers.Find("Default", True)
    layer = scriptcontext.doc.Layers[layer_index]

    # get layers linetype name and index
    lt_index = layer.LinetypeIndex
    lt_name = scriptcontext.doc.Linetypes[lt_index].Name
    print "Linetype '{}' with index: {}".format(lt_name, lt_index)

    # set linetype to continuous (default)
    lt = Rhino.DocObjects.Linetype()
    lt.Default()
    layer.LinetypeIndex = lt.LinetypeIndex
    layer.CommitChanges()
    print "New LinetypeIndex:", layer.LinetypeIndex
    scriptcontext.doc.Views.Redraw()

DoSomething()

c.

1 Like