Windows and Views
Web.Link provides access to Creo Parametric windows and saved views. This section describes the methods that provide this access.
Windows
This section describes the Web.Link methods that access pfcWindow objects. The topics are as follows:
Getting a Window Object
Methods and Property Introduced:
  • pfcBaseSession.CurrentWindow
  • pfcBaseSession.CreateModelWindow()
  • pfcModel.Display()
  • pfcBaseSession.ListWindows()
  • pfcBaseSession.GetWindow()
  • pfcBaseSession.OpenFile()
  • pfcBaseSession.GetModelWindow()
  • The property pfcBaseSession.CurrentWindow provides access to the current active window in Creo Parametric.
    The method pfcBaseSession.CreateModelWindow() creates a new window that contains the model that was passed as an argument.
    Note
    You must call the method pfcModel.Display() for the model geometry to be displayed in the window.
    Use the method pfcBaseSession.ListWindows() to get a list of all the current windows in session.
    The method pfcBaseSession.GetWindow() gets the handle to a window given its integer identifier.
    The method pfcBaseSession.OpenFile() returns the handle to a newly created window that contains the opened model.
    Note
    If a model is already open in a window the method returns a handle to the window.
    The method pfcBaseSession.GetModelWindow() returns the handle to the window that contains the opened model, if it is displayed.
    Window Operations
    Methods and Properties Introduced:
  • pfcWindow.Height
  • pfcWindow.Width
  • pfcWindow.XPos
  • pfcWindow.YPos
  • pfcWindow.GraphicsAreaHeight
  • pfcWindow.GraphicsAreaWidth
  • pfcWindow.Clear()
  • pfcWindow.Repaint()
  • pfcWindow.Refresh()
  • pfcWindow.Close()
  • pfcWindow.Activate()
  • pfcWindow.GetId()
  • pfcBaseSession.FlushCurrentWindow()
  • The properties pfcWindow.Height, pfcWindow.Width, pfcWindow.XPos, and pfcWindow.YPos retrieve the height, width, x-position, and y-position of the window respectively. The values of these parameters are normalized from 0 to 1.
    The properties pfcWindow.GraphicsAreaHeight and pfcWindow.GraphicsAreaWidth retrieve the height and width of the Creo Parametric graphics area window without the border respectively. The values of these parameters are normalized from 0 to 1. For both the window and graphics area sizes, if the object occupies the whole screen, the window size returned is 1. For example, if the screen is 1024 pixels wide and the graphics area is 512 pixels, then the width of the graphics area window is returned as 0.5.
    The method pfcWindow.Clear() removes geometry from the window.
    Both pfcWindow.Repaint() and pfcWindow.Refresh() repaint solid geometry. However, the Refresh method does not remove highlights from the screen and is used primarily to remove temporary geometry entities from the screen.
    Use the method pfcWindow.Close() to close the window. If the current window is the original window created when Creo Parametric started, this method clears the window. Otherwise, it removes the window from the screen.
    The method pfcWindow.Activate() activates a window. This function is available only in the asynchronous mode.
    The method pfcWindow.GetId() retrieves the ID of the Creo Parametric window.
    The method pfcBaseSession.FlushCurrentWindow() flushes the pending display commands on the current window.
    Note
    It is recommended to call this method only after completing all the display operations. Excessive use of this method will cause major slow down of systems running on Windows Vista and Windows 7.
    Embedded Browser
    Methods Introduced:
  • pfcWindow.GetURL()
  • pfcWindow.SetURL()
  • pfcWindow.GetBrowserSize()
  • pfcWindow.SetBrowserSize()
  • The methods pfcWindow.GetURL() and pfcWindow.SetURL() enables you to find and change the URL displayed in the embedded browser in the Creo Parametric window.
    The methods pfcWindow.GetBrowserSize() and pfcWindow.SetBrowserSize() enables you to find and change the size of the embedded browser in the Creo Parametric window.
    Note
    The methods pfcWindow.GetBrowserSize() and pfcWindow.SetBrowserSize() are not supported if the browser is open in a separate window.
    Views
    This section describes the Web.Link methods that access pfcView objects. The topics are as follows:
    Getting a View Object
    Methods Introduced:
  • pfcViewOwner.RetrieveView()
  • pfcViewOwner.GetView()
  • pfcViewOwner.ListViews()
  • pfcViewOwner.GetCurrentView()
  • Any solid model inherits from the interface pfcViewOwner. This will enable you to use these methods on any solid object.
    The method pfcViewOwner.RetrieveView() sets the current view to the orientation previously saved with a specified name.
    Use the method pfcViewOwner.GetView() to get a handle to a named view without making any modifications.
    The method pfcViewOwner.ListViews() returns a list of all the views previously saved in the model.
    From Creo Parametric 2.0 M120 onward, the method, pfcViewOwner.GetCurrentView() has been deprecated. The method returns a view handle that represents the current orientation. Although this view does not have a name, you can use this view to find or modify the current orientation.
    View Operations
    Methods and Properties Introduced:
  • pfcView.Name
  • pfcView.IsCurrent
  • pfcView.Reset()
  • pfcViewOwner.SaveView()
  • To get the name of a view given its identifier, use the property pfcView.Name.
    The property pfcView.IsCurrent determines if the View object represents the current view.
    The method pfcView.Reset() restores the current view to the default view.
    To store the current view under the specified name, call the method pfcViewOwner.SaveView().
    Coordinate Systems and Transformations
    his section describes the various coordinate systems used by Creo Parametric and accessible from Web.Link and how to transform from one coordinate system to another.
    Coordinate Systems
    Creo Parametric and Web.Link use the following coordinate systems:
    The following sections describe each of these coordinate systems.
    Solid Coordinate System
    The solid coordinate system is the three-dimensional, Cartesian coordinate system used to describe the geometry of a Creo Parametric solid model. In a part, the solid coordinate system describes the geometry of the surfaces and edges. In an assembly, the solid coordinate system also describes the locations and orientations of the assembly members.
    You can visualize the solid coordinate system in Creo Parametric by creating a coordinate system datum with the option Default. Distances measured in solid coordinates correspond to the values of dimensions as seen by the Creo Parametric user.
    Solid coordinates are used by Web.Link for all the methods that look at geometry and most of the methods that draw three-dimensional graphics.
    Screen Coordinate System
    The screen coordinate system is two-dimensional coordinate system that describes locations in a Creo Parametric window. This is an intermediate coordinate system after which the screen points are transformed to screen pixels. All the models are first mapped to the screen coordinate system. When the user zooms or pans the view, the screen coordinate system follows the display of the solid, so a particular point on the solid always maps to the same screen coordinate. The mapping changes only when the view orientation is changed.
    Screen coordinates are used by some of the graphics methods, the mouse input methods, and all methods that draw graphics or manipulate items on a drawing.
    Window Coordinate System
    The window coordinate system is similar to the screen coordinate system. After mapping the models to the screen coordinate system, they are mapped to the window coordinate before being drawn to screen pixels based on screen resolution. When pan or zoom values are applied to the coordinates in the screen coordinate system, they result in window coordinates. When an object is first displayed in a window, or the option View  Refit is used, the screen and window coordinates are the same.
    Window coordinates are needed only if you need to take account of zoom and pan—for example, to find out whether a point on the solid is visible in the window, or to draw two-dimensional text in a particular window location, regardless of pan and zoom.
    Drawing Coordinate System
    The drawing coordinate system is a two-dimensional system that describes the location on a drawing relative to the bottom, left corner, and measured in drawing units. For example, on a U.S. letter-sized, landscape-format drawing sheet that uses inches, the top, right-corner is (11, 8.5) in drawing coordinates.
    The Web.Link methods and properties that manipulate drawings generally use screen coordinates.
    Drawing View Coordinate System
    The drawing view coordinate system is used to describe the locations of entities in a drawing view.
    Assembly Coordinate System
    An assembly has its own coordinate system that describes the positions and orientations of the member parts, subassemblies, and the geometry of datum features created in the assembly.
    When an assembly is retrieved into memory each member is also loaded and continues to use its own solid coordinate system to describe its geometry.
    This is important when you are analyzing the geometry of a subassembly and want to extract or display the results relative to the coordinate system of the parent assembly.
    Datum Coordinate System
    A coordinate system datum can be created anywhere in any part or assembly, and represents a user-defined coordinate system. It is often a requirement in a Web.Link application to describe geometry relative to such a datum.
    Section Coordinate System
    Every sketch has a coordinate system used to locate entities in that sketch. Sketches used in features will use a coordinate system different from that of the solid model.
    Transformations
    Methods and Properties Introduced:
  • pfcTransform3D.Invert()
  • pfcTransform3D.TransformPoint()
  • pfcTransform3D.TransformVector()
  • pfcTransform3D.Matrix
  • pfcTransform3D.GetOrigin()
  • pfcTransform3D.GetXAxis()
  • pfcTransform3D.GetYAxis()
  • pfcTransform3D.GetZAxis()
  • MpfcBase.MakeMatrixOrthonormal()
  • All coordinate systems are treated in Web.Link as if they were three-dimensional. Therefore, a point in any of the coordinate systems is always represented by the pfcPoint3D class:
    Vectors store the same data but are represented for clarity by the pfcVector3D class.
    Screen coordinates contain a z-value whose positive direction is outwards from the screen. The value of z is not generally important when specifying a screen location as an input to a method, but it is useful in other situations. For example, if you select a datum plane, you can find the direction of the plane by calculating the normal to the plane, transforming to screen coordinates, then looking at the sign of the z-coordinate.
    A transformation between two coordinate systems is represented by the pfcTransform3D class. This class contains a 4x4 matrix that combines the conventional 3x3 matrix that describes the relative orientation of the two systems, and the vector that describes the shift between them.
    The 4x4 matrix used for transformations is as follows:
    Image
    The utility method pfcTransform3D.Invert() inverts a transformation matrix so that it can be used to transform points in the opposite direction.
    Web.Link provides two utilities for performing coordinate transformations. The method pfcTransform3D.TransformPoint() transforms a three-dimensional point and pfcTransform3D.TransformVector() transforms a three-dimensional vector.
    The following diagram summarizes the coordinate transformations needed when using Web.Link and specifies the Web.Link methods that provide the transformation matrix.
    Image
    The method MpfcBase.MakeMatrixOrthonormal() converts a non-orthonormal matrix to an orthonormal matrix with the specified scaling factor. The input arguments follow:
    •  Matrix—The matrix to be converted to orthonormal.
    •  Scale—Scale factor to be applied on the matrix.
    Transforming to Screen Coordinates
    Methods and Properties Introduced:
  • pfcView.Transform
  • pfcView.Rotate()
  • pfcViewOwner.GetCurrentViewTransform()
  • pfcViewOwner.SetCurrentViewTransform()
  • pfcViewOwner.CurrentViewRotate()
  • pfcTransform3D.Invert()
  • The view matrix describes the transformation from solid to screen coordinates. The property pfcView.Transform provides the view matrix for a model in the view.
    To get and set the transformation matrix for a model in the current view, use the methods pfcViewOwner.GetCurrentViewTransform() and pfcViewOwner.SetCurrentViewTransform().
    The method pfcView.Rotate() rotates an object, relative to the X, Y, or Z axis for the specified rotation angle.
    To rotate an object in the current view, use the method pfcViewOwner.CurrentViewRotate().
    To transform from screen to solid coordinates, invert the transformation matrix using the method pfcTransform3D.Invert().
    Transforming to Coordinate System Datum Coordinates
    Property Introduced:
  • pfcCoordSystem.CoordSys
  • The property pfcCoordSystem.CoordSys provides the location and orientation of the coordinate system datum in the coordinate system of the solid that contains it. The location is in terms of the directions of the three axes and the position of the origin.
    Transforming Window Coordinates
    Properties Introduced
  • pfcWindow.ScreenTransform
  • pfcScreenTransform.PanX
  • pfcScreenTransform.PanY
  • pfcScreenTransform.Zoom
  • You can alter the pan and zoom of a window by using a Screen Transform object. This object contains three attributes. PanX and PanY represent the horizontal and vertical movement. Every increment of 1.0 moves the view point one screen width or height. Zoom represents a scaling factor for the view. This number must be greater than zero.
    Transforming Coordinates of an Assembly Member
    Method Introduced:
  • pfcComponentPath.GetTransform()
  • The method pfcComponentPath.GetTransform() provides the matrix for transforming from the solid coordinate system of the assembly member to the solid coordinates of the parent assembly, or the reverse.