1010
1111import sys
1212from pathlib import Path
13+ import subprocess
1314
1415sys .path .append (str (Path (__file__ ).resolve ().parent .parent .parent ))
1516from mccodelib .instrgeom import Vector3d , DrawLine , DrawMultiline , DrawCircle
17+ from mccodelib import mccode_config
1618
1719
1820def vector_to_tuple (v : Vector3d ):
@@ -140,8 +142,19 @@ def instrument_to_assembly(inst):
140142
141143def main (instr = None , dirname = None , ** kwds ):
142144 from logging import basicConfig , INFO
145+ import time
143146 basicConfig (level = INFO )
144147
148+ try :
149+ # Try initial import or inform to install cadquery
150+ from cadquery .occ_impl .geom import Matrix
151+ except :
152+ message = "To use this display tool, please install the 'cadquery' Python package"
153+ subprocess .Popen ('%s %s' % (mccode_config .configuration ['MCCODE' ]+ "_errmsg" , message ), shell = True )
154+ print (mccode_config .configuration ['MCCODE' ]+ ": " + message )
155+ time .sleep (3 )
156+ quit ()
157+
145158 # output directory
146159 if dirname is None :
147160 from datetime import datetime as dt
@@ -158,7 +171,12 @@ def main(instr=None, dirname=None, **kwds):
158171
159172 # Do the conversion to a CadQuery assembly, then save it to the desired location
160173 assembly = instrument_to_assembly (instrument )
161- assembly .save (str (root .joinpath (f"{ Path (instr ).stem } .{ kwds .get ('format' ,'step' )} " )))
174+ output = str (root .joinpath (f"{ Path (instr ).stem } .{ kwds .get ('format' ,'step' )} " ))
175+ assembly .save (output )
176+
177+ # Use mccode_config / the OS to open the resulting file...
178+ if Path (output ).is_file ():
179+ subprocess .Popen ('%s %s' % (mccode_config .configuration ['BROWSER' ], output ), shell = True )
162180
163181def output_format (astring ):
164182 f = astring .lower ()
0 commit comments