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

  1. 'This script will demonstrate DIMENSION commands on a simple 2D 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. REM Declare Variables
  15. Global Title as string
  16.  
  17. Rem Set Variable
  18. Title$ = "CorelCAD: DIMENSIONING a simple 2D figure"
  19.  
  20. REM Declare Subroutines
  21.  
  22. WITHOBJECT "CorelCAD.Automation.1"
  23.  
  24.     REM Call A New File
  25.     .FileNew
  26.  
  27.     REM Call First Dialog
  28.     string1$ = "This script will demonstrate DIMENSION commands."
  29.     string2$ = "For more information on DIMENSION commands consult CorelCAD's On-line Help."
  30.     BEGIN DIALOG DispMessage1 25, 70, 316, 75, Title$
  31.         TEXT  4, 4, 310, 18, String1$
  32.         TEXT  4, 20, 310, 18, String2$
  33.         TEXT  4, 46, 170, 8, "Click NEXT to proceed or CANCEL to exit the Script."
  34.         PUSHBUTTON  192, 44, 40, 16, "Next >>>"
  35.         CANCELBUTTON  240, 44, 40, 16
  36.     END DIALOG
  37.  
  38.     Return% = DIALOG (DispMessage1)
  39.     if Return = 2 then STOP
  40.     
  41.  
  42.     REM Call Second Dialog and Create Drawing
  43.  
  44.     string1$ = "A model will be created to be DIMENSIONED."
  45.     string2$ = ""
  46.     BEGIN DIALOG DispMessage2 25, 70, 316, 75, Title$
  47.         TEXT  4, 4, 310, 18, String1$
  48.         TEXT  4, 20, 310, 18, String2$
  49.         TEXT  4, 46, 170, 8, "Click NEXT to proceed or CANCEL to exit the Script."
  50.         PUSHBUTTON  192, 44, 40, 16, "Next >>>"
  51.         CANCELBUTTON  240, 44, 40, 16
  52.     END DIALOG
  53.  
  54.     Return% = DIALOG (DispMessage2)
  55.     if Return = 2 then STOP
  56.  
  57.  
  58.     REM Open Figure 1
  59.     .Rectangle -1, -44.8403, -9.555, 0, -37.9971, -19.6866, 0
  60.     .CircleRadius -1, -41.4187, -9.555, 0, -44.8403, -9.555, 0
  61.     .SetPointXYZ -44.278, -7.94593, 0
  62.     .SetPointXYZ -44.8384, -13.7966, 0
  63.     .SolidAdd 
  64.     .ZoomToAll 
  65.     .ZoomOut 
  66.     .ZoomOut 
  67.  
  68.     REM Call Third Dialog and Create First Dimension
  69.  
  70.     string1$ = "The Y-axis direction will be DIMENSIONED using the Y LINEAR DIMENSION command from the DIMENSION flyout."
  71.     string2$ = ""
  72.     BEGIN DIALOG DispMessage3 25, 70, 316, 75, Title$
  73.         TEXT  4, 4, 310, 18, String1$
  74.         TEXT  4, 20, 310, 18, String2$
  75.         TEXT  4, 46, 170, 8, "Click NEXT to proceed or CANCEL to exit the Script."
  76.         PUSHBUTTON  192, 44, 40, 16, "Next >>>"
  77.         CANCELBUTTON  240, 44, 40, 16
  78.     END DIALOG
  79.  
  80.     Return% = DIALOG (DispMessage3)
  81.     if Return = 2 then STOP
  82.  
  83.     call cross(-44.8403, -19.6866, 0)
  84.     call cross(-44.8403, -9.555, 0)
  85.     call doline(-44.8403, -19.6866, 0,-54.1157, -19.6422, 0)
  86.     call doline(-44.8403, -9.555, 0,-54.0904, -9.60367, 0)
  87.     wait for 1
  88.     .undo
  89.     .undo
  90.     .SelectWithinRegion -45.4022, -19.2249, 0, -44.1248, -19.9982, 0
  91.     .deleteselection
  92.     .SelectWithinRegion -45.6399, -8.90094, 0, -44.2192, -10.2531, 0
  93.     .deleteselection
  94.     
  95.     .DimensionLinear -1, 1, -44.8403, -19.6866, 0, -44.8403, -9.555, 0, -54.1103, -7.87136, 0
  96.     .ZoomToAll
  97.     
  98.     REM Call Fourth Dialog and Dimension Width of the Rectangular Box
  99.  
  100.     string1$ = "The width of the model will be DIMENSIONED using the X-LINEAR DIMENSION command."
  101.     string2$ = ""
  102.     BEGIN DIALOG DispMessage4 25, 70, 316, 75, Title$
  103.         TEXT  4, 4, 310, 18, String1$
  104.         TEXT  4, 20, 310, 18, String2$
  105.         TEXT  4, 46, 170, 8, "Click NEXT to proceed or CANCEL to exit the Script."
  106.         PUSHBUTTON  192, 44, 40, 16, "Next >>>"
  107.         CANCELBUTTON  240, 44, 40, 16
  108.     END DIALOG
  109.  
  110.     Return% = DIALOG (DispMessage4)
  111.     if Return = 2 then STOP
  112.  
  113.     call cross(-44.8403, -19.6866, 0)
  114.     call cross(-37.9971, -19.6866, 0)
  115.     .zoomout
  116.     .zoomout
  117.  
  118.     call doline(-44.8403, -19.6866, 0,-44.8293, -27.4212, -0.1)
  119.     call doline(-37.9971, -19.6866, 0,-38.0717, -27.4201, -0.1)
  120.     
  121.     wait for 1
  122.     .undo
  123.     .undo
  124.     .SelectWithinRegion -45.4022, -19.2249, 0, -44.1248, -19.9982, 0
  125.     .deleteselection
  126.     .SelectWithinRegion -38.805, -19.1323, -0.1, -37.1064, -20.7837, -0.1
  127.     .deleteselection
  128.  
  129.     .DimensionLinear -1, 0, -44.8403, -19.6866, 0, -37.9971, -19.6866, 0, -37.3229, -27.4534, 0
  130.     .ZoomToAll
  131.  
  132.     REM Call Fifth Dialog and Dimension Height of the Rectangular Box
  133.  
  134.     string1$ = "The semicircle will be DIMENSIONED using the RADIUS DIMENSION command."
  135.     string2$ = ""
  136.     BEGIN DIALOG DispMessage5 25, 70, 316, 75, Title$
  137.         TEXT  4, 4, 310, 18, String1$
  138.         TEXT  4, 20, 310, 18, String2$
  139.         TEXT  4, 46, 170, 8, "Click NEXT to proceed or CANCEL to exit the Script."
  140.         PUSHBUTTON  192, 44, 40, 16, "Next >>>"
  141.         CANCELBUTTON  240, 44, 40, 16
  142.     END DIALOG
  143.  
  144.     Return% = DIALOG (DispMessage5)
  145.     if Return = 2 then STOP
  146.  
  147.  
  148.     call cross(-39.5863, -6.61537, 0)
  149.     call doline(-41.4187, -9.555, 0,-39.5863, -6.61537, 0)
  150.     call doline(-39.5863, -6.61537, 0,-34.0096, -6.60939, 0)
  151.     wait for 1
  152.     .undo
  153.     .undo
  154.     .SelectWithinRegion -40.9769, -5.45742, 0, -37.6525, -8.3711, 0
  155.     .deleteselection
  156.     
  157.     .DimensionRadius -1, -39.5615, -6.6813, 0, -35.0279, -6.65849, 0
  158.     .ZoomToAll 
  159.  
  160.     string1$ = "A MATERIAL will now be applied to the object."
  161.     string2$ = "RENDERING may take a moment."    
  162.     BEGIN DIALOG DispMessage6 25, 70, 316, 75, Title$
  163.         TEXT  4, 4, 310, 18, String1$
  164.         TEXT  4, 20, 310, 18, String2$
  165.         TEXT  4, 46, 170, 8, "Click NEXT to proceed or CANCEL to exit the Script."
  166.         PUSHBUTTON  192, 44, 40, 16, "Next >>>"
  167.         CANCELBUTTON  240, 44, 40, 16
  168.     END DIALOG
  169.  
  170.     Return% = DIALOG (DispMessage6)
  171.     if Return = 2 then STOP
  172.  
  173.     .SelectAll
  174.     .ApplyMaterial "Others","Insulation"
  175.     .ShadeEntireView -1,-1,3,0
  176.     
  177.     String1$ = "When DIMENSIONING circular objects, select the the feature to be dimensioned and the placement of the dimension text."
  178.     String2$ = "CorelCAD locates the center of the object to be dimensioned."
  179. beep
  180.     BEGIN DIALOG DispMessage100 25, 70, 316, 75, "FINAL HINTS"
  181.         TEXT  4, 4, 310, 18, String1$
  182.         TEXT  4, 25, 310, 18, String2$
  183.         TEXT  42, 48, 118, 8, "Click END to finish the demonstation."
  184.         PUSHBUTTON  223, 47, 40, 16, "END"
  185.     END DIALOG
  186.  
  187.     Return% = DIALOG (DispMessage100)
  188.     if Return = 2 then STOP
  189.  
  190. END WITHOBJECT
  191.  
  192. '************************************************************************************************
  193. '************************************************************************************************************
  194. '************************************************************************************************************
  195.  
  196.  
  197. SUB Cross (xcoo#,ycoo#,zcoo#)
  198. withobject "corelcad.automation.1"
  199.     .SetPointXYZ xcoo, ycoo, zcoo-.2
  200.     .SetPointXYZ xcoo, ycoo, zcoo+.2
  201.     .LineSegment 
  202.     .ChangeColor 51, 255, 102
  203.     .SetPointXYZ xcoo-.2, ycoo, zcoo
  204.     .SetPointXYZ xcoo+.2, ycoo, zcoo
  205.     .LineSegment 
  206.     .ChangeColor 0, 0, 0
  207.     .SetPointXYZ xcoo, ycoo-.2, zcoo
  208.     .SetPointXYZ xcoo, ycoo+.2, zcoo
  209.     .LineSegment 
  210.     .ChangeColor 255, 0, 0
  211.     .Box -1, xcoo-.1, ycoo-.1, zcoo-.1, xcoo+.1, ycoo+.1, zcoo+.1
  212.     .ChangeColor 0, 204, 255
  213.     .setpointxyz xcoo,ycoo,zcoo
  214.     .linesegment
  215.                 wait for 1
  216.     '.selectWithinRegion xcoo-6,ycoo-6,zcoo-6,xcoo+6,ycoo+6,zcoo+6 
  217. end withobject
  218. end sub
  219. '************************************************************************************************************
  220. SUB DoLine(x1#,y1#,z1#,x2#,y2#,z2#)
  221.     WITHOBJECT "CorelCAD.automation.1"
  222.     .NewLayer " ", , -1, 0, 0, 0, 0, 255, 0, 2, ""
  223.     .setcurrentlayer " "
  224.     .setpointxyz x1,y1,z1 
  225.     .setpointxyz x2,y2,z2
  226.     .arrowLine .5,1
  227.     .setcurrentlayer "Default Layer"
  228.     end withobject
  229. END SUB
  230. '************************************************************************************************************
  231. '************************************************************************************************************
  232.  
  233.