Msc. Patran pcl handbook In a Nutshell 7



Download 1.08 Mb.
Page17/25
Date05.08.2017
Size1.08 Mb.
#26706
1   ...   13   14   15   16   17   18   19   20   ...   25

Event Manager

General


  • MSC.Patran’s event manager performs the following functions:

  • Oversees program execution including coordination between MSC.Patran’s four functional areas, i.e., a) user interface, b) applications, c) database, and d) graphics

  • First in – first out

  • Controls heartbeat

  • From a PCL programming perspective, the event manager primarily allows the programmer the ability to halt execution in the event that the MSC.Patran user selects the Abort icon during PCL execution





  • These functions are typically used in loops, i.e., FOR, WHILE, or REPEAT.

  • It is up to the PCL programmer to decide what to do once the user has elected to abort execution. In general, you may want to execute the uil_db_undo() command to clean up any created items, i.e., nodes, elements, property sets, etc.

Event Manager

Functions


  • em_proceed_normal() – Returns FALSE if the user wants to abort and TRUE if the user wants to continue. The user signals his abort request by clicking the Abort icon and confirming his abort request on the Abort Confirmation Window. Note that this function allows the system to update/refresh graphics and forms.



  • em_proceed_quick() – Same as em_proceed_normal() except that it doesn’t allow the system to update/refresh graphics.

  • em_synchronize() – Synchronizes events and graphics making sure everthing is uptodate. Does not handle aborts.

Example


FOR (i = 1 to num_elms)

IF (!em_proceed_normal()) THEN RETURN (-1)

/* statements that do something */

END FOR

Primitive Graphics


  • MSC.Patran provides a set of functions that can be used to draw graphical primitives or objects (e.g., lines, arrows, text, etc.) in the graphic viewports.

  • These routines allow PCL programmers the ability to provide graphical feedback to the user.

Graphic Objects


  • At the present time, MSC.Patran provides functions for drawing 5 graphical objects: lines, text, markers, arrows, and result arrows.

    gm_draw_line(SegmentId, ColorId, StartXYZ, EndXYZ)

    gm_draw_text(SegmentId, ColorId, LocationXYZ, TextString)

    gm_draw_marker(SegmentId, ColorId, LocationXYZ, MarkerType, @

    MarkerSize)

    gm_draw_arrow(SegmentId, ColorId, BaseXYZ, TipXYZ, HeadSize)

    gm_draw_result_arrow(SegmentId, ColorId, LocationXYZ, Direction, @

    ArrowSize, AnchorStyle, LabelString)

  • These graphic objects can be used to:

  1. display/annotate results, LBCs, or other information

  2. create a PCL function to perform labeling operations

  3. create sketches of objects

  • All coordinates referenced by the graphics routines are specified in world space, i.e., MSC.Patran global coordinates.

  • Each graphic object is added to a graphic segment. These graphic segments are used to group, display, and delete the graphic objects.

Primitive Graphics

Graphic Segments


  • Each graphic object is added to a graphic segment. These graphic segments are used to group, display, and delete the graphic objects.

  • There is no limit to how many graphic objects can be added to a graphic segment.

  • Graphic objects are grouped into graphic segments by using a common segment Id. Segments are created using the gm_segment_create(SegmentId) function. Note that you do not specify the SegmentId, but it is assigned by MSC.Patran.

  • Graphic objects are removed or deleted from the display by deleting the appropriate graphic segment with the gm_segment_delete(SegmentId) function.

  • The gm_segment_flush() function draws or “flushes” all currently defined graphic segments to all viewports that contain the current group (of the current viewport).

  • Graphic segments are automatically updated by MSC.Patran to reflect changes in the orientation or position of the model in the graphic viewport.

  • Using the MSC.Patran reset graphics or refresh graphics icons will not remove primitive graphics. Only the gm_segment_delete(SegmentId) function will remove primitive graphics from MSC.Patran viewports.

Primitive Graphics

Example


INTEGER SegmentId
gm_segment_create(SegmentId)
gm_draw_line(SegmentId, 5, [0 0 0], [1 0 0])

gm_draw_line(SegmentId, 5, [1 0 0], [1 1 0])

gm_draw_line(SegmentId, 5, [1 1 0], [0 1 0])

gm_draw_line(SegmentId, 5, [0 1 0], [0 0 0])
gm_draw_text(SegmentId, 12, [0.5, 0.5, 0], “Box”)
gm_segment_flush()




Note that 2 different types of graphic objects (lines and text) are both included in the same graphic segment.

Very primitive graphics

Primitive Graphics


Another Example


FUNCTION Draw2DBox(ColorId, UpperLeft, LowerRight, SegmentId)
/*

Input ColorId INTEGER

UpperLeft(2) REAL

LowerRight(2) REAL

Output SegmentId INTEGER

INTEGER

*/
INTEGER ColorId, SegmentId

INTEGER status
REAL UpperLeft(), LowerRight()

REAL BoxCorners(4, 3)
IF (ColorId < 0 || ColorId > 15) THEN RETURN -1
BoxCorners(1, 1) = UpperLeft(1)

BoxCorners(1, 2) = LowerRight(2)

BoxCorners(1, 3) = 0.0
BoxCorners(2, 1:2) = LowerRight(1:2)

BoxCorners(2, 3) = 0.0
BoxCorners(3, 1) = LowerRight(1)

BoxCorners(3, 2) = UpperLeft(2)

BoxCorners(3, 3) = 0.0
BoxCorners(4, 1:2) = UpperLeft(1:2)

BoxCorners(4, 3) = 0.0

status = gm_segment_create(SegmentId)

IF (status != 0) THEN RETURN status
status = gm_draw_line(SegmentId, ColorId, BoxCorners(1, 1:3), BoxCorners(2, 1:3))

IF (status != 0) THEN RETURN status

status = gm_draw_line(SegmentId, ColorId, BoxCorners(2, 1:3), BoxCorners(3, 1:3))

IF (status != 0) THEN RETURN status

status = gm_draw_line(SegmentId, ColorId, BoxCorners(3, 1:3), BoxCorners(4, 1:3))

IF (status != 0) THEN RETURN status

status = gm_draw_line(SegmentId, ColorId, BoxCorners(4, 1:3), BoxCorners(1, 1:3))

IF (status != 0) THEN RETURN status
status = gm_segment_flush()

IF (status != 0) THEN RETURN status
RETURN 0
END FUNCTION /* Draw2DBox */



Download 1.08 Mb.

Share with your friends:
1   ...   13   14   15   16   17   18   19   20   ...   25




The database is protected by copyright ©ininet.org 2024
send message

    Main page