RhinoScriptSyntax - Section Style?

Just tried having a quick poke round, but couldn’t find anything - I’ve written a tool to set block properties to “By Parent” for things like linetype, print colour, etc, with commands similar to:

rs.ObjectLinetypeSource(obj,3)

I didn’t see any options in the RhinoScriptSyntax page but is there something similar to be able to set Section Style to “By Parent” as well? Something like…ObjectSectionSource?

Hi @ssommerv,

there is no method in RhinoScriptSyntax yet but it can be accessed with RhinoCommon in Rhino 8 from Attributes.SectionAttributesSource

eg. below should change an object’s section style source to “FromLayer”:

#! python 2

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    
    obj_id = rs.GetObject("Select object")
    if not obj_id: return
    
    rh_obj = rs.coercerhinoobject(obj_id, True, True)
    print "Old:", rh_obj.Attributes.SectionAttributesSource 
    
    source = Rhino.DocObjects.ObjectSectionAttributesSource.FromLayer
    print "New:", source
    
    attr = rh_obj.Attributes.Duplicate()
    attr.SectionAttributesSource = source
    scriptcontext.doc.Objects.ModifyAttributes(rh_obj, attr, False)

DoSomething()

does that help ?

_
c.

1 Like

Apologies for the delay, but I have only just had a moment to try this - yes, this works perfectly!

(Except I changed the line:

source = Rhino.DocObjects.ObjectSectionAttributesSource.FromLayer

to

source = Rhino.DocObjects.ObjectionSectionAttributesSource.FromParent

Cheers!