Вы находитесь на странице: 1из 20

Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Chapter 6: The Plotting Client


Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

The Plotting Client – Overview

• Plotting Window

• Defining Curves from Data File

• Defining Curves from Math Expressions

• Adding Notes to a Plot

• Introduction to Templex Functions


Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

The Plotting Client – Plotting Window

• Use SetClientType on the window handle to create the plot object


page1 GetWindowHandle win1 1
win1 SetClientType plot

• After setting the client type you can access the plotting client and get full
access to its functionality using the GetClientHandle command
page1 GetWindowHandle win1 1
win1 GetClientHandle plot1

• Object Hierarchy for pltIPlot (or plotting client)


• The prefix “pltI” is used internally for naming the classes within the plotting
client and it stands for “plot Interface”.
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Data Files

• Add empty curve to plotting window


• Need a valid curve id

• Get the vector handles for the curve

• Set the type of curve to file

• Define the datatype, request, and component for the x and y vector

• Draw the curve in the plot window


Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Data Files

• Add empty curve to plotting window using AddCurve command on the


plot object
• This command adds an empty curve and returns the curve index

• Get the curve handle using GetCurveHandle on the plot object

• GetCurveHandle requires two arguments


• Handle name which can be any name the user desires
• Valid curve id which can be specified by either the AddCurve command or
hard coding an index

• You can use these two commands together to add the empty curve to a
session:
set curve_index [plot1 AddCurve]
plot1 GetCurveHandle curve1 $curve_index
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Data Files

• Next step is to get the vector handle using GetVectorHandle


command on the curve handle

• GetVectorHandle requires two arguments


• Handle name which can be any name the user desires
• A string indicating which vector to get – x, y, or time

• The vector handle is where the curve data is actually stored


curve1 GetVectorHandle xvector1 x
curve1 GetVectorHandle yvector1 y
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Data Files

• Next we need to set the type of vectors to file using the SetType
command on the vector handle
• SetType can be set to file, math, or values

• Also, we need to reference the data file using SetFilename


• We will do this by setting a variable which points to the file and then use this
variable in the SetFilename command.
xvector1 SetType file
yvector1 SetType file
set filename nodout
xvector1 SetFilename $filename
yvector1 SetFilename $filename
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Data Files

• Need to define the data type, request, and component, just like we do in
the Build Plots panel within HyperGraph.

• Done by using the SetDataType, SetRequest, and


SetComponent commands on the vector handle

xvector1 SetDataType "Time"


xvector1 SetRequest "Time"
xvector1 SetComponent "Time“
yvector1 SetDataType "Node Data"
yvector1 SetRequest "Nodal Point 26742"
yvector1 SetComponent "X Displacement"
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Data Files

• Final step is to tell the window to calculate the curve and draw it

• The Recalculate command forces the plot to regenerate all calculated


data and reread all file data

• The Autoscale command forces the plot to recompute the minimum and
maximum values for its axes
• May be necessary to call Recalculate first for recent data changes to be
considered

• The Draw command actually draws the plot with the curves on the window
• Changes made by other methods may not be displayed properly until Draw is
called
• A common practice is to make multiple changes and then call Draw only once,
limiting the number of redraws
plot1 Recalculate
plot1 Autoscale
plot1 Draw
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Math Expressions

• First need to understand how curves are referenced

• x and y vector expressions are used to reference any curve vector in a


session

• A curve vector reference defines the x or y vector by page, window, and


curve number

• An example of a curve vector reference is p2w3c4.x, where:


p2 is page 2
w3 is window 3
c4 is curve 4
x is the vector

• Similarly you have p2w3c4.y for the y vector


Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Defining Curves from Math Expressions

• Once you have the curve and vector handles, the SetType command
can be set to math
xvector1 SetType math
yvector1 SetType math

• Need to define the expressions to be used on x and y vectors using the


SetExpression command

• Our example we are adding curves with id 1 and 2

• X vector expression is simply defined as one of the x vectors from the


two we are summing

• Y vector expression is the summation of the two y vectors


xvector1 SetExpression p1w1c1.x
yvector1 SetExpression p1w1c1.y+p1w1c2.y
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Adding Notes to a Plot

