Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4331

[CONNECT 10.14 VBA] Trying implement old Macro written for 5.7...

$
0
0

We are using CONNECT now, and a user has requested some functionality that existed with the 5.7 edition of MicroStation.  The macro was created in 1999 by someone who has since retired.  I copied/pasted the macro and attempted to run in CONNECT and received the error 'Compile error: Constant expression required'.  Seems to have hung up on line 2 at 'Chr$'.

I figured it was a longshot to expect this to work and wondering if its easier starting from scratch rather than massaging this to work.  The intent of the macro is to open a picklist to select a particular scale, have a fence drawn at selected scale, click an area in the drawing and print to default printer, loop back to selected fence scale to print again.  Perhaps there is now a better way to do this.  I'm new to MicroStation. The user in question has only asked to print at 1=40 so simply creating a fence at 40 scale would probably be sufficient. 

The macro is pasted below, any feedback/guidance/direction at all whatsoever would be greatly appreciated. 

Thanks,

Scott


'prompt user for scale,place fence block,allow user to move,send to printer
'plotgis.bas
' - prompt for accpetance, send to printer.
'12/15/99

Const CANCEL = ""
Const LF = Chr$(10)

Sub main
Dim Point As MbePoint
dim view%
dim which as string

' Start a command
MbeSendCommand "DIALOG VIEWSETTINGS "

' Set a variable associated with a dialog box
MbeSetAppVariable "MGDSHOOK", "msDialogState.viewSettingsP->flags.text_nodes", 0&

MbeSendCommand"dmsg closedialog -46"


Dim elemSet As New MbeElementSet
Dim ok As String
Dim prompt As String

' have user select scale from dialog box
Dim a$(1 to 10)
Dim whichOne As Integer
a$(1) = "1 """+" = 10 '"
a$(2) = "1 """+" = 20 '"
a$(3) = "1 """+" = 30 '"
a$(4) = "1 """+" = 40 '"
a$(5) = "1 """+" = 60 '"
a$(6) = "1 """+" = 80 '"
a$(7) = "1 """+" = 100 '"
a$(8) = "1 """+" = 200 '"
a$(9) = "1 """+" = 500 '"
a$(10) = "1 """+" = 1000 '"
whichOne = MbeSelectBox ("Select Scale for plot:", a$, "Plotting Dialog")
answer$ = "The item selected was " + str$(whichOne) + "."
'which=whichOne
'MbeMessageBox a(whichone)
if whichone < 0 then goto exitsub
MbeMessageBox "Then place data point in view, use data point to move fence to desired location "

' Start a command
MbeSendCommand "place fence block "

' Coordinates are in master units
' between here
' and here

MbeGetInput MBE_DataPointInput, MBE_ResetInput
if MbeState.inputType= MBE_ResetInput then goto exitsub
'end if
status = MbeState.getInputDataPoint(point, view)

' Send a data point to the current command
point.x = Point.x
point.y = Point.y
point.z = Point.z
MbeSendDataPoint point, 1%

' goto selected scale coord val's
if whichOne=1% then goto one
if whichone=2% then goto two
if whichone=3% then goto three
if whichone=4% then goto four
if whichone=5% then goto five
if whichone=6% then goto six
if whichone=7% then goto seven
if whichone=8% then goto eight
if whichone=9% then goto nine
if whichone=10% then goto ten



' these coords are for scale of 1-10
one:
point.x = Point.x - 80.400000#
point.y = Point.y + 101.80000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

two:
' these coords for fence at 1-20
point.x = Point.x - 160.800000#
point.y = Point.y + 203.600000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

three:
' these coords for fence at 1-30
point.x = Point.x - 241.200000#
point.y = Point.y + 305.400000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

four:
' these coords are for scale of 1-40
point.x = Point.x - 321.595200#
point.y = Point.y + 407.284800#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

five:
' these coords are for scale of 1-60
point.x = Point.x - 482.400000#
point.y = Point.y + 608.800000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

six:
' these coords are for scale of 1-80
point.x = Point.x - 643.194000#
point.y = Point.y + 814.569600#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

seven:
' these coords are for scale of 1-100
point.x = Point.x - 804.000000#
point.y = Point.y + 1014.00000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

eight:
' these coords are for scale of 1-200
point.x = Point.x - 1608.000000#
point.y = Point.y + 2036.000000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

nine:
' these coords are for scale of 1-500
point.x = Point.x - 4000.000000#
point.y = Point.y + 5000.000000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

ten:
' these coords are for scale of 1-1000
point.x = Point.x - 8000.000000#
point.y = Point.y + 10040.00000#
point.z = Point.z
MbeSendDataPoint point, 1%
goto done

Done:
'MbeSendCommand " move fence "
'MbeSendCommand "plot border comment bla ha"
MbeSendkeyin "plot border comment Scale is " +a(whichOne)
'text$= "plot border comment " +a(whichOne)
'stat = MbeMessageBox ("string is " +text$, MBE_OKCancelBox or MBE_WarningIcon)
' MbeMessageBox "Is this where you want the fence ? "


plot:
ok = "NO"
prompt = "Is this where you want the fence ?" + LF + _
"Enter 'NO' to move fence" + LF + _
"or Hit CANCEL to Quit"

If elemSet.fromFence() = MBE_Success Then

ok = MbeInputBox(prompt,"YES","FENCE")

End If

While ok <> "YES" AND ok <> CANCEL

MbeSendCommand "MOVE FENCE "

MbeGetInput MBE_DataPointInput
MbeSendLastInput

MbeGetInput MBE_DataPointInput
MbeSendLastInput

ok = MbeInputBox(prompt,"YES","FENCE")

wend

If ok = "YES" Then
MbeMessageBox "Processing fence"
MbeSendkeyin "plot border comment Scale is " +a(whichOne)
MbeSendcommand "plot fence"
MbeSendReset
MbeSendCommand "Null"
GOTO EXITSUB
Else
MbeMessageBox "Command Cancelled"
MbeSendReset
MbeSendCommand "Null"
MbeSendCommand "PLACE FENCE "
MbeSendKeyin "Null"
End If



ExitSub:
Mbewriteprompt "Command Completed"
End Sub


Viewing all articles
Browse latest Browse all 4331

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>