Deprecated: Return type of Lime\App::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/Lime/App.php on line 1357

Deprecated: Return type of Lime\App::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/Lime/App.php on line 1346

Deprecated: Return type of Lime\App::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/Lime/App.php on line 1342

Deprecated: Return type of Lime\App::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/Lime/App.php on line 1361

Deprecated: Creation of dynamic property MongoHybrid\MongoLite::$db is deprecated in /home/heraudcoyp/www/admin/lib/MongoHybrid/MongoLite.php on line 20

Deprecated: Return type of MongoLite\Cursor::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/MongoLite/Cursor.php on line 254

Deprecated: Return type of MongoLite\Cursor::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/MongoLite/Cursor.php on line 263

Deprecated: Return type of MongoLite\Cursor::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/MongoLite/Cursor.php on line 259

Deprecated: Return type of MongoLite\Cursor::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/MongoLite/Cursor.php on line 267

Deprecated: Return type of MongoLite\Cursor::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/heraudcoyp/www/admin/lib/MongoLite/Cursor.php on line 247
Configurer les matériaux de tous les objets en "par calque" avec Rhino Python – heraud.co
n°34
Configurer les matériaux de tous les objets en "par calque" avec Rhino Python
Python, Rhino3D
26 oct 2020
import rhinoscriptsyntax as rs
import Rhino.DocObjects

def loopBlock(block):
    objectsInBlock = rs.BlockObjects(rs.BlockInstanceName(block))

    for obj in objectsInBlock:
        if rs.ObjectType(obj) != 4096:
            action(obj)
        else:
            loopBlock(obj)

def action(object):
    rhino_object = rs.coercerhinoobject(object)
    rhino_object.Attributes.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromLayer
    rhino_object.CommitChanges()

rs.UnselectAllObjects()

objs = rs.AllObjects(include_lights=True, include_grips=True, include_references=True)
if objs:
    for obj in objs:
        if rs.ObjectType(obj) == 4096: #block
           loopBlock(obj)
        else:
            action(obj)
else:
    print "No objects selectable."

Ce script profite de la routine permettant d'appliquer une action sur tous les objets, même ceux situés à l'intérieur de blocs. Il offre un service bien utile lorsqu'on importe de la géométrie d'un autre modeleur (comme SketchUp par exemple) qui insiste pour configurer tous les matériaux par objet.

On remarquera l'usage de la fonction rs.coercerhinoobject() qui permet de passer du GUID d'un objet à l'objet Rhino lui même. Ce passage est nécessaire pour utiliser les fonctions de l'API RhinoCommon.

Mise à jour : cette fonction est maintenant intégrée à CHL Tools (0.3)


c. héraud-louisadat

architecte & développeur
67200 Strasbourg
heraud-arobase-laponies-point-fr

*1992, Strasbourg.

Diplômé d'état en 2016 de l'ENSA Paris-Malaquais et de la RWTH Aachen et habilité à maîtrise d'oeuvre en nom propre (HMONP) en 2019, j'ai travaillé pour diverses agences d'architecture à Paris et Berlin puis fait de la recherche en histoire de l'art sur l'architecture Heimatschutz. J'ai fondé l'agence Atkinson-Héraud Architectes en 2023 avec Isabelle Atkinson-Evans. Je développe également des applications pour le Web et la 3D.

Amis, famille et blogroll : Anaïs Héraud-Louisadat, Héraud–Baumann, Till Baumann, Antoine Le Dreff, Station Zéro, BALT.

alsace europe