home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Raytracing / Raytracer / LW5VT09.LHA / Toaster / Arexx_examples / PlugIns / ModifyRefMove.lwm < prev    next >
Encoding:
Text File  |  1996-06-10  |  9.1 KB  |  254 lines

  1. /* CMD: ½ModifyRefMove                                                  */
  2. /* By Brett Evan Hester      13032 Copenhill Rd. Dallas, Tx. 75240-5302 */
  3.     MacrosName = "ModifyRefMove"
  4. /* Macro Type:                                                          */
  5. /* MODIFIES    * OBJECTS   * BKG NEEDED   * SELECTED     * REMEMBERS    */
  6. /* Description:                                                         */
  7.  
  8. Info1A = "!Modify Reference Move ©       Information 1 of 2"
  9. Info1B = ""
  10. Info1C = "@This macro moves the ENTIRE layer. Based upon a "
  11. Info1D = "@single point. The point can be positioned in    "
  12. Info1E = "@relationship to the Current or Bkg. Layer.      "
  13. Info1F = ""
  14. Info1G = 'þ "·" Moves the point to custom coordinates.    '
  15. Info1H = "  Dflt. Coords. are those of the selected point."
  16. Info1I = "þ CURRENT L. moves the entire layer in relation "
  17. Info1J = "  to itself.                                    "
  18. Info1K = "þ BKG LAYER positioning works by moving the sel."
  19. Info1L = "  pnt. to a certain location and bringing all   "
  20. Info1M = "  the other points along.                       "
  21. Info1N = 'þ "X" Does NOT move the object on that axis.    '
  22.  
  23. Info2A = "!Modify Reference Move ©       Information 2 of 2"
  24. Info2B = "@               Plug-Ins and Go! ©               "
  25. Info2C = "                           Hester and associates"
  26. Info2D = "                           13032 Copenhill Road "
  27. Info2E = "                           Dallas, Texas 75240  "
  28. Info2F = "@Special Thanks to:                              "
  29. Info2G = "Arnie Cachelin  Henry Ribron    Mark J. Holland "
  30. Info2H = "J. Phil Kelso   Terry Wester    Steven K. Simms "
  31. Info2I = "Kevin DeRita    Greg Glaser     William S. Hawes"
  32. Info2J = "NewTek ©        Commodore ©     INOVAtronics ©  "
  33. Info2K = ""
  34. Info2L = "@This macro represents a lot of time & hard work."
  35. Info2M = "@Encourage people to create new ones and not kill"
  36. Info2N = "@that possibility by stealing those that are out."
  37.  
  38. /* -------------------------------------------------------------------- */
  39.                                      /* Start Error Detection (See End) */
  40. SIGNAL ON ERROR
  41. SIGNAL ON SYNTAX
  42.                                                    /* Address LightWave */
  43. VT3DLib = ADDLIB("LWModelerARexx.port",0)
  44. ADDRESS "LWModelerARexx.port"
  45.  
  46. /* -------------------------------------------------------------------- */
  47.                             /* Verify only one pnt sel. and get coords. */
  48. CALL Sel_Mode(USER)
  49.  
  50. N = XFrm_Begin()
  51.  
  52. IF N ~= 1 THEN DO
  53.     ReqA = "!Sorry!"
  54.     ReqB = "@Exactly one point must be selected."
  55.     ReqC = "That point will be used as a reference"
  56.     ReqD = "for moving the entire layer."
  57.     CALL Notify(1,ReqA,ReqB,ReqC,ReqD)
  58.     CALL Exiting
  59. END
  60.  
  61. PARSE value XFrm_GetPos(1) with PntX PntY PntZ .
  62.  
  63. CALL XFrm_End()
  64.  
  65. /* -------------------------------------------------------------------- */
  66.                                     /* Reading Global Macro Preferences */
  67. BEHDefaultFilePath = "Sys:"
  68. BEHSettingsSavedTo = "T:"
  69. BEHSpeechAndSound = "1"
  70.  
  71. IF (EXISTS("S:PlugInPrefs")) THEN DO
  72.     IF (~OPEN(PlugInPrefs, "S:PlugInPrefs", 'R')) THEN BREAK
  73.     IF (READLN(PlugInPrefs) ~= "PlugInPrefs") THEN BREAK
  74.     BEHDefaultFilePath = READLN(PlugInPrefs)
  75.     BEHSettingsSavedTo = READLN(PlugInPrefs)
  76.     BEHSpeechAndSound = READLN(PlugInPrefs)
  77.     CALL CLOSE PlugInPrefs
  78. END
  79.  
  80. /* -------------------------------------------------------------------- */
  81.                                             /* Recalling Macro Settings */
  82. ReqOptX = 1    ; ReqOptY = 1    ; ReqOptZ = 1
  83. ReqPntX = PntX ; ReqPntY = PntY ; ReqPntZ = PntZ
  84.  
  85. PrefsFileName = BEHSettingsSavedTo||MacrosName||".PLUG"
  86.  
  87. IF (EXISTS(PrefsFileName)) THEN DO
  88.     IF (~OPEN(PrefsFile, PrefsFileName, 'R')) THEN BREAK
  89.     IF (READLN(PrefsFile) ~= MacrosName) THEN BREAK
  90.  
  91.     PARSE value READLN(PrefsFile) with ReqOptX ReqOptY ReqOptZ .
  92.  
  93.     CALL CLOSE PrefsFile
  94. END
  95.  
  96. /* ******************************************************************** */
  97.                                                    /* Main Body Of Code */
  98. CALL MenuRequester
  99. CALL SaveSettings
  100. CALL Calculations
  101. CALL Sel_Mode(GLOBAL) ; CALL Move(PosX PosY PosZ)
  102. CALL Exiting
  103.  
  104. /* ******************************************************************** */
  105.                                                       /* User Interface */
  106. MenuRequester:
  107.  
  108.     CALL Req_Begin("Modify Reference Move ©                                by Brett Hester")
  109.  
  110.     CALL Req_AddControl("þ",'T',"Move selected point to:")
  111.     CALL Req_AddControl("-",'T',"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
  112.     CALL Req_AddControl(" ",'T',"   |       Current Layer's        |      Background Layer's      |   ")
  113.     CALL Req_AddControl(" ",'T',"   | - Negative        Positive + | - Negative        Positive + |   ")
  114.     ReqA = Req_AddControl("X",'CH',"· Left Edge Center RightEdge Left Edge Center RightEdge X")
  115.     ReqB = Req_AddControl("Y",'CH',"· LowerEdge Center UpperEdge LowerEdge Center UpperEdge X")
  116.     ReqC = Req_AddControl("Z",'CH',"· FrontEdge Center Back Edge FrontEdge Center Back Edge X")
  117.     ReqD = Req_AddControl("",'V',"1")
  118.     CALL Req_AddControl("-",'T',"- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
  119.     ReqE = Req_AddControl("¤",'CH',"Information")
  120.  
  121.     CALL Req_SetVal(ReqA, ReqOptX)
  122.     CALL Req_SetVal(ReqB, ReqOptY)
  123.     CALL Req_SetVal(ReqC, ReqOptZ)
  124.     CALL Req_SetVal(ReqD, ReqPntX ReqPntY ReqPntZ)
  125.     CALL Req_SetVal(ReqE, 0)
  126.  
  127.     OKorCancel = Req_Post() ; IF OKorCancel = 0 THEN CALL Exiting
  128.  
  129.     ReqOptX = Req_GetVal(ReqA)
  130.     ReqOptY = Req_GetVal(ReqB)
  131.     ReqOptZ = Req_GetVal(ReqC)
  132.     ReqPnt = Req_GetVal(ReqD)
  133.     BEHInfo = Req_GetVal(ReqE)
  134.  
  135.     PARSE var ReqPnt ReqPntX ReqPntY ReqPntZ
  136.  
  137.     CALL Req_End()
  138.  
  139.     IF BEHInfo = 1 THEN CALL InformationWindows
  140.  
  141. RETURN
  142.  
  143. /* -------------------------------------------------------------------- */
  144.                                                         /* Calculations */
  145. Calculations:
  146.  
  147.     CL = CurLayer() ; CBox = BoundingBox(CL)
  148.     PARSE var CBox CN CX1 CX2 CY1 CY2 CZ1 CZ2
  149.     CXC = (CX1/2)+(CX2/2) ; CYC = (CY1/2)+(CY2/2) ; CZC = (CZ1/2)+(CZ2/2)
  150.  
  151.     BL = CurBLayer() ; BBox = BoundingBox(BL)
  152.     PARSE var BBox BN BX1 BX2 BY1 BY2 BZ1 BZ2
  153.     BXC = (BX1/2)+(BX2/2) ; BYC = (BY1/2)+(BY2/2) ; BZC = (BZ1/2)+(BZ2/2)
  154.  
  155.     IF ReqOptX = 1 THEN PosX = ReqPntX - PntX
  156.     IF ReqOptX = 2 THEN PosX = CX1 - PntX
  157.     IF ReqOptX = 3 THEN PosX = CXC - PntX
  158.     IF ReqOptX = 4 THEN PosX = CX2 - PntX
  159.     IF ReqOptX = 5 THEN PosX = BX1 - PntX
  160.     IF ReqOptX = 6 THEN PosX = BXC - PntX
  161.     IF ReqOptX = 7 THEN PosX = BX2 - PntX
  162.     IF ReqOptX = 8 THEN PosX = 0
  163.  
  164.     IF ReqOptY = 1 THEN PosY = ReqPntY - PntY
  165.     IF ReqOptY = 2 THEN PosY = CY1 - PntY
  166.     IF ReqOptY = 3 THEN PosY = CYC - PntY
  167.     IF ReqOptY = 4 THEN PosY = CY2 - PntY
  168.     IF ReqOptY = 5 THEN PosY = BY1 - PntY
  169.     IF ReqOptY = 6 THEN PosY = BYC - PntY
  170.     IF ReqOptY = 7 THEN PosY = BY2 - PntY
  171.     IF ReqOptY = 8 THEN PosY = 0
  172.  
  173.     IF ReqOptZ = 1 THEN PosZ = ReqPntZ - PntZ
  174.     IF ReqOptZ = 2 THEN PosZ = CZ1 - PntZ
  175.     IF ReqOptZ = 3 THEN PosZ = CZC - PntZ
  176.     IF ReqOptZ = 4 THEN PosZ = CZ2 - PntZ
  177.     IF ReqOptZ = 5 THEN PosZ = BZ1 - PntZ
  178.     IF ReqOptZ = 6 THEN PosZ = BZC - PntZ
  179.     IF ReqOptZ = 7 THEN PosZ = BZ2 - PntZ
  180.     IF ReqOptZ = 8 THEN PosZ = 0
  181.  
  182. RETURN
  183.  
  184. /* -------------------------------------------------------------------- */
  185.                                             /* Recording Macro Settings */
  186. SaveSettings:
  187.  
  188.     IF (OPEN(PrefsFile, PrefsFileName, 'W')) THEN DO
  189.         CALL WRITELN(PrefsFile, MacrosName)
  190.  
  191.         CALL WRITELN(PrefsFile, ReqOptX ReqOptY ReqOptZ)
  192.  
  193.         CALL CLOSE PrefsFile
  194.     END
  195.  
  196. RETURN
  197.  
  198. /* -------------------------------------------------------------------- */
  199.                                                               /* Ending */
  200. Exiting:
  201.  
  202.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  203.     EXIT
  204.  
  205. RETURN
  206.  
  207. /* -------------------------------------------------------------------- */
  208.                                                  /* Information Windows */
  209. InformationWindows:
  210.  
  211.     OKorCancel = Notify(2, Info1A, Info1B, Info1C, Info1D, Info1E, Info1F, Info1G, Info1H, Info1I, Info1J, Info1K, Info1L, Info1M, Info1N)
  212.     IF OKorCancel = 1 THEN CALL Notify(1, Info2A, Info2B, Info2C, Info2D, Info2E, Info2F, Info2G, Info2H, Info2I, Info2J, Info2K, Info2L, Info2M, Info2N)
  213.     CALL MenuRequester
  214.  
  215. RETURN
  216.  
  217. /* -------------------------------------------------------------------- */
  218.                                                       /* Error Handling */
  219. SYNTAX:
  220. ERROR:
  221.  
  222.     ErrCode = RC
  223.     ErrLine = SIGL
  224.     ErrInfo = ERRORTEXT(ErrCode)
  225.  
  226.     Err1 = "!Sorry!"
  227.     Err2 = "An Error has been detected"
  228.     Err3 = "@þ Macro -            "
  229.     Err4 = "@þ Line Number -      "
  230.     Err5 = "@þ Error Code -       "
  231.     Err6 = "@þ Error Description -"
  232.     Err7 = "@¤ Please Inform -    "
  233.     Err8 = '  "Error Notice"     '
  234.     Err9 = "  13032 Copenhill Rd."
  235.     Err10 = "  Dallas, TX. 75240  "
  236.  
  237.     Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10)
  238.  
  239. /* -------------------------------------------------------------------- */
  240.                                              /* Advanced Error Handling */
  241.     CALL SETCLIP("ErrorMacro",MacrosName)
  242.     CALL SETCLIP("ErrorLine",ErrLine)
  243.     CALL SETCLIP("ErrorCode",ErrCode)
  244.     CALL SETCLIP("ErrorDesc",ErrInfo)
  245.  
  246.     PARSE SOURCE TempA TempB ErrFile TempC TempD TempE
  247.  
  248.     CALL SETCLIP("ErrorFile",ErrFile)
  249.  
  250. /* -------------------------------------------------------------------- */
  251.  
  252.     IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port")
  253.     EXIT
  254.