Move a selected Item

P

PolyPusher

Guest
Hi all,

I was wondering if I could get some input(direction) on a script or
have one posted(or maybe there is an existing way) to move something
that is selected all ready on the canvas to a point without picking it
up and moving it....

or saying it another way, move a selected object to a point that the
user clicks on the canvas as input.

I hope that isn't too confusing.

Thank you in advance for your help,
PolyPusher.
 
PolyPusher wrote, on 10/01/09 20:40:
Hi all,

I was wondering if I could get some input(direction) on a script or
have one posted(or maybe there is an existing way) to move something
that is selected all ready on the canvas to a point without picking it
up and moving it....

or saying it another way, move a selected object to a point that the
user clicks on the canvas as input.

I hope that isn't too confusing.

Thank you in advance for your help,
PolyPusher.
dbMoveFig is what you want.

The following code will probably give you enough clues? You may need to fix a
couple of line wraps on the (error ...) lines.


/* abFlip.il

Author A.D.Beckett
Group Custom IC (UK), Cadence Design Systems Ltd.
Language SKILL
Date Jun 22, 2005
Modified
By

Functions to do flipping (and rotation) in place. Examples
of usage:

abFlip()
- does a flip horizontally relative to the centre of the selected figures
abFlip(?relativeTo 'lowerLeft)
- does a horizontal flip relative to the lower left corner
abFlip(?orient "MX" ?relativeTo 'upperRight)
- does a vertical flip relative to the upperRight corner
abFlip(?orient "MY" ?relativeTo 'upperRight ?mode 'copy)
- does a horizontal flipped copy relative to the upperRight corner
abFlip(?orient "R90" ?relativeTo 'refPoint)
- does a 90 degree rotation relative to the reference point (often
the + key on the numeric keypad).

In this function:

?orient can be set to:

"MY" - mirror in Y axis (i.e. horizontal flip) (default)
"MX" - mirror in X axis (i.e. vertical flip)
"R90" - 90 degree anti-clockwise rotate
"R180" - 180 degree anti-clockwise rotate
"R270" - 90 degree clockwise rotate
"R0" - no rotation (not much point!)
"MYR90" - mirror in Y axis and rotate by 90
"MXR90" - mirror in X axis and rotate by 90

?relativeTo can be set to:

'centerBox - center of selected figures (default)
'lowerLeft - lower left of selected figures
'lowerRight - lower right of selected figures
'upperLeft - upper left of selected figures
'upperRight - upper right of selected figures
'refPoint - the reference point
'origin - the cellview origin (i.e. 0:0)

?mode can be set to

'move - (the default) flip during a move
'copy - (the default) flip during a copy

?noSnap can be set to t if you don't want it to
snap the origin of the flip

abSetRefPoint(?relativeTo 'upperLeft)
- set the ref point relative to the selected objects

The ?relativeTo has the same meaning as for abFlip()

***************************************************

SCCS Info: @(#) abFlip.il 02/15/07.13:41:41 1.2

*/

/******************************************************************
* *
* (abFlip [?orient "MY"] [?relativeTo 'centerBox] *
* [?mode 'move] [?win windowId] [?noSnap nil]) *
* *
* Flips the selected objects (if any) relative to somewhere, with *
* a particular orientation. Can either copy or move. *
* For details, see the comments at the top of this file *
* *
******************************************************************/

