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 / 3D Symbol Keys.d3m < prev    next >
Encoding:
Text File  |  2003-09-29  |  8.1 KB  |  464 lines

  1. ' This macro saves 2D Projections of 3D Symbols, then
  2. ' brings them into a Symbol key with 4 rows of 5 symbols each.
  3. '
  4. ' Please follow these steps to use this program.
  5. '
  6. ' 1) Copy your symbols to a folder off the C drive
  7. '    that has 3 letters in it's name, c:\CAD for 
  8. '    example.
  9. '
  10. ' 2) Go to that directory at DOS and type:
  11. '    DIR /B >Files.txt.  This creates the ASCII text
  12. '    file containing the files to be opened.
  13. '
  14. ' 3) Copy files.txt to files2.txt, which creates the 
  15. '    file of filenames to be used.
  16. '
  17. ' 4) Create an ASCII text file called count.txt in that
  18. '    same directory that contains 20 lines, each with
  19. '    a single number on it, 1-20.
  20. '
  21. ' 5) Go to DesignCAD and setup the file locations tab
  22. '    for Drawings to read to that directory, then 
  23. '    Save as Default.
  24. '
  25. ' About Running the Program . . .
  26. ' 1) This program makes copies of each symbol in the 
  27. '    group, so make sure your directory you are working
  28. '    with is a copy of the origional, because it will
  29. '    end up being twice as large as you wanted it to be.
  30. ' 2) When prompted, please enter an output filename 
  31. '    simular to c:\1.dc to avoid confusion.  There is
  32. '    no error trapping for overwriting an existing file.
  33. '    You need large amounts of free HD space.
  34. '
  35. ' Get imput from user
  36. Start:
  37. Input "Please type the Archive Name & press Enter:", ARC$
  38. Input "Please type the Group Description & press Enter", DIS$
  39. Input "Please type the Symbol Group ID", GID$
  40. Window 10, 80
  41. Print "Archive          " + ARC$
  42. Print "Description    " + DIS$
  43. Print "Group ID        " + GID$
  44. Print ""
  45. Print "Is this correct? Y/N"
  46. Anykey F$
  47. if F$ = "n" then 
  48.     goto Start
  49. endif
  50. if F$ = "N" then
  51.     goto Start
  52. endif
  53. Count = 0
  54. ' Set's the target file to open
  55.     Root$ = Sys$(20)
  56.     File$ = Root$ + "\" + "Files.txt"
  57.     File2$ = Root$ + "\" + "Count.txt"
  58.     File3$ = Root$ + "\" + "Files2.txt"
  59. ' Opens the files
  60.     open "i", 1, File$
  61.     open "i", 4, File3$
  62. ' Loop Until End of File
  63. Back2:
  64.     open "o", 3, "c:\List.txt"
  65.     open "i", 2, File2$
  66.     do while eof(1) = 0
  67.         if Count = 20 then goto Full
  68.         Input #1, A$
  69.         Input #2, FName$
  70.     B$ = Root$ + "\" + A$
  71. ' Opens the file, Fits it to Window
  72.         >Open
  73.           {
  74.         <Filename [B$]
  75.           }
  76.         >FitToAllWindow
  77.          {
  78.           }
  79.     MinX = Sys(120)
  80.     MinY = Sys(121)
  81.     MaxX = Sys(122)
  82.     MaxY = Sys(123)
  83. ' Sets the new drawing handles for each file
  84.     >DrawingHandle
  85.     {
  86.       <PointXYZ [MinX, MinY, 0]
  87.       <PointXYZ [MaxX, MinY, 0]
  88.         }
  89. ' Saves the incremental File
  90.     FName2$ = Root$ + "\" + FName$ + A$
  91. '    Print FName2$
  92.     >SaveAs
  93.      {
  94.     '<SaveChanges 0
  95.     <Save2D 2
  96.     <FileName [FName2$]
  97.      }
  98. ' Writes Value to Third ASCII Text File
  99.     print #3, FName2$
  100. ' Closes Current Drawing File
  101.     >Close
  102.     {
  103.     <SaveChanges 0
  104.     }
  105.     Count = Count + 1
  106. ' New Section to open files twice
  107.         ' Opens the file, Fits it to Window
  108.             >Open
  109.               {
  110.             <Filename [FName2$]
  111.               }
  112.         ' Fits files to window
  113.             >FitToAllWindow
  114.              {
  115.               }
  116.         ' Get File extents
  117.             MinX = Sys(120)
  118.             MinY = Sys(121)
  119.             MaxX = Sys(122)
  120.             MaxY = Sys(123)
  121.         ' Sets the new drawing handles for each file
  122.             >DrawingHandle
  123.             {
  124.             <PointXYZ [MinX, MinY, 0]
  125.             <PointXYZ [MaxX, MinY, 0]
  126.                 }
  127.         ' Save the File
  128.             >SaveAs
  129.              {
  130.             '<SaveChanges 0
  131.             <Save2D 0
  132.             <FileName [FName2$]
  133.              }
  134.         ' Close each file again
  135.             >Close
  136.             {
  137.             <SaveChanges 0
  138.             }
  139.       loop
  140. '    close 1
  141.  
  142. Full:
  143. ' Close All open ASCII text files
  144. '    Close 1
  145.     Close 2
  146.     Close 3
  147. ' Close the Current Document and open a New One
  148.     Count = 0
  149.     >Close
  150.     {
  151.     }
  152.     >New
  153.     {
  154.     }
  155. '>2DMode
  156. '/{
  157. '/  }
  158. 'Message "Hi"
  159. ' Draws the First Box
  160.     >2DBox
  161.     {
  162.       <Color 0,0,0
  163.       <Layer 1
  164.       <LineStyle 0,2.0000,0.0000
  165.       <PointXYZ 0,0,0
  166.       <PointXYZ 4,-5,0
  167.       <Type 1
  168.       <Orientation 0
  169.     }
  170. ' Selects the Box
  171.     >PointSelect
  172.     {
  173.       <PointXYZ 0,0,0
  174.       <Type 0
  175.     }
  176. ' Makes Copies of the Box in a Row
  177.     >Array
  178.     {
  179.       <PointXYZ 4,0,0
  180.       <PointXYZ 0,-5,0
  181.       <NCopy 5,4,1
  182.       <AlongCurve 0
  183.       <Perpendicular 0
  184.     }
  185. ' Fits the drawing to the current window
  186.     >FitToWindow
  187.     {
  188.     }
  189. 'Message "Hi 2"
  190. ' Adds the 1
  191. '    >Text
  192. '    {
  193. '      <Color 0,0,0
  194. '      <Layer 1
  195. '      <PointXYZ [.3, -4, 0]
  196. '      <PointXYZ [.3, -4, 0]'
  197. '      <Style 0
  198. '      <Justification 0
  199. '      <Size .25
  200. '      <Angle 0.0000
  201. '      <Font "Arial"
  202. '    '  <Text "1"
  203. '    '  }
  204. ' Select's the 1
  205.     '>PointSelect
  206. '    {
  207. '      <PointXYZ .5, -4, 0
  208. ''>>> .3
  209. '      <Type 0
  210. '    }
  211. '' Arrays the 1
  212. '    >Array
  213. '    {
  214. '      <PointXYZ 4.3, -4, 0
  215. '      <PointXYZ .1, -9, 0
  216. '' .3
  217. '      <NCopy 5,4,1
  218. '      <AlongCurve 0
  219. '      <Perpendicular 0
  220. '    }
  221. '' Adds the 2
  222. '    >Text
  223. '    {
  224. '      <Color 0,0,0
  225. '      <Layer 1
  226. '      <PointXYZ [3.7, -4, 0]
  227. '      <PointXYZ [3.7, -4, 0]
  228. '      <Style 0
  229. '      <Justification 0
  230. '      <Size .25
  231. '      <Angle 0.0000
  232. '      <Font "Arial"
  233. '      <Text "2"
  234. '      }
  235. '' Selects the 2
  236. '    >PointSelect
  237. '    {
  238. '      <PointXYZ 4, -4, 0
  239. '' >>>3.7
  240. '      <Type 0
  241. '    }
  242. '' Arrays the 2
  243. '    >Array
  244. '    {
  245. '      <PointXYZ 7.7, -4, 0
  246. '      <PointXYZ 3, -9, 0
  247. ' 3.7
  248. '      <NCopy 5,4,1
  249. '      <AlongCurve 0
  250. '      <Perpendicular 0
  251. '    }
  252.  
  253. ' Loop for Symbols
  254.     XD = 0
  255.     YD = -5
  256.     XA = .5
  257.     YA = -4
  258.     XB = 3.5
  259.     YB = -4
  260.     Count2 = 0
  261.     open "i", 3, "c:\list.txt"
  262.     For A = 1 to 20
  263.     Count2 = Count2 + 1
  264.     Input #3, C$
  265. ' Loads the Symbol
  266.     >Merge
  267.     {
  268.       <Layer 1
  269.       <PointXYZ [XA, YA, 0]
  270.       <PointXYZ [XB, YB, 0]
  271.       <Filename [C$]
  272.       <Type 1
  273.       <Scale 0
  274.       <Reference 0
  275.     }
  276.     XA = XA + 4
  277.     XB = XB + 4
  278.     if Count2 = 5 then 
  279.         YA = YA - 5
  280.         YB = YB - 5
  281.         XA = .5
  282.         XB = 3.5
  283.     endif
  284.     if Count2 = 10 then 
  285.         YA = YA - 5
  286.         YB = YB - 5
  287.         XA = .5
  288.         XB = 3.5
  289.     endif
  290.     if Count2 = 15 then
  291.         YA = YA - 5
  292.         YB = YB - 5
  293.         XA = .5
  294.         XB = 3.5
  295.     endif
  296. ' Draws the New Line
  297.     >Line
  298.     {
  299.       <Color 0,0,0
  300.       <Layer 1
  301.       <LineStyle 0,2.0000,0.0000
  302.       <PointXYZ [XD, YD, 0]
  303.       <PointXYZ [XD + 2, YD, 0]
  304.       <PointXYZ [XD + 2, YD + .25, 0]
  305.       }
  306. ' Selects the line just drawn
  307.     >PointSelect
  308.     {
  309.       <PointXYZ [XD + 2, YD + .25, 0]
  310.       <Type 0
  311.     }
  312. ' Deletes that line
  313.     >SelectDelete
  314.     {
  315.     }
  316. ' Adds text to the box
  317.     Input #4, Z$
  318.     Chop = LEN(Z$)
  319.     Chop2 = Chop - 3
  320.     Y$ = LEFT$(Z$, Chop2)
  321.     X$ = "(" + Y$ + ")"
  322.         >Text
  323.     {
  324.       <Color 0,0,0
  325.       <Layer 1
  326.       <PointXYZ [XD + 2, YD + .25, 0]
  327.       <PointXYZ [XD + 2, YD + .25, 0]
  328.       <Style 0
  329.       <Justification 0
  330.       <Size .25
  331.       <Angle 0.0000
  332.       <Font "Arial"
  333.       <Text [X$]
  334.       }
  335.     XD = XD + 4
  336.     if Count2 = 5 then
  337.         YD = YD -5
  338.         XD = 0
  339.     endif
  340.     if Count2 = 10 then
  341.         YD = YD -5
  342.         XD = 0
  343.     endif
  344.     if Count2 = 15 then
  345.         YD = YD -5
  346.         XD = 0
  347.     endif
  348. Next a
  349. ' Draws the Top Box
  350.     >2DBox
  351.     {
  352.       <Color 0,0,0
  353.       <Layer 1
  354.       <LineStyle 0,2.0000,0.0000
  355.       <PointXYZ 0, 0, 0 
  356.       <PointXYZ 20, .5, 0
  357.       <Type 1
  358.       <Orientation 0
  359.     }
  360. ' Draws the Inner Border
  361.     >2DBox
  362.     {
  363.       <Color 0,0,0
  364.       <Layer 1
  365.       <LineStyle 0,2.0000,0.0000
  366.       <PointXYZ 0, 2, 0 
  367.       <PointXYZ 20, -20, 0
  368.       <Type 1
  369.       <Orientation 0
  370.     }
  371. ' Fits the drawing to the window
  372.     >FitToWindow
  373.     {
  374.     }
  375. ' Adds the Description
  376.     >Text
  377.     {
  378.       <Color 0,0,0
  379.       <Layer 1
  380.       <PointXYZ [21, 1, 0]
  381.       <PointXYZ [21, 1, 0]
  382.       <PointXYZ [21, 1, 0]
  383.       <Style 0
  384.       <Justification 2
  385.       <Size .25
  386.       <Angle 0.0000
  387.       <Font "Arial"
  388.       <Text [DIS$]
  389.       }
  390. ' Adds the DesignCAD
  391.     >Text
  392.     {
  393.       <Color 0,0,0
  394.       <Layer 1
  395.       <PointXYZ [.5, .75, 0]
  396.       <Style 0
  397.       <Justification 0
  398.       <Size 1
  399.       <Angle 0.0000
  400.       <Font "Arial"
  401.       <Text "DesignCAD"
  402.       }
  403. ' Draws the Outer Border
  404.     >2DBox
  405.     {
  406.       <Color 0,0,0
  407.       <Layer 1
  408.       <LineStyle 0,2.0000,0.0000
  409.       <PointXYZ -.5, 2.5, 0 
  410.       <PointXYZ 20.5, -21, 0
  411.       <Type 1
  412.       <Orientation 0
  413.     }
  414. ' Adds the Archive Filename
  415.     Name$ = "Archive Filename:  " + ARC$
  416.     >Text
  417.     {
  418.       <Color 0,0,0
  419.       <Layer 1
  420.       <PointXYZ [0, -20.75, 0]
  421.       <Style 0
  422.       <Justification 0
  423.       <Size .25
  424.       <Angle 0.0000
  425.       <Font "Arial"
  426.       <Text [Name$]
  427.       }
  428. ' Adds the Group ID
  429.     >Text
  430.     {
  431.       <Color 0,0,0
  432.       <Layer 1
  433.       <PointXYZ [20, 2.1, 0]
  434.       <Style 0
  435.       <Justification 2
  436.       <Size .25
  437.       <Angle 0.0000
  438.       <Font "Arial"
  439.       <Text [GID$]
  440.       }
  441. ' Fits the drawing to the window
  442.     >FitToWindow
  443.     {
  444.     }
  445. ' Saves the file
  446.     Input "Please enter the drawing filename . . .", FN$
  447.     >SaveAs
  448.      {
  449.     <SaveChanges 0
  450.     <FileName [FN$]
  451.      }
  452.     >Close
  453.     {
  454.     }
  455.     >New
  456.     {
  457.     }
  458. close 3
  459. Count = 0
  460. goto Back2
  461. End
  462.