Jump to content
Mr. Abolfazl Shiri

post-processing macro

Recommended Posts

I want to write a macro for automatically taking snapshots of the

contour plots, using command line and I am looking for a manual which

contains more detail of the global commands. The list provided in

 Documentation is not enough and is missing many thing. Also the list

in FGuiAction does not cover all the actions. Please let me know where

to look for this information.

 

Thanks,.

Share this post


Link to post
Share on other sites

Hi,

Do you know the Screenshot Collection you can configure in the designEngines? This might be the easiest and most comfortable way to do it. Just set your visualizations in the various 3D Windows and create an assembly.

Share this post


Link to post
Share on other sites

About the full list of global commands we have to put our heads together. Do you have particular classes of commands in mind? Some of the "commands" are implemented as features and those are scanned in real time and depend on your configuration.

Share this post


Link to post
Share on other sites

Hi,

Do you know the Screenshot Collection you can configure in the designEngines? This might be the easiest and most comfortable way to do it. Just set your visualizations in the various 3D Windows and create an assembly.

Hi,

Good idea... Can I use this method for all the simulation which are performed before.  

I want to be able to import the Shipflow Result file (.cgns) and run a macro to plot all the graphs in an automated method.

implementing an DesignEngin in each case sounds a bit of effort.

 

Thanks.

(p.s.> is there any tutorial explaining how to do the method you have suggested?)

Share this post


Link to post
Share on other sites

About the full list of global commands we have to put our heads together. Do you have particular classes of commands in mind? Some of the "commands" are implemented as features and those are scanned in real time and depend on your configuration.

To be more precise, I would like to parametresize a series of plot generation. The code I am working right now looks like this:

 

clearConsole()

getActive3DWindow().getCamera().set(doubleSeries(0,1,0, 0,-1,0, 0,0,0, 0,1,0, -75,-47,30,1,7,44,270,73,0,-2,0,0), 210)

XPAN_FreeContours.setVisible(true)

XPAN_FreeContours.setViewer(3DScene)

XPAN_FreeContours.setMappedData("WaveHeight")

XPAN_FreeContours.setDivisions(12)

// set preset 1, XPAN_FreeContours.setPreset()

XPAN_FreeContours.setColorMap(WaveHeight)

WaveHeight.setVisible(true)

WaveHeight.setValues([-0.005,0.005:12])

WaveHeight.setOrientation("Horizontal")

WaveHeight.setWidthRange(300)

WaveHeight.setHeightRange(20)

WaveHeight.setXRange(50)

WaveHeight.setYRange(0)

3DScene.enableLighting(false)

3DView.screenshot("C:\Documents\ShipFlow\test.png",FNull)

 

First question: what is the matrix in .getCamera() setting means. how can I decide which view to set.

Second: how can I define a variable in the code to make it general. Define the variables at the begining of macro and use them.

 

I will come back with more questions, but so far these are the important ones.

Thank you very much for the help

Share this post


Link to post
Share on other sites

Hi,

 

CAESES/FFW uses commands internally that are not exposed to the user. These commands are used inside the Framework only and are not guaranteed to not change their behavior, their interface or may even be removed completely in upcoming releases. The mentioned "getActive3DWindow()" command is such a command. Those commands are taken out of the global command list or the autocompletion on purpose.

 

However, as your example shows, there are commands that _should_ be marked as internal but are not. The "FGlCamera.set()" command is such a command. We do not advice to use this command as a user. They can be used, of course, but the usage may not be straight forward and may be error prone. The only way to find out the correct argument for the camera setting matrix is to create a new camera position (toolbars->Camera Positions) and look at the "toggleOnCmd" of the created action (right click->edit in the main toolbar).

 

Regarding the code you posted: Is this a featuredefinition or an fsc script? Fsc scripts do not have any input arguments. Features allow to define input arguments that can be referenced inside the code.

Share this post


Link to post
Share on other sites

Hi,

 

CAESES/FFW uses commands internally that are not exposed to the user. These commands are used inside the Framework only and are not guaranteed to not change their behavior, their interface or may even be removed completely in upcoming releases. The mentioned "getActive3DWindow()" command is such a command. Those commands are taken out of the global command list or the autocompletion on purpose.

 

However, as your example shows, there are commands that _should_ be marked as internal but are not. The "FGlCamera.set()" command is such a command. We do not advice to use this command as a user. They can be used, of course, but the usage may not be straight forward and may be error prone. The only way to find out the correct argument for the camera setting matrix is to create a new camera position (toolbars->Camera Positions) and look at the "toggleOnCmd" of the created action (right click->edit in the main toolbar).

 

Regarding the code you posted: Is this a featuredefinition or an fsc script? Fsc scripts do not have any input arguments. Features allow to define input arguments that can be referenced inside the code.

 

I will use commands like " 3DView.rotateToXAxis() " instead but then I have three questions:

1- how can I zoom in a particular section of the window and then capture the screenshot?

2-what is the command for turning off the offsets.

3- what is the comman for turning on/off Isometric View?

 

Thanks for your help

Share this post


Link to post
Share on other sites

Hi,

 

1. The only way I can think of is what Arne wrote about the camera positions toolbar. Setup your viewport and create a new camera position. Then look into the "toggle on command". The transformation matrix applied there is probably what you are looking for.

 

2. For the quick filters, there is only an internal command (for which applies what Arne wrote above):

3DScene.setFilterState("offsetFilter true")

where you set true or false to enable/ disable the respective filter.

 

