home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 January / Chip_1997-01_cd.bin / ms95 / disk22 / dir04 / f000710.re_ / f000710.re
Text File  |  1996-04-02  |  5KB  |  131 lines

  1. ' BASIC macro which allows the user to place patterned blocks. 
  2. '--------------------------------------------------------------------
  3. '
  4. '  Copyright (1995) Bentley Systems, Inc., All rights reserved.
  5. '
  6. '   $Workfile:   demo.bas  $
  7. '   $Revision:   6.3  $
  8. '       $Date:   08 Dec 1995 14:47:38  $
  9. '
  10. '  "MicroStation" is a registered trademark of Bentley Systems, Inc. 
  11. '
  12. '  Limited permission is hereby granted to reproduce and modify this
  13. '  copyrighted material provided that the resulting code is used only
  14. '  in conjunction with Bentley Systems products under the terms of the
  15. '  license agreement provided therein, and that this notice is retained
  16. '  in its entirety in any such reproduction or modification.
  17. '
  18. '--------------------------------------------------------------------
  19. '   Notes:
  20. '   This example requires the cell library SAMPLE2.CEL from the
  21. '   \ustation\wsmod\default\cell\ subdirectory.  If the macro does
  22. '   not find this file, then an error is reported.
  23. '
  24. '---------------------------------------------------------------
  25. '
  26. ' Main Entry point
  27. '
  28. '---------------------------------------------------------------
  29. Sub main
  30.     Dim startPoint As MbePoint
  31.     Dim endPoint as MbePoint
  32.     Dim status%
  33.     Dim view%
  34.     Dim endOfFilePos as Long
  35.     Dim button As Integer
  36.     Dim fullCellFileName As String
  37.     Dim cmdString As String
  38.  
  39.     ' check if the cell library exists
  40.     If MbeFindFile (fullCellFileName, "SAMPLE2", "MS_CELL", ".cel") <> MBE_Success Then
  41.         button = mbeMessageBox ("Unable to find required cell library SAMPLE2.CEL in MS_CELL configuration variable",_
  42.                     MBE_OKBox or MBE_CriticalIcon)
  43.         Exit Sub
  44.     End If
  45.  
  46.     cmdString = "attach library " + fullCellFileName
  47.     ' Attach the correct cell library
  48.     MbeSendKeyin cmdString
  49.     
  50.     ' continue placing patterned blocks until a RESET is entered
  51.  
  52.     Do
  53.         '   Locate the end of file.  This file position is
  54.     '   assumed to be the position of the block that
  55.     '   will be added to the file.
  56.         endOfFilePos = MbeDgnInfo.endOfFile
  57.  
  58.         '   Start the PLACE BLOCK command
  59.         MbeSendCommand "PLACE BLOCK ICON "
  60.  
  61.         '   Wait for a data point or a reset
  62.         MbeGetInput MBE_DataPointInput, MBE_ResetInput
  63.  
  64.         '   if a reset was entered, exit the loop
  65.         if MbeState.inputType = MBE_ResetInput then Exit Do
  66.  
  67.         '   Extract the data point coordinates and view
  68.         status = MbeState.getInputDataPoint (startPoint,view)
  69.  
  70.         '   Send a data point to the current command
  71.         MbeSendDataPoint startPoint, view
  72.  
  73.         '   Wait for a data point or a reset
  74.         MbeGetInput MBE_DataPointInput, MBE_ResetInput
  75.  
  76.         '   if a reset was entered, exit the loop
  77.         if MbeState.inputType = MBE_ResetInput then Exit Do
  78.  
  79.         '   Extract the data point coordinates and view
  80.         status = MbeState.getInputDataPoint (endPoint,view)
  81.  
  82.         '   Send Data point and View to active command
  83.         MbeSendDataPoint endPoint, view
  84.  
  85.         '   Send command pattern area
  86.         MbeSendCommand "PATTERN AREA ICON "
  87.  
  88.         ' When a command brings up a modal dialog,
  89.         ' a later statement must close the dialog,
  90.         ' or the MbeState.modalDialogByUser property
  91.         ' should be set to 1 so that the user must close
  92.         ' the dialog when the macro is executed.
  93.     '
  94.     ' In this case, the PATTERN AREA ICON command
  95.     ' may open an alert box stating that a
  96.     ' large number of patterns will be placed and
  97.     ' the user is given the chance to cancel the
  98.     ' operation.  This macro needs to have the user
  99.     ' handle that alert box, since this
  100.     ' macro does not handle this event.  This is done
  101.     ' by setting the modalDialogByUser property of
  102.     ' the State object to TRUE (1)
  103.         MbeState.modalDialogByUser = 1
  104.  
  105.         '   Set the active patternCell to cell from Library
  106.         MbeSettings.patternCell = "DECID"
  107.  
  108.         '   Locate the element at the file position stored in
  109.     '   the endOfFilePos variable.  This file position was
  110.     '   stored BEFORE the place block command was executed and
  111.     '   is the file position of the block.
  112.         '   This locate causes a datapoint to be sent to the 
  113.     '   active command which is "pattern area" to select
  114.     '   the element.
  115.         MbeLocateElement(endOfFilePos)
  116.     
  117.         '   Send a datapoint to confirm the selected element
  118.         MbeSendDataPoint startPoint, view
  119.  
  120.         ' Set the MbeState.modalDialogByUser value to zero so that
  121.     ' the user does not have to respond to a modal dialog box
  122.     ' that may open.
  123.     ' Note: Be sure to set this value to a known state since
  124.     ' its setting will affect other macros as long as the BASIC
  125.     ' environment is running.
  126.         MbeState.modalDialogByUser = 0
  127.  
  128.     Loop
  129.  
  130. End Sub
  131.