/* CMD: ½AutoMove                                                       */
/* By Brett Evan Hester      13032 Copenhill Rd. Dallas, Tx. 75240-5302 */
	MacrosName = "AutoMove"
/* Macro Type:                                                          */
/* MODIFIES    * OBJECTS   * BKG NEEDED   * SELECTED                    */
/* Description:                                                         */

/*        "Auto Move ©                                     "            */
/*        "This macro moves the currently selected to the  "            */
/*        "center of the background layer. Using the center"            */
/*        "of the current layer as a base point.           "            */

/*        "Special Thanks to:                              "            */
/*        "Arnie Cachelin  Henry Ribron    Mark J. Holland "            */
/*        "J. Phil Kelso   Terry Wester    Steven K. Simms "            */
/*        "Kevin DeRita    Greg Glaser     William S. Hawes"            */
/*        "NewTek ©        Commodore ©     INOVAtronics ©  "            */

/*        "This macro represents a lot of time & hard work."            */
/*        "Encourage people to create new ones and not kill"            */
/*        "that possibility by stealing those that are out."            */

/* -------------------------------------------------------------------- */
                                     /* Start Error Detection (See End) */
SIGNAL ON ERROR
SIGNAL ON SYNTAX
                                                   /* Address LightWave */
VT3DLib = ADDLIB("LWModelerARexx.port",0)
ADDRESS "LWModelerARexx.port"

/* ******************************************************************** */
                                                   /* Main Body of Code */
CALL Sel_Mode(USER)

CL = CurLayer() ; BL = CurBlayer()

PARSE VALUE BoundingBox(BL) WITH BN BX1 BX2 BY1 BY2 BZ1 BZ2
PARSE VALUE BoundingBox(CL) WITH CN CX1 CX2 CY1 CY2 CZ1 CZ2

BXC = (BX1/2)+(BX2/2) ; BYC = (BY1/2)+(BY2/2) ; BZC = (BZ1/2)+(BZ2/2)
CXC = (CX1/2)+(CX2/2) ; CYC = (CY1/2)+(CY2/2) ; CZC = (CZ1/2)+(CZ2/2)

XDIF = BXC - CXC      ; YDIF = BYC - CYC      ; ZDIF = BZC - CZC

/* ******************************************************************** */
                                                      /* User Interface */
ReqA = "!- -- --- Plug Ins: Auto Move © --- -- -"
ReqB = "@by Brett Hester"
ReqC = ""
ReqD = "!- -- --- Object Moved --- -- -"
ReqE = "@the amount moved is -"
ReqF = XDIF " " YDIF " " ZDIF
ReqG = "@the new center is -"
ReqH = CXC " " CYC " " CZC

IF Notify(2,ReqA,ReqB,ReqC,ReqD,ReqE,ReqF,ReqG,ReqH) = 1 THEN CALL Move(XDIF YDIF ZDIF)

/* -------------------------------------------------------------------- */
                                                              /* Ending */
IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
EXIT

/* -------------------------------------------------------------------- */
                                                      /* Error Handling */
SYNTAX:
ERROR:

	ErrCode = RC
	ErrLine = SIGL
	ErrInfo = ERRORTEXT(ErrCode)

	Err1 = "!Sorry!"
	Err2 = "An Error has been detected"
	Err3 = "@þ Macro -            "
	Err4 = "@þ Line Number -      "
	Err5 = "@þ Error Code -       "
	Err6 = "@þ Error Description -"
	Err7 = "@¤ Please Inform -    "
	Err8 = '  "Error Notice"     '
	Err9 = "  13032 Copenhill Rd."
	Err10 = "  Dallas, TX. 75240  "

	Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10)

/* -------------------------------------------------------------------- */
                                             /* Advanced Error Handling */
	CALL SETCLIP("ErrorMacro",MacrosName)
	CALL SETCLIP("ErrorLine",ErrLine)
	CALL SETCLIP("ErrorCode",ErrCode)
	CALL SETCLIP("ErrorDesc",ErrInfo)

	PARSE SOURCE TempA TempB ErrFile TempC TempD TempE

	CALL SETCLIP("ErrorFile",ErrFile)

/* -------------------------------------------------------------------- */

	IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
	EXIT