Following filters are currently used:

pointFilter

curveFilter

surfaceFilter

meshFilter

offsetFilter

 

You can also set multiple filter states by using expressions like this:

3DScene.setFilterState("surfaceFilter true\noffsetFilter true")

 

3. There is no command to turn isometric view on or off. You can change the view by using

3DView.rotateToIsometric...()

(same like you did with rotateToXAxis()).

 

I hope that helps.

 

Cheers,

Stefan

Share this post


Link to post
Share on other sites

Hi,

 

1. The only way I can think of is what Arne wrote about the camera positions toolbar. Setup your viewport and create a new camera position. Then look into the "toggle on command". The transformation matrix applied there is probably what you are looking for.

 

2. For the quick filters, there is only an internal command (for which applies what Arne wrote above):

3DScene.setFilterState("offsetFilter true")

where you set true or false to enable/ disable the respective filter.

 

Following filters are currently used:

pointFilter

curveFilter

surfaceFilter

meshFilter

offsetFilter

 

You can also set multiple filter states by using expressions like this:

3DScene.setFilterState("surfaceFilter true\noffsetFilter true")

 

3. There is no command to turn isometric view on or off. You can change the view by using

3DView.rotateToIsometric...()

(same like you did with rotateToXAxis()).

 

I hope that helps.

 

Cheers,

Stefan

 

Thank you very much Stefan,

Just a comment:

- if you run "3DView.rotateToIsometric...()" command while the Isometric View is disabled, it gives different camera view. this might be a bug in the system.

Share this post


Link to post
Share on other sites

What are the correct argument for commands below:

 

getActive3DWindow().getCamera().setTranslationVector()

 

getActive3DWindow().getCamera().setRotationVector()

 

 

I want to rotate the camera in a certain angle and translate the focal length of the camera to a specific position.

 

Thank you

Share this post


Link to post
Share on other sites

These two commands are leftovers from an earlier version and are not functional anymore. Unfortunately they have not been removed yet.
What you are looking for is setting a transformation for the camera.

There are two ways to go about that:

The first way is to specify a coordinate system using a point of origin and a second point the z-axis of the system should point at.
This coordinate system can then be used as transformation for the camera.

point  camOrigin(0,0,0)
point  camViewPoint(0,0,1)

coordinateSystem camSystem()
camSystem.setOrigin(camOrigin)
camSystem.setAlignment(camOrigin+camViewPoint)

3DCam.setTransformation(camSystem.getInverseMatrix4())

The origin used in the coordinate system will then be the position of the camera and the alignment of the system will be the point the camera is facing.

By making the alignment relative to the origin ("camOrigin + camViewpoint"), camViewPoint effectively behaves like a vector specifying the viewing direction of the camera.

So changing camViewPoint to [1,1,1] will rotate the camera by 45 degrees around the X- and Y-axes for example.
If you change camOrigin to [0,0,1] for example, the camera will move one unit to the right, effectively moving the scene one unit to the left.

If you want to also rotate the camera around the viewing direction, you can use the following:

parameter rollAngle(0)
camSystem.setAngle(rollAngle)

Changing the parameter rollAngle will then roll the camera around the viewing direction.

 

 

The second way lets you specify the viewing direction using Euler angles by utilizing a transformationchain.

rotation camRotationX(parameter angleX(0),0)
rotation camRotationY(parameter angleY(0),1)
rotation camRotationZ(parameter angleZ(0),2)

translation camTranslation(0,0,0)
transformationchain camTransformation([camRotationX, camRotationY, camRotationZ, camTranslation])

coordinateSystem camSystem()
camSystem.setTransformation(camTransformation)

3DCam.setTransformation(camSystem.getInverseMatrix4())

With this setup you can change the rotations around the axes by changing the angle parameters.
The translation controls the position of the camera. This could also be parametrized of course.

 

 

 


Please note that by default an orthographic projection is used. This means that the camera does not have a perceivable distance to the scene,
so moving the camera along the viewing direction does not change the size of the displayed objects as would be the case for a perspective projection.
Also, objects will even be displayed if they are technically behind the camera, which might be confusing when changing the position of the camera.

In order to change the size of the displayed objects you will need to use the command .setZoomLevel() of the camera.

Share this post


Link to post
Share on other sites

Hi David,

 

Actually, no, there is no way to specify the resolution except when not providing a path and using the setting on the file dialog that pops up.

I have just added an optional "width" parameter to both, the global screenshot command and the FGlWindow.screenshot command, that allows to specify the width of the image. The height will be scaled accordingly. It will be included in 3.1.

 

Arne

Share this post


Link to post
Share on other sites

Hi David,

 

The problem is that if you specify both, width and height, it is impossible to specify the actual viewport. What I mean is, that the screenshot command takes the current viewport (i.e. camera position and window geometry) to determine what to put into the screenshot. If you would now specify width and height in the command that has a different aspect ration than the current viewport, what would you expect as a viewport? I tried to visualize that in this image:

 

post-7-0-87210200-1402388219_thumb.png

 

And even if you can tell me what YOU would aspect, the next person could expect something completely different...

 

What you can do is utilize the screenshot collection for this. Set up the desired viewport including aspect ratio once, set the resolution and let the screenshotcollection handle the rest.

 

Arne

Share this post


Link to post
Share on other sites

I would expect that the window is resized accordant to the new aspect ratio. There is other software which handles it in this way

 

But if you say that a screenshot collection is also possible ... I will check that.

 

David

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...