home *** CD-ROM | disk | FTP | other *** search
/ Corel Draw 7 / CD7_CAD.ISO / cad / dimspl3d.csc < prev    next >
Encoding:
Text File  |  1996-10-28  |  8.1 KB  |  228 lines

  1. 'This script will demonstrate DIMENSION commands on a simple 3D object
  2.  
  3. '************************************************************************************************************
  4. '************************************************************************************************************
  5. '************************************************************************************************************
  6. '************************************************************************************************************
  7. REM ⌐ 1996 Corel Corporation. All rights reserved.
  8. '************************************************************************************************************
  9.  
  10.  
  11. declare Sub Cross(xcoo#,ycoo#,zcoo#)
  12. declare Sub DoLine(x1#,y1#,z1#,x2#,y2#,z2#)
  13.  
  14.  
  15. REM Declare Variables
  16. Global Title as string
  17.  
  18. Rem Set Variable
  19. Title$ = "CorelCAD: DIMENSIONING a simple 3D figure"
  20.  
  21. REM Declare Subroutines
  22.  
  23. WITHOBJECT "CorelCAD.Automation.1"
  24.  
  25.     REM Call A New File
  26.     .FileNew
  27.  
  28.     REM Call First Dialog
  29.  
  30.     string1$ = "This script will demonstrate the DIMENSION commands."
  31.     string2$ = "For more information on DIMENSION commands consult CorelCAD's On-line Help."
  32.     BEGIN DIALOG DispMessage1 25, 70, 316, 70,Title$
  33.         TEXT  4, 3, 310, 17, String1$
  34.         TEXT  5, 25, 310, 19, String2$
  35.         TEXT  6, 46, 310, 13, "Click NEXT to proceed or CANCEL to exit the Script."
  36.         PUSHBUTTON  198, 44, 40, 16, "Next >>>"
  37.         CANCELBUTTON  240, 44, 40, 16
  38.     END DIALOG
  39.  
  40.     Return% = DIALOG (DispMessage1)
  41.     if Return = 2 then STOP
  42.  
  43.     REM Call Second Dialog and Draw Simple 3D Figure
  44.  
  45.     string1$ = "A BOX will be created to DIMENSION."
  46.     string2$ = ""
  47.     BEGIN DIALOG DispMessage2 25, 70, 316, 70,Title$
  48.         TEXT  4, 3, 310, 17, String1$
  49.         TEXT  5, 25, 310, 19, String2$
  50.         TEXT  6, 46, 310, 13, "Click NEXT to proceed or CANCEL to exit the Script."
  51.         PUSHBUTTON  198, 44, 40, 16, "Next >>>"
  52.         CANCELBUTTON  240, 44, 40, 16
  53.     END DIALOG
  54.  
  55.     Return% = DIALOG (DispMessage2)
  56.     if Return = 2 then STOP
  57.  
  58.     REM Create Rectangular Box To Be Dimensioned 
  59.     .Box -1, -54.7076, -23.4799, 0, -49.8334, -25.674, 2.4411
  60.     .ZoomToAll 
  61.     .ZoomOut 
  62.     .ZoomOut 
  63.  
  64.     REM Call Third Dialog and Dimension One Feature of Rectangular Box
  65.     string1$ = "The length of the BOX will be DIMENSIONED using the X LINEAR DIMENSION command from the DIMENSION flyout."
  66.     string2$ =  "We will use ENDPOINT SNAP in the SNAP flyout to specify DIMENSION end-points."
  67.     BEGIN DIALOG DispMessage3 25, 70, 316, 70,Title$
  68.         TEXT  4, 3, 310, 17, String1$
  69.         TEXT  5, 25, 310, 19, String2$
  70.         TEXT  6, 46, 310, 13, "Click NEXT to proceed or CANCEL to exit the Script."
  71.         PUSHBUTTON  198, 44, 40, 16, "Next >>>"
  72.         CANCELBUTTON  240, 44, 40, 16
  73.     END DIALOG
  74.  
  75.     Return% = DIALOG (DispMessage3)
  76.     if Return = 2 then STOP
  77.     REM Script Ends When User Closes Dialog
  78.         
  79.     REM Create First Dimension 
  80.     call cross(-54.7076, -25.674, 0)
  81.     call cross(-49.8334, -25.674, 0)
  82.     call doline(-54.7076, -25.674, 0,-54.6968, -28.081, 0)
  83.     call doline(-49.8334, -25.674, 0,-49.825, -28.044, 0)
  84.     wait for 1
  85.     .undo
  86.     .undo
  87.     .SelectWithinRegion -54.4425, -27.8756, 2.4411, -53.315, -28.4935, 2.4411
  88.     .deleteselection
  89.     .SelectWithinRegion -49.5622, -27.8088, 2.4411, -48.5589, -28.378, 2.4411
  90.     .deleteselection
  91.     .DimensionLinear -1, 0, -54.7076, -25.674, 0, -49.8334, -25.674, 0, -52.0871, -28.0692, 0
  92.     .ZoomToAll
  93.     
  94.     REM Call Fourth Dialog and Dimension Width of the Rectangular Box
  95.  
  96.     string1$ = "The width will be DIMENSIONED using the Y-LINEAR DIMENSION command."
  97.     string2$ = ""
  98.     BEGIN DIALOG DispMessage4 25, 70, 316, 70,Title$
  99.         TEXT  4, 3, 310, 17, String1$
  100.         TEXT  5, 25, 310, 19, String2$
  101.         TEXT  6, 46, 310, 13, "Click NEXT to proceed or CANCEL to exit the Script."
  102.         PUSHBUTTON  198, 44, 40, 16, "Next >>>"
  103.         CANCELBUTTON  240, 44, 40, 16
  104.     END DIALOG
  105.  
  106.     Return% = DIALOG (DispMessage4)
  107.     if Return = 2 then STOP
  108.     
  109.     REM Create Second Dimension 
  110.     call cross(-49.8334, -25.674, 0)
  111.     call cross(-49.8334, -23.4799, 0)
  112.     call doline(-49.8334, -25.674, 0,-47.0714, -25.6813, 0)
  113.     call doline(-49.8334, -23.4799, 0,-47.0621, -23.5114, 0)
  114.     wait for 1
  115.     .undo
  116.     .undo
  117.     .SelectWithinRegion -49.5622, -27.8088, 2.4411, -48.5589, -28.378, 2.4411
  118.     .deleteselection
  119.     .SelectWithinRegion -49.4487, -25.4706, 2.4411, -48.5352, -26.418, 2.4411
  120.     .deleteselection
  121.     .DimensionLinear -1, 1, -49.8334, -23.4799, 0, -49.8334, -25.674, 0, -47.0955, -25.1169, 0
  122.     .ZoomToAll
  123.  
  124.     REM Call Fifth Dialog and Dimension Height of the Rectangular Box
  125.     string1$ = "The height will be DIMENSIONED using the Z-LINEAR command"
  126.     string2$ = ""
  127.     BEGIN DIALOG DispMessage5 25, 70, 316, 70,Title$
  128.         TEXT  4, 3, 310, 17, String1$
  129.         TEXT  5, 25, 310, 19, String2$
  130.         TEXT  6, 46, 310, 13, "Click NEXT to proceed or CANCEL to exit the Script."
  131.         PUSHBUTTON  198, 44, 40, 16, "Next >>>"
  132.         CANCELBUTTON  240, 44, 40, 16
  133.     END DIALOG
  134.  
  135.     Return% = DIALOG (DispMessage5)
  136.     if Return = 2 then STOP
  137.  
  138.     REM Create Third Dimension and Zoom to All
  139.     call cross(-54.7076, -23.4799, 0)
  140.     call cross(-54.7076, -23.4799, 2.4411)
  141.     call doline(-54.7076, -23.4799, 0,-56.16, -25.9342, 2.4411)
  142.     call doline(-54.7076, -23.4799, 2.4411,-56.9865, -23.4996, 2.4411)
  143.     wait for 1
  144.     .undo
  145.     .undo
  146.     .zoomout
  147.     .SelectWithinRegion -54.3776, -25.5144, 2.4411, -53.4079, -26.3908, 2.4411
  148.     .deleteselection
  149.     .SelectWithinRegion -55.2369, -23.0612, 2.4411, -53.898, -24.1741, 2.4411
  150.     .deleteselection
  151.     .DimensionLinear -1, 2, -54.7076, -23.4799, 0, -54.7076, -23.4799, 2.4411, -57.0157, -22.1567, 0
  152.     .ZoomToAll 
  153.     
  154.     string1$ = "A MATERIAL will  be applied to the BOX."
  155.     string2$ = "RENDERING may take a moment."
  156.     BEGIN DIALOG DispMessage6 25, 70, 316, 70,Title$
  157.         TEXT  4, 3, 310, 17, String1$
  158.         TEXT  5, 25, 310, 19, String2$
  159.         TEXT  6, 46, 310, 13, "Click NEXT to proceed or CANCEL to exit the Script."
  160.         PUSHBUTTON  198, 44, 40, 16, "Next >>>"
  161.         CANCELBUTTON  240, 44, 40, 16
  162.     END DIALOG
  163.  
  164.     Return% = DIALOG (DispMessage6)
  165.     if Return = 2 then STOP
  166.     .SelectWithinRegion -55.1196, -23.0698, 2.4411, -54.2263, -23.7867, 2.4411
  167.     .deleteselection    
  168.     .SelectAll
  169.     .ApplyMaterial "Woods", "Pine"    
  170.     .ShadeEntireView -1,-1,3,0
  171.  
  172.     String1$ = "There is a seperate tool to DIMENSION each axial direction. (X-LINEAR, Y-LINEAR, Z-LINEAR)."
  173.     String2$ = "The FREE DIMENSION tool in the DIMENSION flyout can be used to quickly DIMENSION any two points."
  174. beep
  175. BEGIN DIALOG DispMessage100 25, 70, 316, 75, "FINAL HINTS"
  176.     TEXT  4, 4, 310, 16, string1
  177.     TEXT  4, 19, 310, 17, string2
  178.     TEXT  42, 48, 118, 8, "Click END to finish the demonstation."
  179.     PUSHBUTTON  223, 47, 40, 16, "END"
  180. END DIALOG
  181.  
  182.     Return% = DIALOG (DispMessage100)
  183.     if Return = 2 then STOP
  184.  
  185. END WITHOBJECT
  186.  
  187. '************************************************************************************************
  188. '************************************************************************************************************
  189. '************************************************************************************************************
  190.  
  191.  
  192. SUB Cross (xcoo#,ycoo#,zcoo#)
  193. withobject "corelcad.automation.1"
  194.     .SetPointXYZ xcoo, ycoo, zcoo-.2
  195.     .SetPointXYZ xcoo, ycoo, zcoo+.2
  196.     .LineSegment 
  197.     .ChangeColor 51, 255, 102
  198.     .SetPointXYZ xcoo-.2, ycoo, zcoo
  199.     .SetPointXYZ xcoo+.2, ycoo, zcoo
  200.     .LineSegment 
  201.     .ChangeColor 0, 0, 0
  202.     .SetPointXYZ xcoo, ycoo-.2, zcoo
  203.     .SetPointXYZ xcoo, ycoo+.2, zcoo
  204.     .LineSegment 
  205.     .ChangeColor 255, 0, 0
  206.     .Box -1, xcoo-.1, ycoo-.1, zcoo-.1, xcoo+.1, ycoo+.1, zcoo+.1
  207.     .ChangeColor 0, 204, 255
  208.     .setpointxyz xcoo,ycoo,zcoo
  209.     .linesegment
  210.                 wait for 1
  211.     '.selectWithinRegion xcoo-6,ycoo-6,zcoo-6,xcoo+6,ycoo+6,zcoo+6 
  212. end withobject
  213. end sub
  214. '************************************************************************************************************
  215. SUB DoLine(x1#,y1#,z1#,x2#,y2#,z2#)
  216.     WITHOBJECT "CorelCAD.automation.1"
  217.     .NewLayer " ", , -1, 0, 0, 0, 0, 255, 0, 2, ""
  218.     .setcurrentlayer " "
  219.     .setpointxyz x1,y1,z1 
  220.     .setpointxyz x2,y2,z2
  221.     .arrowLine .5,1
  222.     .setcurrentlayer "Default Layer"
  223.     end withobject
  224. END SUB
  225. '************************************************************************************************************
  226. '************************************************************************************************************
  227.  
  228.