7171from compas .datastructures import Network
7272from compas .datastructures import VolMesh
7373
74+ from compas .robots import RobotModel
75+
7476from .artist import GHArtist
7577from .circleartist import CircleArtist
7678from .frameartist import FrameArtist
99101VolMeshArtist .default_cellcolor = (255 , 0 , 0 )
100102
101103
102- @plugin (category = 'factories' , pluggable_name = 'new_artist' , requires = ['ghpythonlib' ])
104+ def verify_gh_context ():
105+ try :
106+ import Rhino
107+ import scriptcontext as sc
108+
109+ return not isinstance (sc .doc , Rhino .RhinoDoc )
110+ except :
111+ return False
112+
113+
114+ @plugin (category = 'factories' , pluggable_name = 'new_artist' , requires = ['ghpythonlib' , verify_gh_context ])
103115def new_artist_gh (cls , * args , ** kwargs ):
104116 # "lazy registration" seems necessary to avoid item-artist pairs to be overwritten unintentionally
105117
@@ -111,6 +123,7 @@ def new_artist_gh(cls, *args, **kwargs):
111123 GHArtist .register (Mesh , MeshArtist )
112124 GHArtist .register (Network , NetworkArtist )
113125 GHArtist .register (VolMesh , VolMeshArtist )
126+ GHArtist .register (RobotModel , RobotModelArtist )
114127
115128 data = args [0 ]
116129
@@ -127,7 +140,7 @@ def new_artist_gh(cls, *args, **kwargs):
127140 for name , value in inspect .getmembers (cls ):
128141 if inspect .ismethod (value ):
129142 if hasattr (value , '__isabstractmethod__' ):
130- raise Exception ('Abstract method not implemented' )
143+ raise Exception ('Abstract method not implemented: {}' . format ( value ) )
131144
132145 return super (Artist , cls ).__new__ (cls )
133146
0 commit comments