下列代码提供了Update_A_Dynamo_By_Ref方法的一个示例,该方法出现在 Project_PlugandSolve VBA工程的modDynamoUpdater模块中。
Public Function UpdateADynamo2(objDynamoInstance As Fix2DDynamo.Fix2DDynamo, objMasterDynamo As Fix2DDynamo.Fix2DDynamo, ByRef strReturnMsg) As UpdateDynamoResult
Dim strDIName As String
Dim strDMName As String
Dim iDataSourceOption As DynamoDataSourceOption
Dim iResult As Long 'UpdateDynamoResult
Dim iPrompt As Long
Dim iUpdateOptions As Long ' update options
iDataSourceOption = g_WizardConfig.iDataSourceOption
If g_WizardConfig.iDataSourceOption = DYNAMO_PROMPT_FOR_CHOICE Then
If g_ReturnFromPromptForChoice = PROMPT_DLG_SEL_UPDATE_NO_DS_APPLY_TO_ALL Then
iDataSourceOption = DYNAMO_UPDATE_BUT_NOT_APPLY
ElseIf g_ReturnFromPromptForChoice = PROMPT_DLG_SEL_UPDATE_ATTEMPT_MATCH_APPLY_TO_ALL Then
iDataSourceOption = DYNAMO_UPDATE_AND_APPLY
ElseIf g_ReturnFromPromptForChoice = PROMPT_DLG_SEL_DO_NOT_UPDATE_APPLY_TO_ALL Then
iDataSourceOption = DYNAMO_NOT_UPDATE
End If
End If
' 转换选项参数
iUpdateOptions = &H0
If iDataSourceOption = DYNAMO_PROMPT_FOR_CHOICE Then
iUpdateOptions = UPDATE_OPTION_ON_MISMATCH_PROMT_FOR_CHOICE
ElseIf iDataSourceOption = DYNAMO_UPDATE_AND_APPLY Then
iUpdateOptions = UPDATE_OPTION_ON_MISMATCH_UPDATE_DYNAMO + UPDATE_OPTION_ON_MISMATCH_APPLY_DATA_SOURCES
ElseIf iDataSourceOption = DYNAMO_UPDATE_BUT_NOT_APPLY Then
iUpdateOptions = UPDATE_OPTION_ON_MISMATCH_UPDATE_DYNAMO
End If
If g_WizardConfig.bKeepSize = True Then
iUpdateOptions = iUpdateOptions + UPDATE_OPTION_RESIZE_INSTANCE
End If
If g_WizardConfig.bKeepCaption = True Then
iUpdateOptions = iUpdateOptions + UPDATE_OPTION_SAVE_CAPTIONS
End If
'如果图符实例转换则新增选项
If g_iDynamoToolType = DYN_QUICK_CONVERTER Or _
g_iDynamoToolType = DYN_CONVERTER_WIZARD Then
iUpdateOptions = iUpdateOptions + UPDATE_OPTION_UPDATE_ON_CONVERSION
End If
'调用“更新图符”
PlugandSolve.GeometryHelperObj.Update_A_Dynamo_By_Ref2 objMasterDynamo, objDynamoInstance, iUpdateOptions, mobjStrMgr.GetNLSStr(4069), iResult
'获取结果串
strReturnMsg = PlugandSolve.GeometryHelperObj.Get_Last_Result_String
'从提示获取最后一个用户选择
If (g_WizardConfig.iDataSourceOption = DYNAMO_PROMPT_FOR_CHOICE) And _
(g_ReturnFromPromptForChoice = PROMPT_DLG_SEL_NONE) Then
iPrompt = PlugandSolve.GeometryHelperObj.Get_Last_Prompt_Value
If (iPrompt = PROMPT_DLG_SEL_UPDATE_NO_DS_APPLY_TO_ALL) Or _
(iPrompt = PROMPT_DLG_SEL_UPDATE_ATTEMPT_MATCH_APPLY_TO_ALL) Or _
(iPrompt = PROMPT_DLG_SEL_DO_NOT_UPDATE_APPLY_TO_ALL) Then
g_ReturnFromPromptForChoice = iPrompt
End If
End If
'////// 实际更新调用结束
' If iResult <= DYNAMO_UPDATED Then
' UpdateADynamo = DYNAMO_UPDATED
' ElseIf iResult <= DYNAMO_NOTUPDATED Then
' UpdateADynamo = DYNAMO_NOTUPDATED
' Else
' UpdateADynamo = DYNAMO_UPDATE_ABORTED
' End If
If (iResult And UPDATER_RESULT_SUCCESS_BIT) > 0 Then
UpdateADynamo2 = DYNAMO_UPDATED
End If
If (iResult And UPDATER_RESULT_DYNAMO_NOT_UPDATED_BIT) > 0 Then
UpdateADynamo2 = DYNAMO_NOTUPDATED
End If
If (iResult And UPDATER_RESULT_USER_CANCELLED_BIT) > 0 _
Or (iResult And UPDATER_RESULT_SUCCESS_BIT) = 0 Then
UpdateADynamo2 = DYNAMO_UPDATE_ABORTED
End If
End Function
如需在上下文中查看这一代码:
- 在经典视图中,从工作台菜单选择“Visual Basic编辑器”。
- 或 -
在 Ribbon 视图中,单击主页选项卡上工作台组中的“Visual Basic Editor”。
- 在树状图中,双击Project_PlugandSolve文件夹,然后Modules文件夹,最后modDynamoUpdater。
- 搜索UpdateADynamo以找到这一代码。