Rhino common API - LinetypeScale

Hello,

I am new to Rhino and particularly enjoy creating new commands with Rhino scripts. Could you please explain why this code doesn’t work to change the linetypeScale with the Rhino common API?

Thank you in advance for your help.

Best regards,

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

def change_linetype_scale(curve_id, scale):
    curve = rs.coercecurve(curve_id)
    if curve:
        obj = sc.doc.Objects.Find(curve_id)
        if obj:
            obj.Attributes.LinetypeScale = scale
            obj.CommitChanges()
            sc.doc.Views.Redraw()
            print(f"L'échelle du type de ligne de la courbe {curve_id} a été changée en {scale}.")
        else:
            print("Impossible de trouver l'objet dans le document.")
    else:
        print("L'objet sélectionné n'est pas une courbe.")

# Sélectionner la courbe
curve_id = rs.GetObject("Sélectionnez une courbe", rs.filter.curve)
if curve_id:
    change_linetype_scale(curve_id, 5)

Hi @Guillec,

This works in Rhino 8:

import Rhino
import scriptcontext as sc

def Test():
    obj_type = Rhino.DocObjects.ObjectType.Curve
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select curve", False, obj_type)
    if objref and rc == Rhino.Commands.Result.Success:
        obj = objref.Object()
        if obj:
            attributes = obj.Attributes.Duplicate()
            attributes.LinetypePatternScale  = 5
            sc.doc.Objects.ModifyAttributes(objref, attributes, True)
            sc.doc.Views.Redraw()

if __name__ == "__main__":
    Test()

– Dale

Great, that works, thank you very much, this will help me a lot !