Jump to content

automatically capture views for report


---
 Share

Recommended Posts

---

Hi Everyone!

I was wondering if anyone had a nice script for automatically capturing report 3d views for all the standard and isometric projections.

Link to comment
Share on other sites

  • 2 weeks later...
---

I have a script that do this. Of course the code must by adapted for your use:

 

		rif_dir=("S:\\"+reparto_maiuscolo+"\\Controlli\\*")
		if reparto==2 or reparto==3:
			rif_dir=("S:\\"+reparto_maiuscolo+"\\*")
		control_dir="S:\\"+reparto_maiuscolo+"\\Controlli\\*"
		if reparto==2 or reparto==3:
			control_dir=("S:\\"+reparto_maiuscolo+"\\*")
		RESULT=gom.script.sys.create_user_defined_dialog (content='<dialog>' \
	' <title>Confronto Vecchio/Nuovo</title>' \
	' <style>Standard</style>' \
	' <control id="OkCancel"/>' \
	' <position>center</position>' \
	' <embedding>always_toplevel</embedding>' \
	' <sizemode>automatic</sizemode>' \
	' <size width="348" height="408"/>' \
	' <content rows="8" columns="1">' \
	'  <widget row="0" rowspan="1" column="0" columnspan="1" type="label">' \
	'   <name>label_1</name>' \
	'   <tooltip></tooltip>' \
	'   <text>Imposta il Tempo di Preallineamento</text>' \
	'   <word_wrap>false</word_wrap>' \
	'  </widget>' \
	'  <widget row="1" rowspan="1" column="0" columnspan="1" type="input::radiobutton">' \
	'   <name>NormalOrLong</name>' \
	'   <tooltip></tooltip>' \
	'   <items>' \
	'    <item description="Corto" state="3"/>' \
	'    <item description="Normale" state="1"/>' \
	'    <item description="Lungo" state="2"/>' \
	'   </items>' \
	'   <default>1</default>' \
	'  </widget>' \
	'  <widget row="2" rowspan="1" column="0" columnspan="1" type="separator">' \
	'   <name>separator</name>' \
	'   <tooltip></tooltip>' \
	'   <title></title>' \
	'  </widget>' \
	'  <widget row="3" rowspan="1" column="0" columnspan="1" type="label">' \
	'   <name>label_2</name>' \
	'   <tooltip></tooltip>' \
	'   <text>Seleziona le Figure di Riferimento</text>' \
	'   <word_wrap>false</word_wrap>' \
	'  </widget>' \
	'  <widget row="4" rowspan="1" column="0" columnspan="1" type="input::file">' \
	'   <name>directory2</name>' \
	'   <tooltip>Importa di File di Riferimento</tooltip>' \
	'   <type>multi_file</type>' \
	'   <title>Scegli files</title>' \
	'   <default></default>' \
	'   <limited>true</limited>' \
	'   <file_types>' \
	'    <file_type description="Tutti i file" name="*.stl *.g3d"/>' \
	'   </file_types>' \
	'   <file_types_default>*.stl *.g3d</file_types_default>' \
	'  </widget>' \
	'  <widget row="5" rowspan="1" column="0" columnspan="1" type="separator">' \
	'   <name>separator_1</name>' \
	'   <tooltip></tooltip>' \
	'   <title></title>' \
	'  </widget>' \
	'  <widget row="6" rowspan="1" column="0" columnspan="1" type="label">' \
	'   <name>label</name>' \
	'   <tooltip></tooltip>' \
	'   <text>Seleziona le Figure da Controllare</text>' \
	'   <word_wrap>false</word_wrap>' \
	'  </widget>' \
	'  <widget row="7" rowspan="1" column="0" columnspan="1" type="input::file">' \
	'   <name>directory</name>' \
	'   <tooltip>Importa File Attuali</tooltip>' \
	'   <type>multi_file</type>' \
	'   <title>Scegli files</title>' \
	'   <default></default>' \
	'   <limited>true</limited>' \
	'   <file_types>' \
	'    <file_type description="Tutti i file" name="*.stl *.g3d"/>' \
	'   </file_types>' \
	'   <file_types_default>*.stl *.g3d</file_types_default>' \
	'  </widget>' \
	' </content>' \
	'</dialog>')
		
		RESULT.directory2.default = rif_dir
		RESULT.directory.default = control_dir
		
		RESULT=gom.script.sys.show_user_defined_dialog (dialog=RESULT)
		dir2 = RESULT.directory2
		print (dir2)
		dir = RESULT.directory
		print (dir)
		NormalOrLong = int(RESULT.NormalOrLong)
		print (NormalOrLong)
			
		for filenames in dir2:
			print(filenames)
			base, ext = os.path.splitext(filenames)
			if ext == '.stl':
				stlfile = os.path.join(filenames)
				gom.script.sys.import_stl (
					bgr_coding=True, 
					files=[stlfile], 
					import_mode='clipboard', 
					length_unit='mm', 
					stl_color_bit_set=False, 
					target_type='mesh')
			if ext == '.g3d':
				g3dfile = os.path.join(filenames)
				gom.script.sys.import_g3d (
					files=[g3dfile], 
					import_mode='clipboard')
		
		counter=-1
		print (counter)
		for n in range(len(gom.app.project.clipboard.actual_elements)):
			print (n)
			counter+1
			print (counter)
			mesh=gom.app.project.clipboard.actual_elements[0].import_information.name
			print (mesh)
			gom.script.mesh.convert_mesh_to_cad_data (
				meshes=[gom.app.project.clipboard.actual_elements[0]], 
				name=mesh)
			gom.script.part.create_new_part (name=mesh)
			gom.script.part.add_elements_to_part (
				elements=[gom.app.project.clipboard.nominal_elements[0]], 
				import_mode='new_elements', 
				part=gom.app.project.parts[counter])
			gom.script.cad.show_element_exclusively (elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts[counter], 'explorer_category', 'nominal_part']}))
			#INIZIO ALLINEAMENTO MONDO
		
			gom.script.cad.show_element_exclusively (elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts[counter], 'explorer_category', 'nominal_part']}))
			Punto_Coordinata=('Punto_Coordinata_')+(mesh)
			print (Punto_Coordinata)
			MCAD_ELEMENT=gom.script.primitive.create_touch_point_disc (
				clearance=100.0, 
				name=Punto_Coordinata,
				normal={'direction': gom.Vec3d (0.0, 0.0, 1.0), 'point': gom.Vec3d (0.0, 0.0, 0.0), 'type': 'projected'}, 
				only_touch_from_outside=True, 
				point={'point': gom.Vec3d (0.0, 0.0, 500.0)}, 
				project_element=gom.app.project.parts[counter].nominal, 
				properties=gom.Binary ('eAHFmGtsW2cZx3+p2hLCui6jQKkQWGlgYasTJ02Tzm1p2qQjoIZGI82mSZtx7OPEzLfaztIMRj34wIQYAwk6bpMmsSJQUaV9mChCiItAQoC6T1wE7APiKui0wZchpDXo/5zz5hzHTpqCEIkSvz7nPc/1//yf5z0z5WJ89kD/WSZPHJs4cTcz1XS+XksmTxS8oleqT1fLFa9az3s1/J8OtrOjiy520LUD+OIDT2cWgHefmoq9v5yrL6WrXmwoMTQYmyzXc/mzsYP+c1cudrLfnr+Rn45eYO4jVy52MAS8CRoeBTyKpFikhkeKHGWqpMhTokYFjwx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vZFbT+habv7TZyXWEc+NTP56MRT9ja9+23gVfUbrc5d//e0o7DVMpVcHJQ1sglLWrupoqCIQGGpMvLypkDh0upD4LFhcjfiFMYlxFeqmOdWu/54wmA4bWPd0rBdKa2fwz57b2DQanf8GIB9WLQG6Rw=='), 
				radius=200.0)
			
			gom.script.inspection.inspect_by_referenced_construction (elements=[gom.app.project.inspection[Punto_Coordinata]])
			coordinate_system=('CS_')+(mesh)
			MCAD_ELEMENT=gom.script.cs.create_element_by_orientation (
				name=coordinate_system, 
				orientation='auto', 
				origin=gom.app.project.inspection[Punto_Coordinata], 
				properties=gom.Binary ('eAHFmFtsXFcVhj9HaTBRQ0gbII0QHTmGuknHHjt2LpOUTJOmpBC3VknTCkFHczm2h84tM+PYKYJM4IGCkKpKQBEgtRJtVMlSqjy15SJAAgmB5D4BVRAPiOtDUKEvrZCaoH/tsz1nbnECQhzL9j7n7L32Wv9a619rnxOVUvzk1OgSx47ec+/RhzhRyxQa9WTyaDEoBeXGTK1SDWqNQlDHXQNsYNNGNrKJjZuAlx57LjcPfOzB6dgnK7ONxUwtiE0kJsZjxyqN2cJSbJ9bt7I8yG5bfyPXwO1AZmVleQDJ2Q7NIhmyBBRJk6NCmTIBORpUqJGmSMGepFmkQJ4G8zyxYWV5HTHgPdA80rXqkdWZv35Le30Q2GZKD2gFN0GzTokMRYr84jNvTOqNZmzs0KhBwBINrv5LO74X2GBrG9RMrzlGXtfaKzfBO+toHmSeBiWKfBSNAzLkbVwioEGGWGilJOvv3QwxzhAxymRslp6cMvk5k+Y0GDIp2vkMRQJiNqqG8/2sMXLUqdvsKncRM/xifI4Yi8xTsJlx6lTJkCMgSYwqNXu6SI0MVQ4Q4/McZCyyn3Yfa7MoS4U8Z4hFZkmX2dA+yQsoMGdWJJkkQcJkt2a07ElSNo87rxwI7RVi2dDeLHOGXdHmaacdzEZ+hKF0qpEnCGc4ZGWnPC2b8+RDz+l9ou29R6X1Ph5KaOmpVdFd4hGdkuwgR2L1V7a2z23J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hamZ1NivUi/8eSKVuuP5hSO3/XM69d3Kzls1J+FSqQ01j1Y1bDHTRvi+wOR588fSxCded0iGrOoDrBXvnpb/+Mx1Cfg4sGNN3eo8ToGqFQY1NP4446jFH8zqnPpNdNNuKpSbUgNSvFckCeFOHP5qNNIfhzA1e/GfE1elYkztXfy7tyTQb+/T4ogZocCTgTNUQhZPPCPpR8Bq6cryBqZcsN349eK6y29I2GhIdFFKc6qKjHR0E0lVSXOaAgGLbJmXyt7VXuW1orKfhoP83kLHk7eOfAWjyhZ7/WF/rx1bediHvb76t6tbf/qlvZKu/Njc08ro4e6pd3rt899a1ounHcI68IktWxn/p/J/rsHbVx3Grf9P3vOjbbLeh1e3j+vhQcllfeWX2t0X+7wxgmOAb52QnBa7/ePQgaae9I8ez8MubhTyTtJTe7XHmhnUX7C+tuhbi1RWXVZXqnR/5cvXJdhXIE9R7mOHEjNr7NHOe+dHrkuo74f7CXWnAtFTweD+y9cl1qfQjfST+lIR/Ymv3l17FF2j8dlXLv1ADtQXqJsjmru0K60C80JKmvqQ8GVdweK+L4VtQhOjUR/qHgdRh0qppMrunHmswBMEZJevDW1YUnyT2hKZt25DBygvarsdSrySveP2zuGlZ188P5Ta9eq/AVf576sBnes='))
			
			gom.script.inspection.inspect_by_referenced_construction (elements=[gom.app.project.inspection[coordinate_system]])
			
			CAD_ALIGNMENT=gom.script.transform_element.by_csys (
				actual_coordinate_system=gom.app.project.inspection[coordinate_system], 
				elements=gom.ElementSelection ({'category': ['key', 'elements', 'part', gom.app.project.parts[counter], 'explorer_category', 'nominal_part']}), 
				invert_transformation=False, 
				target_coordinate_system=gom.app.project.nominal_elements['system_global_coordinate_system'])
		
			gom.script.cad.delete_element (
				elements=[gom.app.project.inspection[Punto_Coordinata], gom.app.project.inspection[coordinate_system]], 
				with_measuring_principle=True)
			
		# FINE ALLINEAMENTO MONDO
	
		#Importare file nuovi con finestra di dialogo
				
		for filename in dir:
			print(filename)
			base, ext = os.path.splitext(filename)
			if ext == '.stl':
				stlfile = os.path.join(filename)
				gom.script.sys.import_stl (
					bgr_coding=True, 
					files=[stlfile], 
					import_mode='clipboard', 
					length_unit='mm', 
					stl_color_bit_set=False, 
					target_type='mesh')
			if ext == '.g3d':
				g3dfile = os.path.join(filename)
				gom.script.sys.import_g3d (
					files=[g3dfile], 
					import_mode='clipboard')
		
		for n in range(len(gom.app.project.clipboard.actual_elements)):
			print (n)
			mesh=gom.app.project.clipboard.actual_elements[0].import_information.name
			print (mesh)
			gom.script.part.add_elements_to_part (
				elements=[gom.app.project.clipboard.actual_elements[0]], 
				import_mode='add_to_part', 
				part=gom.app.project.parts[n])
		
		for n in range(len(gom.app.project.parts)):
			part=(gom.app.project.parts[n].name)
			for causale in causali:
				if causale in part:
					print("Trovato:", causale)
					ref=part.split(causale)[0]+causale
					print (ref)
					break
			for causale in causali:
				control_name=(gom.app.project.parts[n].actual.import_information.name)
				if causale in control_name:
					print("Trovato:", causale)
					control=control_name.split(causale)[0]+causale
					print (control)
					break
			for causale in causali:
				if causale in control_name:
					print("Trovato:", causale)
					figura=control_name.split(causale)[1]
					print (control)
					break
			if NormalOrLong==3:
				tempo='normal'
			if NormalOrLong==1:
				tempo='enhanced'
			if NormalOrLong==2:
				tempo='advanced'
			CAD_ALIGNMENT=gom.script.alignment.create_prealignment (
				computation_mode=tempo, 
				compute_additional_bestfit=True, 
				name_expression=control+"_su_"+ref+figura, 
				parent_alignment=gom.app.project.parts[n].original_alignment, 
				part=gom.app.project.parts[n])
			
			gom.script.cad.show_element (elements=[gom.app.project.parts[n].nominal])
			
			gom.script.selection3d.select_all_points_of_element (elements=[gom.app.project.parts[n].nominal])
			
			MCAD_ELEMENT=gom.script.comparison.create_multiple_surface_comparison_on_cad (
				compute_maximum_deviation=False, 
				copy_selected_patches_only=False, 
				deviation_calculation_type='shortest_distance', 
				max_angle_between_normals=1.047197551, 
				max_opening_angle=0.5235987756, 
				name=('Surface_Comparison_')+str(n), 
				properties=gom.Binary ('eAHFmG2MVGcVx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qf6I6tjVH7arHH01rrRdN2iFJEW4OQ6vG9PNGYdWLcCJE/AFeJ/iv70jgV69r9zd5oSAJwcPTM8YvU8pSLvB5qOLZ5aw0VXEwj+/XHTlLQmbWZvqGkqbe5XhKGzyTZnp0xuZ6Z/PRnFTU9z3u1ulR69hxPnxWnUhES/r2C++LpPmGHkCJlg52krnXOifLRJL+XsDF820I350f/L9D0N3q6biYqBuLWqPav9fxQ9uwbsnXBSi/090/LhhlJ3pfTU8Brv6L/1R2ufDxf/ZsbXePr+ekV1mBX7HKk/eIx1z1pLvau0GGwFHZFDhV4W5DQ8Hmx0DNtjMDky9q9ObOoVEbUrDrYjluW/My/CZlRUdG4aNbzXZHLy3vbCQGD1DRC00Eqa3gDq6yNYT2+clbqZtUZaiqs/dIWELrfr9p05N3dD33nUy2yfPNwQFUJVeJmtc3dhlTq9tb3x4HvMnytmEunO10JA3SF/+ftyNhRyh9K4v/pOcvmt/Fd+j6xPPXXpRlrebqTztbrkyryB4LmkFCA2qbvLR67hJtj7TXmSIMZ+sSGSzoHhL+I69TV4oOOJTr9dXpjrLsB7Xt+byB9F37ty5qes+96eb5J9//+9x46SPTcPyFzulwZOen7JFh+79eDi11+nQ3YB7Hz9PXtKbfyWjyJp/xLW0G3MlX5r86aA9A2pkjbRoDArQ4bhAV04a5yTa+TgUnSAjVXd9d94O0cn/AIIhHNIBdSc='), 
				search_distance=1.0, 
				tolerance=0.1)
			
			gom.script.selection3d.deselect_all ()
			
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			
			gom.script.view.show_legend (enable=True)
			gom.script.legend.set_mode_to_legend ()
			gom.script.legend.edit_legend_properties (
				legend_template='Legenda_VN', 
				uuid='e9ac15df-e23b-4edf-98c1-0c31b208d6ed')
		
		zoom_level=-90
		gom.script.view.show_grid (enable=False)
		a=-1
		#INIZIO VISTE 3D
		for n in range(len(gom.app.project.parts)):
			controllo=gom.app.project.parts[n].actual.name
			riferimento=gom.app.project.parts[n].nominal.name
			print (controllo)
			print (riferimento)
			
			gom.script.sys.set_project_keywords (
				keywords={'Controllo': controllo, 'Riferimento': riferimento}, 
				keywords_description={'Controllo': 'Controllo Parte', 'Riferimento': 'Riferimento Parte'})
		
			a+=1
			print (a)
			if a==0:
				report=str("report")
			else:
				report=str("report "+str(a))
			print (report)
			b=a+1
			report2=str("report "+str(b))#per immagine2
			
			snapshot1=str("snapshot_frame_"+str(6))
			print (snapshot1)
			
			snapshot2=str("snapshot_frame_"+str(7))
			print (snapshot2)
			
			snapshot3=str("snapshot_frame_"+str(8))	
			print (snapshot3)
			
			snapshot4=str("snapshot_frame_"+str(9))	
			print (snapshot4)
			
			snapshot5=str("snapshot_frame_"+str(10))	
			print (snapshot5)
			
			snapshot6=str("snapshot_frame_"+str(11))	
			print (snapshot6)
			
			snapshot7=str("snapshot_frame_"+str(12))	
			print (snapshot7)	
			
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			gom.script.sys.recalculate_project (with_reports=False)
			
			#Immagine 1 Z+
			gom.script.view.set_view_direction_and_up_direction (
				rotation_center=gom.Vec3d (44.3655706, 31.53865025, 31.06736641), 
				use_animation=False, 
				view_direction=gom.Vec3d (0.0, 0.0, 1.0), 
				widget='3d_view')
				
			def zoom(percent,**kwargs):
				"""
				param1:
					Use:Required
					Type:float or int
					e.g. 10 or 2.5
				Kwarg1:
					Use:Required
					Type:String
					Key:dir
					Value(s):in or out
					e.g. \'in\' or \'out\'
				Kwarg2:
					Use:Optional
					Type:bool
					Key:adapt
					Value(s):True or False
					Default: False
				Example Usage(s):
					
					Zoom out 10% after applying adaptive zoom
					zoom(10,dir=\'out\',adapt=True)
					
					Zoom in 15.5%, no adaptive zoom applied
					zoom(15.5,dir=\'in\')
					
				"""
				
				if len(kwargs.keys()) == 2:
					adapt = kwargs['adapt']
				else:
					adapt = False
				
				if kwargs['dir'] == 'out':
					scale_factor = 1 + (percent/100)
				elif kwargs['dir'] == 'in':
					scale_factor = 1 - (percent/100)
				else:
					print("You did not specifiy a zoom direction")
					return
				
				# adapt zoom
				if adapt == True:
					gom.script.view.adapt_zoom (use_animation=False)
				
				# get the actual view
				pos = [gom.app.get( 'views.active.position.' + i ) for i in ( 'x', 'y', 'z' )]
				scale = gom.app.get ( 'views.active.scale' )
				up = [gom.app.get( 'views.active.up_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				view = [gom.app.get( 'views.active.view_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				
				# zoom out a little bit
				scale = scale_factor * scale
				
				# write the new view back
				gom.script.view.set_view_cartesian ( 
					camera_position = gom.Vec3d ( pos[0], pos[1], pos[2] ), 
					scale = scale, 
					up_direction = gom.Vec3d ( up[0], up[1], up[2] ), 
					use_animation = True, 
					view_direction = gom.Vec3d ( view[0], view[1], view[2] ))
			
			if __name__ == '__main__':
				
				#example zoom in 60 percent with adaptive zoom
				zoom(zoom_level,dir='in',adapt = True)
			
			gom.script.view.show_legend (enable=False)
			
			gom.script.report.create_report_page (
				animated_page=False, 
				animation=[snapshot1, 'Along line "", 10.0s'], 
				imitate_fit_mode='overwrite', 
				master_name='Report Bitron_a4', 
				template_name='Report Riavvio Pressa', 
				template_orientation='landscape', 
				template_package={'name': 'Bitron', 'uuid': '11a448bd-b5a9-4f56-acfe-5d55966554dc', 'version': '1.0.170'}, 
				title='$format (page_number, "", show_unit=false, date_format=\'dd/MM/yyyy\')$ - $format (number_of_pages, "", show_unit=false, date_format=\'dd/MM/yyyy\')$')
			
			#Immagine 2 Y+
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			
			gom.script.view.set_view_direction_and_up_direction (
				rotation_center=gom.Vec3d (-49.24919891, 5.257396698, -137.2389908), 
				use_animation=False, 
				view_direction=gom.Vec3d (0.0, 1.0, 0.0), 
				widget='3d_view')
			
			#gom.script.view.adapt_zoom (use_animation=False)
			
			def zoom(percent,**kwargs):
				"""
				param1:
					Use:Required
					Type:float or int
					e.g. 10 or 2.5
				Kwarg1:
					Use:Required
					Type:String
					Key:dir
					Value(s):in or out
					e.g. \'in\' or \'out\'
				Kwarg2:
					Use:Optional
					Type:bool
					Key:adapt
					Value(s):True or False
					Default: False
				Example Usage(s):
					
					Zoom out 10% after applying adaptive zoom
					zoom(10,dir=\'out\',adapt=True)
					
					Zoom in 15.5%, no adaptive zoom applied
					zoom(15.5,dir=\'in\')
					
				"""
				
				if len(kwargs.keys()) == 2:
					adapt = kwargs['adapt']
				else:
					adapt = False
				
				if kwargs['dir'] == 'out':
					scale_factor = 1 + (percent/100)
				elif kwargs['dir'] == 'in':
					scale_factor = 1 - (percent/100)
				else:
					print("You did not specifiy a zoom direction")
					return
				
				# adapt zoom
				if adapt == True:
					gom.script.view.adapt_zoom (use_animation=False)
				
				# get the actual view
				pos = [gom.app.get( 'views.active.position.' + i ) for i in ( 'x', 'y', 'z' )]
				scale = gom.app.get ( 'views.active.scale' )
				up = [gom.app.get( 'views.active.up_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				view = [gom.app.get( 'views.active.view_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				
				# zoom out a little bit
				scale = scale_factor * scale
				
				# write the new view back
				gom.script.view.set_view_cartesian ( 
					camera_position = gom.Vec3d ( pos[0], pos[1], pos[2] ), 
					scale = scale, 
					up_direction = gom.Vec3d ( up[0], up[1], up[2] ), 
					use_animation = True, 
					view_direction = gom.Vec3d ( view[0], view[1], view[2] ))
			
			if __name__ == '__main__':
				
				#example zoom in 60 percent with adaptive zoom
				zoom(zoom_level,dir='in',adapt = True)
			
			gom.script.view.show_legend (enable=False)
			gom.script.report.create_report_page (
				animated_page=False, 
				animation=['snapshot_frame_6', 'Along line "", 10.0s'], 
				imitate_fit_mode='overwrite', 
				master_name='Report Bitron_a4', 
				template_name='Report Riavvio Pressa', 
				template_orientation='landscape', 
				template_package={'name': 'Bitron', 'uuid': '11a448bd-b5a9-4f56-acfe-5d55966554dc', 'version': '1.0.171'}, 
				title='$format (page_number, "", show_unit=false, date_format=\'dd/MM/yyyy\')$ - $format (number_of_pages, "", show_unit=false, date_format=\'dd/MM/yyyy\')$')
			
			
			gom.script.sys.cut_to_clipboard (elements=[gom.app.project.reports[report2].pages['page 1'].elements['snapshot_frame_6']])
			
			gom.script.sys.paste_from_clipboard (destination=[gom.app.project.reports[report].pages['page 1'].elements['rectangle_3']])
			
			gom.script.report.edit_properties (
				data=[gom.app.project.reports[report].pages['page 1'].elements[snapshot2]], 
				origin=gom.Vec2d (140.2476049, 48.28346194))
			
			gom.script.report.update_report_page (
				pages=[gom.app.project.reports[report]], 
				used_alignments='report', 
				used_digits='report', 
				used_legends='report', 
				used_stages='report', 
				used_units='report')
			
			gom.script.cad.delete_element (
				elements=[gom.app.project.reports[report2]], 
				with_measuring_principle=True)
			
			#Immagine 3 X+
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			
			gom.script.view.set_view_direction_and_up_direction (
				rotation_center=gom.Vec3d (-49.24919891, 5.257396698, -137.2389908), 
				use_animation=False, 
				view_direction=gom.Vec3d (1.0, 0.0, 0.0), 
				widget='3d_view')
			
			#gom.script.view.adapt_zoom (use_animation=False)
			
			def zoom(percent,**kwargs):
				"""
				param1:
					Use:Required
					Type:float or int
					e.g. 10 or 2.5
				Kwarg1:
					Use:Required
					Type:String
					Key:dir
					Value(s):in or out
					e.g. \'in\' or \'out\'
				Kwarg2:
					Use:Optional
					Type:bool
					Key:adapt
					Value(s):True or False
					Default: False
				Example Usage(s):
					
					Zoom out 10% after applying adaptive zoom
					zoom(10,dir=\'out\',adapt=True)
					
					Zoom in 15.5%, no adaptive zoom applied
					zoom(15.5,dir=\'in\')
					
				"""
				
				if len(kwargs.keys()) == 2:
					adapt = kwargs['adapt']
				else:
					adapt = False
				
				if kwargs['dir'] == 'out':
					scale_factor = 1 + (percent/100)
				elif kwargs['dir'] == 'in':
					scale_factor = 1 - (percent/100)
				else:
					print("You did not specifiy a zoom direction")
					return
				
				# adapt zoom
				if adapt == True:
					gom.script.view.adapt_zoom (use_animation=False)
				
				# get the actual view
				pos = [gom.app.get( 'views.active.position.' + i ) for i in ( 'x', 'y', 'z' )]
				scale = gom.app.get ( 'views.active.scale' )
				up = [gom.app.get( 'views.active.up_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				view = [gom.app.get( 'views.active.view_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				
				# zoom out a little bit
				scale = scale_factor * scale
				
				# write the new view back
				gom.script.view.set_view_cartesian ( 
					camera_position = gom.Vec3d ( pos[0], pos[1], pos[2] ), 
					scale = scale, 
					up_direction = gom.Vec3d ( up[0], up[1], up[2] ), 
					use_animation = True, 
					view_direction = gom.Vec3d ( view[0], view[1], view[2] ))
			
			if __name__ == '__main__':
				
				#example zoom in 60 percent with adaptive zoom
				zoom(zoom_level,dir='in',adapt = True)
			gom.script.view.show_legend (enable=False)
			gom.script.report.create_report_page (
				animated_page=False, 
				animation=['snapshot_frame_6', 'Along line "", 10.0s'], 
				imitate_fit_mode='overwrite', 
				master_name='Report Bitron_a4', 
				template_name='Report Riavvio Pressa', 
				template_orientation='landscape', 
				template_package={'name': 'Bitron', 'uuid': '11a448bd-b5a9-4f56-acfe-5d55966554dc', 'version': '1.0.171'}, 
				title='$format (page_number, "", show_unit=false, date_format=\'dd/MM/yyyy\')$ - $format (number_of_pages, "", show_unit=false, date_format=\'dd/MM/yyyy\')$')
			
			
			gom.script.sys.cut_to_clipboard (elements=[gom.app.project.reports[report2].pages['page 1'].elements['snapshot_frame_6']])
			
			gom.script.sys.paste_from_clipboard (destination=[gom.app.project.reports[report].pages['page 1'].elements['rectangle_3']])
			
			gom.script.report.edit_properties (
				data=[gom.app.project.reports[report].pages['page 1'].elements[snapshot3]], 
				origin=gom.Vec2d (232.9476049, 47.95733585))
			
			gom.script.report.update_report_page (
				pages=[gom.app.project.reports[report]], 
				used_alignments='report', 
				used_digits='report', 
				used_legends='report', 
				used_stages='report', 
				used_units='report')
			
			gom.script.cad.delete_element (
				elements=[gom.app.project.reports[report2]], 
				with_measuring_principle=True)
			
			#Immagine 4 Z-
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			
			gom.script.view.set_view_direction_and_up_direction (
				rotation_center=gom.Vec3d (-49.24919891, 5.257396698, -137.2389908), 
				use_animation=False, 
				view_direction=gom.Vec3d (0.0, 0.0, -1.0), 
				widget='3d_view')
			
			#gom.script.view.adapt_zoom (use_animation=False)
			
			def zoom(percent,**kwargs):
				"""
				param1:
					Use:Required
					Type:float or int
					e.g. 10 or 2.5
				Kwarg1:
					Use:Required
					Type:String
					Key:dir
					Value(s):in or out
					e.g. \'in\' or \'out\'
				Kwarg2:
					Use:Optional
					Type:bool
					Key:adapt
					Value(s):True or False
					Default: False
				Example Usage(s):
					
					Zoom out 10% after applying adaptive zoom
					zoom(10,dir=\'out\',adapt=True)
					
					Zoom in 15.5%, no adaptive zoom applied
					zoom(15.5,dir=\'in\')
					
				"""
				
				if len(kwargs.keys()) == 2:
					adapt = kwargs['adapt']
				else:
					adapt = False
				
				if kwargs['dir'] == 'out':
					scale_factor = 1 + (percent/100)
				elif kwargs['dir'] == 'in':
					scale_factor = 1 - (percent/100)
				else:
					print("You did not specifiy a zoom direction")
					return
				
				# adapt zoom
				if adapt == True:
					gom.script.view.adapt_zoom (use_animation=False)
				
				# get the actual view
				pos = [gom.app.get( 'views.active.position.' + i ) for i in ( 'x', 'y', 'z' )]
				scale = gom.app.get ( 'views.active.scale' )
				up = [gom.app.get( 'views.active.up_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				view = [gom.app.get( 'views.active.view_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				
				# zoom out a little bit
				scale = scale_factor * scale
				
				# write the new view back
				gom.script.view.set_view_cartesian ( 
					camera_position = gom.Vec3d ( pos[0], pos[1], pos[2] ), 
					scale = scale, 
					up_direction = gom.Vec3d ( up[0], up[1], up[2] ), 
					use_animation = True, 
					view_direction = gom.Vec3d ( view[0], view[1], view[2] ))
			
			if __name__ == '__main__':
				
				#example zoom in 60 percent with adaptive zoom
				zoom(zoom_level,dir='in',adapt = True)
			gom.script.view.show_legend (enable=False)
			gom.script.report.create_report_page (
				animated_page=False, 
				animation=['snapshot_frame_6', 'Along line "", 10.0s'], 
				imitate_fit_mode='overwrite', 
				master_name='Report Bitron_a4', 
				template_name='Report Riavvio Pressa', 
				template_orientation='landscape', 
				template_package={'name': 'Bitron', 'uuid': '11a448bd-b5a9-4f56-acfe-5d55966554dc', 'version': '1.0.171'}, 
				title='$format (page_number, "", show_unit=false, date_format=\'dd/MM/yyyy\')$ - $format (number_of_pages, "", show_unit=false, date_format=\'dd/MM/yyyy\')$')
			
			
			gom.script.sys.cut_to_clipboard (elements=[gom.app.project.reports[report2].pages['page 1'].elements['snapshot_frame_6']])
			
			gom.script.sys.paste_from_clipboard (destination=[gom.app.project.reports[report].pages['page 1'].elements['rectangle_3']])
			
			gom.script.report.edit_properties (
				data=[gom.app.project.reports[report].pages['page 1'].elements[snapshot4]], 
				origin=gom.Vec2d (47.54760486, 127.6845664))
			
			gom.script.report.update_report_page (
				pages=[gom.app.project.reports[report]], 
				used_alignments='report', 
				used_digits='report', 
				used_legends='report', 
				used_stages='report', 
				used_units='report')
			
			gom.script.cad.delete_element (
				elements=[gom.app.project.reports[report2]], 
				with_measuring_principle=True)
			
			#Immagine 5 Y-
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			
			gom.script.view.set_view_direction_and_up_direction (
				rotation_center=gom.Vec3d (-49.24919891, 5.257396698, -137.2389908), 
				use_animation=False, 
				view_direction=gom.Vec3d (0.0, -1.0, 0.0), 
				widget='3d_view')
			
			#gom.script.view.adapt_zoom (use_animation=False)
			
			def zoom(percent,**kwargs):
				"""
				param1:
					Use:Required
					Type:float or int
					e.g. 10 or 2.5
				Kwarg1:
					Use:Required
					Type:String
					Key:dir
					Value(s):in or out
					e.g. \'in\' or \'out\'
				Kwarg2:
					Use:Optional
					Type:bool
					Key:adapt
					Value(s):True or False
					Default: False
				Example Usage(s):
					
					Zoom out 10% after applying adaptive zoom
					zoom(10,dir=\'out\',adapt=True)
					
					Zoom in 15.5%, no adaptive zoom applied
					zoom(15.5,dir=\'in\')
					
				"""
				
				if len(kwargs.keys()) == 2:
					adapt = kwargs['adapt']
				else:
					adapt = False
				
				if kwargs['dir'] == 'out':
					scale_factor = 1 + (percent/100)
				elif kwargs['dir'] == 'in':
					scale_factor = 1 - (percent/100)
				else:
					print("You did not specifiy a zoom direction")
					return
				
				# adapt zoom
				if adapt == True:
					gom.script.view.adapt_zoom (use_animation=False)
				
				# get the actual view
				pos = [gom.app.get( 'views.active.position.' + i ) for i in ( 'x', 'y', 'z' )]
				scale = gom.app.get ( 'views.active.scale' )
				up = [gom.app.get( 'views.active.up_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				view = [gom.app.get( 'views.active.view_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				
				# zoom out a little bit
				scale = scale_factor * scale
				
				# write the new view back
				gom.script.view.set_view_cartesian ( 
					camera_position = gom.Vec3d ( pos[0], pos[1], pos[2] ), 
					scale = scale, 
					up_direction = gom.Vec3d ( up[0], up[1], up[2] ), 
					use_animation = True, 
					view_direction = gom.Vec3d ( view[0], view[1], view[2] ))
			
			if __name__ == '__main__':
				
				#example zoom in 60 percent with adaptive zoom
				zoom(zoom_level,dir='in',adapt = True)
			gom.script.view.show_legend (enable=False)
			gom.script.report.create_report_page (
				animated_page=False, 
				animation=['snapshot_frame_6', 'Along line "", 10.0s'], 
				imitate_fit_mode='overwrite', 
				master_name='Report Bitron_a4', 
				template_name='Report Riavvio Pressa', 
				template_orientation='landscape', 
				template_package={'name': 'Bitron', 'uuid': '11a448bd-b5a9-4f56-acfe-5d55966554dc', 'version': '1.0.171'}, 
				title='$format (page_number, "", show_unit=false, date_format=\'dd/MM/yyyy\')$ - $format (number_of_pages, "", show_unit=false, date_format=\'dd/MM/yyyy\')$')
			
			
			gom.script.sys.cut_to_clipboard (elements=[gom.app.project.reports[report2].pages['page 1'].elements['snapshot_frame_6']])
			
			gom.script.sys.paste_from_clipboard (destination=[gom.app.project.reports[report].pages['page 1'].elements['rectangle_3']])
			
			gom.script.report.edit_properties (
				data=[gom.app.project.reports[report].pages['page 1'].elements[snapshot5]], 
				origin=gom.Vec2d (140.2476049, 127.6845664))
			
			gom.script.report.update_report_page (
				pages=[gom.app.project.reports[report]], 
				used_alignments='report', 
				used_digits='report', 
				used_legends='report', 
				used_stages='report', 
				used_units='report')
			
			gom.script.cad.delete_element (
				elements=[gom.app.project.reports[report2]], 
				with_measuring_principle=True)
			
			#Immagine 6 Z-
			gom.script.cad.show_element_exclusively (elements=[gom.app.project.inspection[n]])
			
			gom.script.view.set_view_direction_and_up_direction (
				rotation_center=gom.Vec3d (-49.24919891, 5.257396698, -137.2389908), 
				use_animation=False, 
				view_direction=gom.Vec3d (-1.0, 0.0, 0.0), 
				widget='3d_view')
			
			#gom.script.view.adapt_zoom (use_animation=False)
			
			def zoom(percent,**kwargs):
				"""
				param1:
					Use:Required
					Type:float or int
					e.g. 10 or 2.5
				Kwarg1:
					Use:Required
					Type:String
					Key:dir
					Value(s):in or out
					e.g. \'in\' or \'out\'
				Kwarg2:
					Use:Optional
					Type:bool
					Key:adapt
					Value(s):True or False
					Default: False
				Example Usage(s):
					
					Zoom out 10% after applying adaptive zoom
					zoom(10,dir=\'out\',adapt=True)
					
					Zoom in 15.5%, no adaptive zoom applied
					zoom(15.5,dir=\'in\')
					
				"""
				
				if len(kwargs.keys()) == 2:
					adapt = kwargs['adapt']
				else:
					adapt = False
				
				if kwargs['dir'] == 'out':
					scale_factor = 1 + (percent/100)
				elif kwargs['dir'] == 'in':
					scale_factor = 1 - (percent/100)
				else:
					print("You did not specifiy a zoom direction")
					return
				
				# adapt zoom
				if adapt == True:
					gom.script.view.adapt_zoom (use_animation=False)
				
				# get the actual view
				pos = [gom.app.get( 'views.active.position.' + i ) for i in ( 'x', 'y', 'z' )]
				scale = gom.app.get ( 'views.active.scale' )
				up = [gom.app.get( 'views.active.up_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				view = [gom.app.get( 'views.active.view_direction.' + i ) for i in ( 'x', 'y', 'z' )]
				
				# zoom out a little bit
				scale = scale_factor * scale
				
				# write the new view back
				gom.script.view.set_view_cartesian ( 
					camera_position = gom.Vec3d ( pos[0], pos[1], pos[2] ), 
					scale = scale, 
					up_direction = gom.Vec3d ( up[0], up[1], up[2] ), 
					use_animation = True, 
					view_direction = gom.Vec3d ( view[0], view[1], view[2] ))
			
			if __name__ == '__main__':
				
				#example zoom in 60 percent with adaptive zoom
				zoom(zoom_level,dir='in',adapt = True)
			gom.script.view.show_legend (enable=False)
			gom.script.report.create_report_page (
				animated_page=False, 
				animation=['snapshot_frame_6', 'Along line "", 10.0s'], 
				imitate_fit_mode='overwrite', 
				master_name='Report Bitron_a4', 
				template_name='Report Riavvio Pressa', 
				template_orientation='landscape', 
				template_package={'name': 'Bitron', 'uuid': '11a448bd-b5a9-4f56-acfe-5d55966554dc', 'version': '1.0.171'}, 
				title='$format (page_number, "", show_unit=false, date_format=\'dd/MM/yyyy\')$ - $format (number_of_pages, "", show_unit=false, date_format=\'dd/MM/yyyy\')$')
			
			
			gom.script.sys.cut_to_clipboard (elements=[gom.app.project.reports[report2].pages['page 1'].elements['snapshot_frame_6']])
			
			gom.script.sys.paste_from_clipboard (destination=[gom.app.project.reports[report].pages['page 1'].elements['rectangle_3']])
			
			gom.script.report.edit_properties (
				data=[gom.app.project.reports[report].pages['page 1'].elements[snapshot6]], 
				origin=gom.Vec2d (232.9476049, 127.3584403))
			
			gom.script.report.update_report_page (
				pages=[gom.app.project.reports[report]], 
				used_alignments='report', 
				used_digits='report', 
				used_legends='report', 
				used_stages='report', 
				used_units='report')
			
			gom.script.cad.delete_element (
				elements=[gom.app.project.reports[report2]], 
				with_measuring_principle=True)
		
		for causale in causali:
			if causale in riferimento:
				print("Trovato:", causale)
				riferimento_project_name=riferimento.split(causale)[0]+causale
				print (riferimento_project_name)
				break
		
		for causale in causali:
			if causale in controllo:
				print("Trovato:", causale)
				controllo_project_name=controllo.split(causale)[0]+causale
				print (controllo_project_name)
				break
		
		project_name=controllo_project_name+"_su_"+riferimento_project_name+".ginspect"
		print (project_name)
		
		filepath=gom.app.project.parts[0].actual.import_information.file
		
		# Otteniamo il percorso completo della cartella contenente il file
		dir_path = os.path.dirname(filepath)
		
		# Naviga indietro di un livello per arrivare alla cartella contenente la data
		parent_dir = os.path.abspath(os.path.join(dir_path, os.pardir))
		
		# Aggiungiamo la sotto-cartella "Analisi" al percorso della cartella contenente la data
		project_dir = os.path.join(parent_dir, "Analisi\\Vecchio_Nuovo")
		if reparto==2 or reparto==3:
			project_dir = os.path.join(parent_dir, "WRP\\Vecchio_Nuovo")
		
		# Stampiamo il percorso completo della cartella "Analisi"
		print(project_dir)
		
		if not os.path.exists(project_dir):
			os.makedirs(project_dir)
		
		project_save=os.path.join(project_dir, project_name)
		print (project_save)
		
		gom.script.sys.save_project_as (
			file_name=project_save, 
			open_in_presentation_mode=False)
			
		pdf_name = os.path.splitext(project_name)[0] + ".pdf"
		print (pdf_name)
		# Aggiungiamo la sotto-cartella "Report" al percorso della cartella contenente la data
		pdf_dir = os.path.join(os.path.dirname(parent_dir), "00_Report\\Vecchio_Nuovo")
		if reparto==2 or reparto==3:
			pdf_dir = os.path.join(project_dir)#, "\\Vecchio_Nuovo")
		
		if not os.path.exists(pdf_dir):
			os.makedirs(pdf_dir)
		
		pdf_save=os.path.join(pdf_dir, pdf_name)
		print (pdf_save)
		
# Verifica se il file PDF è aperto da un altro utente
		while True:
			try:
				if not os.path.isfile(pdf_save):
					# Il file non esiste, esegui l'esportazione del PDF
					gom.script.report.export_pdf(
						export_all_reports=True,
						file=pdf_save,
						jpeg_quality_in_percent=90,
						max_dpi=150
					)
					print("Il file PDF è stato creato con successo!")
					break
		
				# Il file esiste, verifica se è aperto da un altro utente
				try:
					os.rename(pdf_save, pdf_save)
				except PermissionError:
					# Il file è aperto da un altro utente
					print("Il file PDF è aperto da un altro utente.")
					DIALOG=gom.script.sys.create_user_defined_dialog (content='<dialog>' \
					' <title>Message</title>' \
					' <style></style>' \
					' <control id="OkCancel"/>' \
					' <position>automatic</position>' \
					' <embedding>always_toplevel</embedding>' \
					' <sizemode>automatic</sizemode>' \
					' <size height="172" width="367"/>' \
					' <content rows="1" columns="1">' \
					'  <widget columnspan="1" row="0" type="display::text" column="0" rowspan="1">' \
					'   <name>text</name>' \
					'   <tooltip></tooltip>' \
					'   <text>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">' \
					'&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">' \
					'p, li { white-space: pre-wrap; }' \
					'&lt;/style>&lt;/head>&lt;body style="    ">' \
					'&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:16pt;">Il PDF è aperto da un altro utente.&lt;/span>&lt;/p>' \
					'&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:16pt;">Chiudilo e premi OK.&lt;/span>&lt;/p>&lt;/body>&lt;/html></text>' \
					'   <wordwrap>false</wordwrap>' \
					'  </widget>' \
					' </content>' \
					'</dialog>')
					
					#
					# Event handler function called if anything happens inside of the dialog
					#
					def dialog_event_handler (widget):
						pass
					
					DIALOG.handler = dialog_event_handler
					
					RESULT=gom.script.sys.show_user_defined_dialog (dialog=DIALOG)
					
					#input("Chiudi il PDF e premi INVIO per continuare...")
					continue
		
				# Sovrascrivi il file PDF
				gom.script.report.export_pdf(
					export_all_reports=True,
					file=pdf_save,
					jpeg_quality_in_percent=90,
					max_dpi=150
				)
				print("Il file PDF è stato creato con successo!")
				break
		
			except Exception as e:
				print("Si è verificato un errore durante l'esportazione del file PDF:", str(e))
		if reparto!=2 and reparto!=3:
			report_quarep_dir="F:\\Controlli_"+reparto_minuscolo+"\\Controlli"
			codice=(gom.app.project.project_name).split("_")[0]
			print (codice)
			target_dir = os.path.join(report_quarep_dir, codice)
			print (target_dir)
			if not os.path.exists(target_dir):
				os.makedirs(target_dir)
			
			shutil.copy2(pdf_save, target_dir)
		
		os.startfile(pdf_save)

 

Link to comment
Share on other sites

  • 5 weeks later...
 Share

×
×
  • Create New...