home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2003 November / PCWK1103B.iso / DesignCAD 3D Max PLUS trial 30 / DATA1.CAB / Example_Files / Sample_Macros / 600_3_InfoS.d3m < prev    next >
Encoding:
Text File  |  2003-09-29  |  8.6 KB  |  453 lines

  1. ' This is the third macro in the 600 series, which creates the
  2. ' large material boxes. 
  3. '
  4. ' Get Values from data file.
  5. '
  6. ' Based on RType chosen by user above
  7.         open "i", 1, "*\sample macros\600.txt"
  8. ' Assign #s found to Variables
  9.     Input #1, AddLen
  10.     Input #1, TH
  11.     Input #1, PanNum2
  12.     Input #1, PanNum
  13. ' Close File
  14.     Close #1
  15. '
  16. ' Routine to Calculate values for Large Info Boxes
  17.   Calc1:
  18.       ' Calculate and display MTee
  19.         Precision 2    
  20.         MTeeN = Area1 * 0.286
  21.         MTeeC = MTeeN / 25
  22.         MTeeN2 = ROUND(MTeeN)
  23.         ' MTeeC2 = ROUND(MTeeC)
  24.         MTemp = MTeeC + .5
  25.         MTeeC2 = ROUND(MTemp)
  26.         '
  27.     ' Calculate and display 1.2CN
  28.         CN12 = Area1 * 1.65
  29.         CNC12 = CN12 / 75
  30.         ' CN122 = CN12
  31.         CN122 = ROUND(CN12)
  32.         '  CNC122 = CNC12
  33.         CTemp = CNC12 + .5
  34.         CNC122 = ROUND(CTemp)
  35.         '
  36.     ' Calculate and display 1.6CN
  37.         CN6 = Area1 * 1.61
  38.         CN6C = CN6 / 75
  39.           CN62 = ROUND(CN6)
  40.         ' CN62 = ROUND(CN6)
  41.          ' CN6C2 = CN6C
  42.         C6Temp = CN6C + .5
  43.         CN6C2 = ROUND(C6Temp)
  44.         '
  45.     ' Calculate and display ST Fix
  46.         STFix = Area1 * 0.765
  47.         STFixC = STFix / 100
  48.         STFixD = STFixC + .5
  49.         STFixC = ROUND(STFixD)
  50.                 STFixC2 = STFixC
  51.         STFix2 = ROUND(STFix)
  52.     ' Calculate and display Rods T
  53.         RodsT = Area1 * 0.765
  54.         RodsTC = RodsT / 100
  55.         RodsTD = RodsTC + .5
  56.         RodsTC = ROUND(RodsTD)
  57.         RodsTC2 = RodsTC
  58.         RodsT2 = RodsT
  59.     ' Calculate and display Rods B
  60.         RodsB = Area1 * 0.765
  61.         RodsBC = RodsB / 100
  62.         RodsBD = RodsBC + .5
  63.         RodsBC = ROUND(RodsBD)
  64.         ' RodsBC2 = RodsBC
  65.         RodsB2 = RodsB
  66.     ' Calculate and display Channel
  67.     ' Apply Channel Adjustment from Earlier
  68.         Chan = Chan + AddLen
  69.         Chan = Len1 / 3
  70.         Chan2 = ROUND(Chan)
  71.         Chan2C = Chan2 / 24
  72.         'ChTemp = Chan2C + .5
  73.         'Chan2C = ROUND(ChTemp)
  74.     ' Resolve Panel Choice for the user
  75.         Panel = .36
  76.     ' Calculate and display Panels
  77.         Ar = Area1 * 0.065
  78.         Pan1 = Area1 + Ar
  79.         Pan2 = Pan1 / Panel
  80.         Pan3 = Pan2
  81.         Precision 2
  82.     ' Apply Panel Reduction
  83.         Pan3 = Pan3 - PanNum2    
  84.         Precision 2
  85.         PTemp = Pan3 + .05
  86.     '    Pan3 = ROUND(PTemp)
  87.         '
  88. ' Routine to make smaller info box if area is less than or equal to 46 sm
  89.   Small:
  90. ' Create New File
  91.     >New
  92.     {
  93.     }
  94.     ' Silent Mode On
  95.         Sys(36) = 1
  96.     '
  97.     ' Make Layer 11 the current layer
  98.         Layer(11) = 14
  99.     '
  100.     ' Create String Variables for Text Block
  101.     ' Variables in the No. Column need to be integers only
  102.         Precision 0
  103.         MTeeN2$ = MTeeN2
  104.         CNC122$ = CN122
  105.         CN62$ = CN62
  106.         STFix2$ = STFix2
  107.         RodsT2$ = RodsT2
  108.         RodsB2$ = RodsB2
  109.         Chan2$ = Chan2
  110.     ' Variables in the CTS column need one place precision
  111.         Precision 1
  112. ' Straight Unmodified Variables
  113.         MTeeC2$ = MTeeC
  114.         CN122$ = CNC12
  115.         CN6C2$ = CN6C
  116.         STFixC2$ = STFixC
  117.         RodsTC2$ = RodsTC
  118.         RodsBC2$ = RodsBC
  119.         Chan2C$ = Chan2C
  120.         Pan3$ = Pan3
  121. ' Rounded Variables
  122. '        MTeeC2$ = MTeeC2
  123. '        CN122$ = CNC122
  124. '        CN6C2$ = CN6C2
  125. '        STFixC2$ = STFixC2
  126. '        RodsTC2$ = RodsTC2
  127. '        RodsBC2$ = RodsBC2
  128. '        Chan2C$ = Chan2C
  129. '        Pan3$ = Pan3
  130.  
  131.     ' Prompt user for text height
  132.     '    Sys$(41) = "Text Height . . ."
  133.     '    Input "Enter the Text Height for the Info Box . . . (Enter = 1)", TH
  134.     ' Check for Exit Condition on Input box
  135.     '    if Sys(999) = 1 then 
  136.     '        Message "Program Stopped by User."
  137.     '        End
  138.     '    endif
  139. ' Check for valid entries
  140.     'if TH = 0 then TH = 1
  141. ' Rem this back in if text sizes under 1 become a problem
  142.     ' if TH < 1 then TH = 1
  143. ' Half Text height
  144.     HTH = TH / 2
  145. ' Set Spacing for all text blocks at 1, DO NOT CHANGE THIS !!
  146.     SP = 1
  147. ' Get Old Text Height
  148.     OLDTH = Sys(12)
  149. ' Set new Text height
  150.     Sys(12) = TH
  151.     Six = 1
  152.     if Six = 1 then
  153.     ' Text Block with 0.6
  154.         >TextBlock
  155.         {
  156.         <Style 0
  157.         <Distance [SP]
  158.         <TextBegin
  159.         <Text "   "
  160.         <Text " T  "
  161.         <Text "1.2 "
  162.         <Text "0.6 "
  163.         <Text "Fix "
  164.         <Text "T R "
  165.         <Text "B R "
  166.         <Text "Ch "
  167.         <justification 1    
  168.         <pointxyz 0, 0, 0    
  169.         }
  170.     else
  171.     ' Text Block without 0.6
  172.         >TextBlock
  173.         {
  174.         <Distance [SP]
  175.         <TextBegin
  176.         <Text "   "
  177.         <Text " T  "
  178.         <Text "1.2 "
  179.         <Text "    "
  180.         <Text "Fix "
  181.         <Text "T R "
  182.         <Text "B R "
  183.         <Text "Ch "
  184.         <justification 1
  185.         <pointxyz 0, 0, 0
  186.         }
  187.     end if
  188.     ' Set Color to Red
  189.         Sys(300) = 255
  190.         Sys(301) = 0
  191.         Sys(302) = 0
  192.     '
  193. ' Draw Number Column Values
  194.     if Six = 1 then
  195.     ' Text Block with 0.6
  196.         >TextBlock
  197.         {
  198.         <Distance [SP]
  199.         <TextBegin
  200.         <Text "   "
  201.         <Text [MTeeN2$]
  202.         <Text [CNC122$]
  203.         <Text [CN62$]
  204.         <Text [STFix2$]
  205.         <Text [RodsT2$]
  206.         <Text [RodsB2$]
  207.         <Text [Chan2$]
  208.         <justification 1
  209.         <pointxyz [HTH * 8], 0, 0
  210.         }
  211.     else
  212.     ' Text block without 0.6
  213.         >TextBlock
  214.         {
  215.         <Distance [SP]
  216.         <TextBegin
  217.         <Text "   "
  218.         <Text [MTeeN2$]
  219.         <Text [CNC122$]
  220.         <Text "   "
  221.         <Text [STFix2$]
  222.         <Text [RodsT2$]
  223.         <Text [RodsB2$]
  224.         <Text [Chan2$]
  225.         <justification 1
  226.         <pointxyz [HTH * 8], 0, 0
  227.         }
  228.     end if
  229.     ' Set Color back to normal
  230.         Sys(300) = ccRed
  231.         Sys(301) = ccGreen
  232.         Sys(302) = ccBlue
  233.     '
  234.     ' Text Title Block for Ref
  235.         >TextBlock
  236.         {
  237.         <Distance [SP]
  238.         <Style 0
  239.         <TextBegin
  240.         <Text "Ref"
  241.         <justification 1    
  242.         <pointxyz 0, 0, 0    
  243.         }
  244.     ' Text Block for No
  245.         >TextBlock
  246.         {
  247.         <Distance [SP]
  248.         <TextBegin
  249.         <Style 0
  250.         <Text "no"
  251.         <justification 1
  252.         <pointxyz [HTH * 8], 0, 0
  253.         }
  254. ' Set Current Line Type to Zero
  255.     Sys(6) = 0
  256.     '
  257. '
  258. ' Draw Title Block Box
  259.     >Box
  260.     {
  261.     <Pointxyz [-TH*2], [TH/2], 0
  262.     <Pointrel [TH*8], [-TH*2], 0
  263.     }
  264. '
  265. ' Draw First 3 value Box
  266.     >Box
  267.     {
  268.     <Pointxyz [-TH*2], [-TH*1.5], 0
  269.     <Pointrel [TH*8], [-TH*6], 0
  270.     }
  271. '
  272. ' Update Current Y Value 
  273.     CurY = TH*1.5
  274.     CurY = CurY + TH*6
  275. '
  276. ' Draw second 3 value Box
  277.     >Box
  278.     {
  279.     <Pointxyz [-TH*2], [-CurY], 0
  280.     <Pointrel [TH*8], [-TH*6], 0
  281.     }
  282.     '
  283. ' Update Current Y Value
  284.     CurY = CurY + TH*6
  285. '
  286. ' Draw Channel Box
  287.     >Box
  288.     {
  289.     <Pointxyz [-TH*2], [-CurY], 0
  290.     <Pointrel [TH*8], [-TH*2], 0
  291.     }
  292. '
  293. ' Update Current Y Value
  294.     CurY = CurY + TH*2
  295. '
  296. ' Draw Left Column Line
  297.     >Line
  298.     {
  299.     <Pointxyz [TH*2], [TH/2], 0
  300.     <Pointxyz [TH*2], [-CurY], 0
  301.     }
  302. '
  303. ' Draw Right Column Line
  304.     >Line
  305.     {
  306.     <Pointxyz [TH*6], [TH/2], 0
  307.     <Pointxyz [TH*6], [-CurY], 0
  308.     }
  309. ' Divide by however many the user says are in a carton
  310.     NewNum = Pan3 / PanNum
  311. ' Round the Result up since we need the next full carton
  312. '    Precision 1
  313. '    NewNum$ = NewNum
  314. '    a$ = RIGHT$(NewNum, 1)
  315. '    if a$ = "0" then goto Done3
  316. '    Precision 0
  317. '    NewNum2 = NewNum
  318. '    NewNum = NewNum2 + 1
  319. ' EEE
  320. Done3:
  321.     Precision 1
  322.     NewNum3 = NewNum
  323.     NewNum2$ = NewNum3,"cts"
  324.     Precision 2
  325. ' Select Object when Created is on
  326.     Sys(242) = 1
  327. '
  328. ' Print Panels at info box bottom
  329.     >Text2D
  330.     {
  331.     <justification 1
  332.     <size [TH]
  333.     <text "Panels"
  334.     <angle 0
  335.     <Pointxyz 0, [-CurY-TH*2], 0
  336.     }
  337. ' Select Object when Created is off
  338.     Sys(242) = 0
  339. ' Get Current Max X values to place labled behind the text values
  340.     M = Sys(198)
  341.     M = M + 1
  342.     N = TH * 4 + M
  343. ' Set Color to Red
  344.     Sys(300) = 255
  345.     Sys(301) = 0
  346.     Sys(302) = 0
  347. ' Add Carton # and cts
  348.     >Text2D
  349.     {
  350.     <justification 0
  351.     <size [TH]
  352.     <text [NewNum2$]
  353.     <angle 0
  354.     <Pointxyz [M], [-CurY-TH*2], 0
  355.     }
  356. ' Reset Color
  357.     Sys(300) = ccRed
  358.     Sys(301) = ccGreen
  359.     Sys(302) = ccBlue
  360.     '
  361. '
  362. ' Select All
  363.         >SelectAll
  364.         {
  365.         }
  366.     ' Copy Area Box back into main drawing
  367.                 >Copy
  368.                 {
  369.                 }
  370.             '
  371.             ' Close Temp Drawing
  372.                 >Close
  373.                 {
  374.                 <SaveChanges 0
  375.                 }
  376.             ' Refresh the Screen
  377.                 >Regenerate
  378.                 {
  379.                 }
  380.             ' Back to Layer 11
  381.                 Layer(11) = 14
  382.                 '
  383.             ' Paste the info box in again
  384.                 >Paste
  385.                 {
  386.                 <Type 0
  387.                 ' 0 = Changeable scale (based on distance between handles 1 and 2); 1 = Fixed scale (always paste at original size)
  388.                 <SelectOnly 0
  389.                 ' 
  390.                 ' 0 = select the pasted object; 1 = leave the pasted object unselected
  391.                 <pointxyz 0,0,0
  392.                 }
  393.                 '
  394.             ' Select Layer 11
  395.                 >SelectLayer
  396.                 {    
  397.                 <Layer 11
  398.                 }
  399.             ' Get Min and Max of the current Selection
  400.                 MinX = Sys(196) 
  401.                 MinY = Sys(197) 
  402.                 MaxX = Sys(198) 
  403.                 MaxY = Sys(199) 
  404.             ' Set Handle
  405.                 >SetHandle
  406.                 {
  407.                 <pointxyz [MinX,MinY],0
  408.                 <pointxyz [MaxX,MinY],0
  409.                 }
  410.     ' Loop for Moving Box from Layer 11 to the LLay layer
  411.         for a = 1 to Sys(9)
  412.             getattr a, type, select, laynum, group, red, green, blue
  413.             if laynum = 11 then laynum = 10
  414.                 Putattr a, type, select, laynum, group, red, green, blue
  415.             next a
  416.     LLay = 10
  417.     if LLay = 10 then
  418.     ' Make Layer 10 Current and name it
  419.         Layer(10) = 14
  420.         Sys$(93) = "6x6 Material Boxes"
  421.     else
  422.     ' Make Layer 14 Current and name it
  423.         Layer(14) = 14
  424.         Sys$(93) = "Master Info Box"
  425.     endif
  426.     ' Silent Mode Off
  427.         Sys(36) = 0
  428.     '
  429.     ' Refresh the Screen
  430.         >Regenerate
  431.         {
  432.         }
  433.     '
  434.     ' Move the Box
  435.         >Move
  436.         {
  437.         <Type 0
  438.         }
  439.     '
  440.     ' Refresh the Screen
  441.         >Regenerate
  442.         {
  443.         }
  444.     '
  445.     ' Deselect the Box after it's been placed
  446.         >PointSelect
  447.         {
  448.         <Type 0
  449.         <pointxyz -100, -100, 100
  450.         }
  451.     ' Return to previous Current Layer
  452.         Sys(3) = CurLay
  453.     '