[docs]classRobotModelArtist(BaseRobotModelArtist):"""Visualizer for robot models inside a Blender environment. Parameters ---------- model : :class:`compas.robots.RobotModel` Robot model. layer : str, optional The name of the layer that will contain the robot meshes. """def__init__(self,model,layer=None):self.layer=layersuper(RobotModelArtist,self).__init__(model)
[docs]defdraw_geometry(self,geometry,name=None,color=None):# Imported colors take priority over a the parameter colorif'mesh_color.diffuse'ingeometry.attributes:color=geometry.attributes['mesh_color.diffuse']# If we have a color, we'll discard alpha because draw_mesh is hard coded for a=1ifcolor:r,g,b,_a=colorcolor=[r,g,b]else:color=[1.,1.,1.]ifself.layer:collection=bpy.data.collections.new(self.layer)bpy.context.scene.collection.children.link(collection)v,f=geometry.to_vertices_and_faces()returncompas_blender.draw_mesh(vertices=v,faces=f,name=name,color=color,centroid=False,layer=self.layer)