|
[Sponsors] |
August 23, 2018, 10:29 |
Scripting with trace: cameraview
|
#1 |
New Member
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
Dear all,
I'm writing a script to automate some tasks when post-processing with ParaView 5.0.0. I use Tools > Start Trace to convert the mouse movements to Python code. However, the tracing does not work / does not generate code when loading a cameraview (.pvcc file) and I don't seem to be the only one who has had this problem. Has anyone have found a workaround solution or found the code equivalent? |
|
October 23, 2018, 04:50 |
|
#2 |
New Member
Join Date: Jul 2014
Posts: 13
Rep Power: 12 |
I forgot to post the solution that I came up with some time ago:
Code:
# Read pvcc file A = [] with open(top_path + '/' + pvccfile) as fileobject: A = fileobject.read() B = ''.join(A) C = B.replace('\n','') # CameraPosition match_pos = re.findall('<Property name="CameraPosition"(.*)<Property name="CameraFocalPoint"',C) xpos = re.findall('<Element index="0" value="(.*)"/>(.*)<Element index="1"',match_pos[0]) ypos = re.findall('<Element index="1" value="(.*)"/>(.*)<Element index="2"',match_pos[0]) zpos = re.findall('<Element index="2" value="(.*)"/>',match_pos[0]) xpos = float(xpos[0][0]) ypos = float(ypos[0][0]) zpos = float(zpos[0]) # CameraFocalPoint match_foc = re.findall('<Property name="CameraFocalPoint"(.*)<Property name="CameraViewUp"',C) xfoc = re.findall('<Element index="0" value="(.*)"/>(.*)<Element index="1"',match_foc[0]) yfoc = re.findall('<Element index="1" value="(.*)"/>(.*)<Element index="2"',match_foc[0]) zfoc = re.findall('<Element index="2" value="(.*)"/>',match_foc[0]) xfoc = float(xfoc[0][0]) yfoc = float(yfoc[0][0]) zfoc = float(zfoc[0]) # CameraViewUp match_up = re.findall('<Property name="CameraViewUp"(.*)<Property name="CenterOfRotation"',C) xup = re.findall('<Element index="0" value="(.*)"/>(.*)<Element index="1"',match_up[0]) yup = re.findall('<Element index="1" value="(.*)"/>(.*)<Element index="2"',match_up[0]) zup = re.findall('<Element index="2" value="(.*)"/>',match_up[0]) xup = float(xup[0][0]) yup = float(yup[0][0]) zup = float(zup[0]) # CenterOfRotation match_rot = re.findall('<Property name="CenterOfRotation"(.*)<Property name="RotationFactor"',C) xrot = re.findall('<Element index="0" value="(.*)"/>(.*)<Element index="1"',match_rot[0]) yrot = re.findall('<Element index="1" value="(.*)"/>(.*)<Element index="2"',match_rot[0]) zrot = re.findall('<Element index="2" value="(.*)"/>',match_rot[0]) xrot = float(xrot[0][0]) yrot = float(yrot[0][0]) zrot = float(zrot[0]) # RotationFactor match_fac = re.findall('<Property name="RotationFactor"(.*)<Property name="CameraViewAngle"',C) rotation_factor = re.findall('<Element index="0" value="(.*)"/>',match_fac[0]) rotation_factor = float(rotation_factor[0]) # CameraViewAngle match_ang = re.findall('<Property name="CameraViewAngle"(.*)<Property name="CameraParallelScale"',C) camera_ang = re.findall('<Element index="0" value="(.*)"/>',match_ang[0]) camera_ang = float(camera_ang[0]) # CameraParallelScale match_sca = re.findall('<Property name="CameraParallelScale"(.*)<Property name="CameraParallelProjection"',C) camera_sca = re.findall('<Element index="0" value="(.*)"/>',match_sca[0]) camera_sca = float(camera_sca[0]) # CameraParallelProjection match_prj = re.findall('<Property name="CameraParallelProjection"(.*)<Domain',C) camera_proj = re.findall('<Element index="0" value="(.*)"/>',match_prj[0]) camera_proj = int(camera_proj[0]) renderView1.CameraViewUp = [xup, yup, zup] renderView1.CameraPosition = [xpos, ypos, zpos] renderView1.CenterOfRotation = [xrot, yrot, zrot] renderView1.RotationFactor = rotation_factor renderView1.CameraViewAngle = camera_ang renderView1.CameraParallelScale = camera_sca renderView1.CameraParallelProjection = camera_proj renderView1.CameraFocalPoint = [xfoc, yfoc, zfoc] |
|
Tags |
camera view, paraview, scripting, trace |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[ICEM] ICEM Scripting Issues | tylerplowright | ANSYS Meshing & Geometry | 33 | September 27, 2021 17:35 |
ANSYS stack trace error when running 2-way FSI in command line | raz | ANSYS | 0 | June 6, 2017 08:31 |
[ANSYS Meshing] Need help with selection of edges using scripting | studentzz | ANSYS Meshing & Geometry | 1 | March 5, 2017 17:49 |
Glyph Scripting Origin | pdp.aero | Pointwise & Gridgen | 3 | July 9, 2015 17:57 |
record actions via scripting | Marabelle | ANSYS | 0 | July 31, 2013 12:57 |