(procedure (abFlip @key (orient "MY") (relativeTo 'centerBox)
(mode 'move) noSnap
(win (hiGetCurrentWindow)))
(let (bbox figs origin transform)
(setq figs (geGetSelSet win))
;-----------------------------------------------------------------
; work out the origin of the transform
;-----------------------------------------------------------------
(setq bbox (abFindBBox figs))
(setq origin
(case relativeTo
(centerBox (centerBox bbox))
(lowerLeft (lowerLeft bbox))
(lowerRight (list (xCoord (upperRight bbox))
(yCoord (lowerLeft bbox))))
(upperLeft (list (xCoord (lowerLeft bbox))
(yCoord (upperRight bbox))))
(upperRight (upperRight bbox))
(refPoint (leGetRefPoint (geGetEditCellView win)))
(origin (list 0 0))
(t (error "Unknown ?relativeTo mode; must be one of 'centerBox, 'lowerLeft,
'lowerRight, 'upperLeft, 'upperRight, 'refPoint, 'origin"))
))
(when origin
(unless noSnap
(setq origin
(list
(times (round (quotient
(xCoord origin)
(getq win xSnapSpacing)))
(getq win xSnapSpacing))
(times (round (quotient
(yCoord origin)
(getq win ySnapSpacing)))
(getq win ySnapSpacing))
)))
;-----------------------------------------------------------
; Combine the transform to do a shift to the origin,
; rotate/flip, and then shift back again
;-----------------------------------------------------------
(setq transform
(dbConcatTransform
(dbConcatTransform
(list (mapcar 'minus origin) "R0")
(list 0:0 orient)
)
(list origin "R0")
))
;-----------------------------------------------------------
; Then either move or copy all the figures
;-----------------------------------------------------------
(foreach fig figs
(case mode
(move
(dbMoveFig fig (dbGetq fig cellView) transform))
(copy
(dbCopyFig fig (dbGetq fig cellView) transform))
)
)
t
)
)
)

/***************************************************************
* *
* (abSetRefPoint [?relativeTo 'centerBox] [?win windowId]) *
* *
* Set the reference point relative to somewhere on the *
* selected set. *
* *
***************************************************************/

(procedure (abSetRefPoint @key (relativeTo 'centerBox)
(win (hiGetCurrentWindow)))
(let (bbox figs origin)
;-----------------------------------------------------------------
; Work out the new reference point
;-----------------------------------------------------------------
(setq figs (geGetSelSet win))
(setq bbox (abFindBBox figs))
(setq origin
(case relativeTo
(centerBox (centerBox bbox))
(lowerLeft (lowerLeft bbox))
(lowerRight (list (xCoord (upperRight bbox))
(yCoord (lowerLeft bbox))))
(upperLeft (list (xCoord (lowerLeft bbox))
(yCoord (upperRight bbox))))
(upperRight (upperRight bbox))
(refPoint (leGetRefPoint (geGetEditCellView win)))
(origin (list 0 0))
(t (error "Unknown ?relativeTo mode; must be one of 'centerBox, 'lowerLeft,
'lowerRight, 'upperLeft, 'upperRight, 'refPoint, 'origin"))
))
(when origin
(leSetRefPoint (geGetEditCellView win) origin)
)
)
)
 
On Oct 1, 4:39 pm, Andrew Beckett <andr...@DcEaLdEeTnEcTe.HcIoSm>
wrote:
PolyPusher wrote, on 10/01/09 20:40:

Hi all,

I was wondering if I could get some input(direction) on a script or
have one posted(or maybe there is an existing way) to move something
that is selected all ready on the canvas to a point without picking it
up and moving it....

or saying it another way, move a selected object to a point that the
user clicks on the canvas as input.

I hope that isn't too confusing.

Thank you in advance for your help,
PolyPusher.

dbMoveFig is what you want.

The following code will probably give you enough clues? You may need to fix a
couple of line wraps on the (error ...) lines.

/* abFlip.il

Author     A.D.Beckett
Group      Custom IC (UK), Cadence Design Systems Ltd.
Language   SKILL
Date       Jun 22, 2005
Modified
By

Functions to do flipping (and rotation) in place. Examples
of usage:

abFlip()
   - does a flip horizontally relative to the centre of the selected figures
abFlip(?relativeTo 'lowerLeft)
   - does a horizontal flip relative to the lower left corner
abFlip(?orient "MX" ?relativeTo 'upperRight)
   - does a vertical flip relative to the upperRight corner
abFlip(?orient "MY" ?relativeTo 'upperRight ?mode 'copy)
   - does a horizontal flipped copy relative to the upperRight corner
abFlip(?orient "R90" ?relativeTo 'refPoint)
   - does a 90 degree rotation relative to the reference point (often
     the + key on the numeric keypad).

In this function:

?orient can be set to:

     "MY" - mirror in Y axis (i.e. horizontal flip) (default)
     "MX" - mirror in X axis (i.e. vertical flip)
     "R90" - 90 degree anti-clockwise rotate
     "R180" - 180 degree anti-clockwise rotate
     "R270" - 90 degree clockwise rotate
     "R0" - no rotation (not much point!)
     "MYR90" - mirror in Y axis and rotate by 90
     "MXR90" - mirror in X axis and rotate by 90

?relativeTo can be set to:

'centerBox - center of selected figures (default)
'lowerLeft - lower left of selected figures
'lowerRight - lower right of selected figures
'upperLeft - upper left of selected figures
'upperRight - upper right of selected figures
'refPoint - the reference point
'origin - the cellview origin (i.e. 0:0)

?mode can be set to

'move - (the default) flip during a move
'copy - (the default) flip during a copy

?noSnap can be set to t if you don't want it to
snap the origin of the flip

abSetRefPoint(?relativeTo 'upperLeft)
   - set the ref point relative to the selected objects

The ?relativeTo has the same meaning as for abFlip()

***************************************************

SCCS Info: @(#) abFlip.il 02/15/07.13:41:41 1.2

*/

/******************************************************************
*                                                                 *
*         (abFlip [?orient "MY"] [?relativeTo 'centerBox]         *
*           [?mode 'move] [?win windowId] [?noSnap nil])          *
*                                                                 *
* Flips the selected objects (if any) relative to somewhere, with *
*       a particular orientation. Can either copy or move.        *
*      For details, see the comments at the top of this file      *
*                                                                 *
******************************************************************/

(procedure (abFlip @key (orient "MY") (relativeTo 'centerBox)
                   (mode 'move) noSnap
                   (win (hiGetCurrentWindow)))
   (let (bbox figs origin transform)
        (setq figs (geGetSelSet win))
        ;-----------------------------------------------------------------
        ; work out the origin of the transform
        ;-----------------------------------------------------------------
        (setq bbox (abFindBBox figs))
        (setq origin
             (case relativeTo
                   (centerBox (centerBox bbox))
                   (lowerLeft (lowerLeft bbox))
                   (lowerRight (list (xCoord (upperRight bbox))
                                     (yCoord (lowerLeft bbox))))
                   (upperLeft (list (xCoord (lowerLeft bbox))
                                    (yCoord (upperRight bbox))))
                   (upperRight (upperRight bbox))
                   (refPoint (leGetRefPoint (geGetEditCellView win)))
                   (origin (list 0 0))
                   (t (error "Unknown ?relativeTo mode; must be one of 'centerBox, 'lowerLeft,
'lowerRight, 'upperLeft, 'upperRight, 'refPoint, 'origin"))
                   ))
        (when origin
             (unless noSnap
                     (setq origin
                           (list
                            (times (round (quotient
                                           (xCoord origin)
                                           (getq win xSnapSpacing)))
                                   (getq win xSnapSpacing))
                            (times (round (quotient
                                           (yCoord origin)
                                           (getq win ySnapSpacing)))
                                   (getq win ySnapSpacing))
                            )))
             ;-----------------------------------------------------------
             ; Combine the transform to do a shift to the origin,
             ; rotate/flip, and then shift back again
             ;-----------------------------------------------------------
             (setq transform
                   (dbConcatTransform
                    (dbConcatTransform
                     (list (mapcar 'minus origin) "R0")
                     (list 0:0 orient)
                     )
                    (list origin "R0")
                    ))
             ;-----------------------------------------------------------
             ; Then either move or copy all the figures
             ;-----------------------------------------------------------
             (foreach fig figs
                      (case mode
                            (move
                             (dbMoveFig fig (dbGetq fig cellView) transform))
                            (copy
                             (dbCopyFig fig (dbGetq fig cellView) transform))
                            )
                      )
             t
             )
        )
   )

/***************************************************************
*                                                              *
*   (abSetRefPoint [?relativeTo 'centerBox] [?win windowId])   *
*                                                              *
*     Set the reference point relative to somewhere on the     *
*                        selected set.                         *
*                                                              *
***************************************************************/

(procedure (abSetRefPoint @key (relativeTo 'centerBox)
                   (win (hiGetCurrentWindow)))
   (let (bbox figs origin)
        ;-----------------------------------------------------------------
        ; Work out the new reference point
        ;-----------------------------------------------------------------
        (setq figs (geGetSelSet win))
        (setq bbox (abFindBBox figs))
        (setq origin
             (case relativeTo
                   (centerBox (centerBox bbox))
                   (lowerLeft (lowerLeft bbox))
                   (lowerRight (list (xCoord (upperRight bbox))
                                     (yCoord (lowerLeft bbox))))
                   (upperLeft (list (xCoord (lowerLeft bbox))
                                    (yCoord (upperRight bbox))))
                   (upperRight (upperRight bbox))
                   (refPoint (leGetRefPoint (geGetEditCellView win)))
                   (origin (list 0 0))
                   (t (error "Unknown ?relativeTo mode; must be one of 'centerBox, 'lowerLeft,
'lowerRight, 'upperLeft, 'upperRight, 'refPoint, 'origin"))
                   ))
        (when origin
             (leSetRefPoint (geGetEditCellView win) origin)
             )
        )
   )
Wow. This is great! Your code looks like artwork.

Yes, I think I can get from here. If not, I will call you ;-)

Thank you,
PolyPusher
 

Welcome to EDABoard.com

Sponsor

Back
Top