• Add a note to the plotting window with AddNote command on plotting


client handle

• You also need to get the note handle using GetNoteHandle

• The GetNoteHandle requires two arguments


• The first is the handle name
• The second is a valid note id

• We can use the GetNoteHandle and AddNote commands together:


win1 GetClientHandle plot1
plot1 GetNoteHandle note1 [plot1 AddNote]
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Adding Notes to a Plot

• Now that we have adding a note and have the note handle, we can set
the name of the note and add text to the node

• Setting the name is done with SetName command on note handle

• Adding text is done with the SetText command on the note handle
note1 SetName “My Note”
note1 SetText “This is my note”

• If you wish to find the name or text of a note, you can use the GetName
and GetText commands on the note handle

note1 GetName
returns: My Note
note1 GetText
returns: This is my note
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Adding Notes to a Plot

• Notes can be attached to a curve, window, view, or point

• Done with the SetAttachment command on the note handle

note1 SetAttachment curve

• If curve is selected, we also have to set which curve the note is attached
to using the SetAttachToCurveIndex command on the note handle
• Below is an example where we are attaching to a curve with index of 2

note1 SetAttachToCurveIndex 2

• We also need to supply the index of the point that the note is attached to
using the SetAttachToPointIndex command on the note handle
• Setting the Point Index to 0 attaches the note at the first point of the curve

note1 SetAttachToPointIndex 0
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Introduction to Templex Statements

• What is Templex?
• Templex is a general purpose text and numeric processor
• Can be used to create fully annotated notes and labels capable of performing
data analysis and curve statistics within a plot window

• How do we attach a note to the last point of a curve


• Use the index number of the point –you need to know what this number is
• Use a Templex statement to tell you the number of points in a curve and
calculate the index

• numpts Templex statement reports the number of element in an


expression
• The result is always a scalar
• We can use statement to calculate the index
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Introduction to Templex Statements

• Using numpts statement to get the number of elements in a curve


numpts(p1w1c2.y)

• SetAttachToPointIndex requires the final index be specified which


is different than the number of elements
• Indexing starts with 0
• Counting starts with 1

note1 SetAttachment curve


note1 SetAttachToCurveIndex 2
note1 SetAttachToPointIndex “numpts(p1w1c2.y)-1”
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Introduction to Templex Statements

• Using Templex Statements in the text of a note

• Need to use { } around Templex statement when it is used inside a text


field
• Templex statement(s) that are inside the { } are automatically evaluated so
that in the note you see the numerical value

• For example, let’s report the maximum value of a curve inside a note:

note1 SetText "maximum value is {max(p1w1c2.y)}"


Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

Exercise 6.1

Creating Plots and Notes with Templex inside the Notes


Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

The Plotting Client - Exercise

Exercise 6a
Description:
Load in the data file demo.dat and create a curve using the following YType, Y Request, and Y
Component vs Time:
Y Type:Force
Y Request: REQ/13 Curve 13
Y Component: Z
Then in the same window, create a second curve using the following vs. Time:
Y Type:Force
Y Request: REQ/18 Curve 18
Y Component: Z
Update the X axis so that the label is “Time (seconds)” and the Y axis label is “Force (Newtons)”.
Handles used
session, project, page, window, client, curve, vector
TCL/TK commands used
AddCurve, SetFilename, SetType, SetDataType, SetRequest, SetComponent
Hints
Try loading the demo.dat file into HyperGraph to see how the Y Type, Y Request, or Y
Component are defined.
Copyright © 2009 Altair Engineering, Inc. Proprietary and Confidential. All rights reserved.

The Plotting Client - Exercise

Exercise 6b

Description:

Using the 2 curves created in Exercise 5a, add those two curves together.
Update the title of the curve to be “Sum Fz Request 13 and 18”. Add a
note which reports the minimum of the new curve. Attach the note to the
minimum as well.

Handles used

session, project, page, window, client, curve, vector, note

TCL/TK commands used

SetType, SetExpression, AddNote, SetAttachment

Hints

To attach a note to the curve at the same point as the minimum, try using
the Templex command indexofmin.

Вам также может понравиться