Ruggiero, The following script saves a 100x100 sphere. I created it using the trace option in ParaView.
On Thu, Sep 10, 2015 at 5:07 AM, Ruggiero Guida <ruggiero.gu...@gmail.com> wrote: > I am trying to create a screenshot of a specific size from a [VTK file][1]. > This is the code I am using > > from paraview.simple import * > paraview.simple._DisableFirstRenderCameraReset() > rad_map = LegacyVTKReader(FileNames=['test.vtk']) > > # get active view > renderView1 = GetActiveViewOrCreate('RenderView') > dpi = 70 > heigth = 24.39846235421442 > width = 24.398462354214413 > width_p = int(width * dpi) > heigth_p = int(heigth * dpi) > renderView1.ViewSize = [width_p, heigth_p] > > # reset view to fit data > #renderView1.ResetCamera() > > # current camera placement for renderView1 > renderView1.CameraParallelProjection = 1 > renderView1.CameraPosition = [5, 5, 1000] > renderView1.CameraFocalPoint = [5, 5, 0.0] > renderView1.CameraViewUp = [0.0, 1.0, 0.0] > scale = (heigth) / 2.0 > renderView1.CameraParallelScale = scale > > Render() > SaveScreenshot("/Users/ruggiero/dev/test.png", magnification=1) > > The problem is that the `ViewSize` seems to be ignored and I keep having > images of fixed size 1707 × 855. The height 855 seems to be a kind of > limit; the only way to get what I want is to limit the `ViewSize` to > 855x855. > > I have checked [this][2] question and [this][3] question, but with no > success. > > Any idea? I am not very confident in the settings for the camera. Could > this be the issue? > > > [1]: https://dl.dropboxusercontent.com/u/1342856/test.vtk > [2]: > http://stackoverflow.com/questions/31930448/in-python-script-for-paraview-can-i-specify-the-resolution-when-i-do-a-savescre > [3]: > http://stackoverflow.com/questions/27430588/paraview-python-command-to-save-picture-of-defined-size > > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the ParaView Wiki at: > http://paraview.org/Wiki/ParaView > > Search the list archives at: http://markmail.org/search/?q=ParaView > > Follow this link to subscribe/unsubscribe: > http://public.kitware.com/mailman/listinfo/paraview > >
#### import the simple module from the paraview from paraview.simple import * #### disable automatic camera reset on 'Show' paraview.simple._DisableFirstRenderCameraReset() # create a new 'Sphere' sphere1 = Sphere() # get active view renderView1 = GetActiveViewOrCreate('RenderView') # uncomment following to set a specific view size renderView1.ViewSize = [100, 100] # show data in view sphere1Display = Show(sphere1, renderView1) # trace defaults for the display properties. sphere1Display.ColorArrayName = [None, ''] sphere1Display.DiffuseColor = [0.0, 0.65, 1.0] # reset view to fit data renderView1.ResetCamera() # current camera placement for renderView1 renderView1.CameraPosition = [0.0, 0.0, 3.2903743041222895] renderView1.CameraParallelScale = 0.8516115354228021 # save screenshot SaveScreenshot('/home/danlipsa/Desktop/a.png', magnification=1, quality=100, view=renderView1) #### saving camera placements for all active views # current camera placement for renderView1 renderView1.CameraPosition = [0.0, 0.0, 3.2903743041222895] renderView1.CameraParallelScale = 0.8516115354228021 #### uncomment the following to render all views # RenderAllViews() # alternatively, if you want to write images, you can use SaveScreenshot(...).
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the ParaView Wiki at: http://paraview.org/Wiki/ParaView Search the list archives at: http://markmail.org/search/?q=ParaView Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/paraview