|
Action:
|
Gets the position of a pick event.
|
|
|
Filename:
|
scm/scmext/pick_scm.cxx
|
|
|
Syntax:
|
(pick:position event [plane-position
|
|
|
[plane-direction=xy-plane]])
|
|
|
Arg Types:
|
event
|
pick-event
|
|
plane-position
|
position
|
|
plane-direction
|
gvector
|
|
|
Returns:
|
position
|
|
|
Description:
|
This extension computes the
position of the pick event mapped into the space of the active WCS, if specified; otherwise, it maps into model space coordinates. If snapping is active, the position component is snapped to the grid. Positions returned are approximate.
|
|
|
event specifies the event used, typically, a mouse click.
|
|
|
The optional
plane-position specifies the position of the plane to pick.
|
|
|
The optional
plane-direction specifies the normal direction of the plane from which to pick. The default is the
xy-plane in model space.
|
|
|
Example:
|
; pick:position
|
|
; Create a solid block.
|
|
(define block1
|
|
|
(solid:block (position -10 -10 0)
|
|
|
(position 25 25 25)))
|
|
;; block1
|
|
; Extract a position of the pick from a pick-event.
|
|
(pick:position (read-event))
|
|
; Using the mouse, select screen position 1
|
|
; corresponding approximately to the upper
|
|
; left corner of the front of the block.
|
|
;; #[position -34.3990726470947 39.1702480316162 0]
|
|
; Extract another position of the pick from a
|
|
; pick-event.
|
|
(pick:position
|
|
|
(read-event) (position 0 0 0)
|
|
|
(gvector 0 1 0))
|
|
; Using the mouse, select screen position 1
|
|
; corresponding approximately to the lower
|
|
; right corner of the front of the block.
|
|
;; #[position 20.2177810668945 0 -5.35901403427124]
|
|
; OUTPUT Example 1
|
|
|
; Second example:
|
|
; Draw a rubberbanded rectangle using
|
|
; pick:position.
|
|
; Define the first corner of a rectangle.
|
|
(define start (pick:position (read-event)))
|
|
;; start
|
|
; Create a rectangle rubberband driver.
|
|
(rbd:rectangle #t start)
|
|
;; #[rbd-driver 401b1df0]
|
|
; Define the second corner of rectangle.
|
|
(define end (pick:position (read-event)))
|
|
;; end
|
|
; Define the rectangle.
|
|
(define rectangle
|
|
|
(lambda (start end)
|
|
|
|
(let ((x1 (position:x start))
|
|
|
|
|
(x2 (position:x end))
|
|
|
|
|
(y1 (position:y start))
|
|
|
|
|
(y2 (position:y end))
|
|
|
|
|
(z1 (position:z start))
|
|
|
|
|
(z2 (position:z end)))
|
|
|
|
(let ((corner1 (position x2 y1 z2))
|
|
|
|
(corner2 (position x1 y2 z1)))
|
|
|
(list (edge:linear start corner1)
|
|
|
|
(edge:linear corner1 end)
|
|
|
|
(edge:linear end corner2)
|
|
|
|
(edge:linear corner2 start))))))
|
|
;; rectangle
|
|
; Draw the rectangle.
|
|
(define rectangle (rectangle start end))
|
|
;; rectangle
|
|
; #[entity 2 1] #[entity 3 1] #[entity 4 1]
|
|
; #[entity 5 1]
|
|
; Turn off rubberbanding.
|
|
(rbd:remove-type rbd:rectangle?)
|
|
;; ()
|
|
; OUTPUT Example 2
|
|
|
|
|
|
Figure 4-5. pick:position
|