Hi.
I have defined a function which can accept different strings. This function will do differents works when different strings is passed. So I defined to commands.
<CommandMethod("AddOne")> _
Public Sub AddOne()
'' Get the current database and start the Transaction Manager
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim pPtRes As PromptPointResult
Dim pPtOpts As PromptPointOptions = New PromptPointOptions("")
pPtOpts.Message = vbLf & "Select the insert point:"
pPtRes = acDoc.Editor.GetPoint(pPtOpts)
Dim ptStart As Point3d = pPtRes.Value
'' Exit if the user presses ESC or cancels the command
If pPtRes.Status = PromptStatus.Cancel Then Exit Sub
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
AddMasonry(ptStart, "1") 'This is the function I need to pass in different parameters
acTrans.Commit()
End Using
End Sub
'The second command,just the parameter is different, all the other codes are the same?
<CommandMethod("AddTwo")> _
Public Sub AddTwo()
'' Get the current database and start the Transaction Manager
Dim acDoc As Document = Application.DocumentManager.MdiActiveDocument
Dim acCurDb As Database = acDoc.Database
Dim pPtRes As PromptPointResult
Dim pPtOpts As PromptPointOptions = New PromptPointOptions("")
pPtOpts.Message = vbLf & "Select the insert point:"
pPtRes = acDoc.Editor.GetPoint(pPtOpts)
Dim ptStart As Point3d = pPtRes.Value
'' Exit if the user presses ESC or cancels the command
If pPtRes.Status = PromptStatus.Cancel Then Exit Sub
'' Start a transaction
Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
AddMasonry(ptStart, "2") 'The only difference is "2" is here, not the "1".
acTrans.Commit()
End Using
End Sub
So, I question is can I pass the parameter to the function in one command.