Convert_A_Group_To_A_Dynamo_By_Ref Method Example

The following example shows the Convert_A_Group_To_A_Dynamo_By_Ref method example using the methods in PlugandSolve – modDynamoConverter.   

Public Function ConvertADynamo(objGroup As Fix2DGroup.Fix2DGroup, 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

    Dim bProceedConvert As Boolean

    

    iDataSourceOption = g_WizardConfig.iDataSourceOption

    If g_WizardConfig.iDataSourceOption = DYNAMO_PROMPT_FOR_CHOICE Then

        If g_ReturnFromPromptForChoiceOnConvert = PROMPT_DLG_SEL_UPDATE_NO_DS_APPLY_TO_ALL Then

            iDataSourceOption = DYNAMO_UPDATE_BUT_NOT_APPLY

        ElseIf g_ReturnFromPromptForChoiceOnConvert = PROMPT_DLG_SEL_UPDATE_ATTEMPT_MATCH_APPLY_TO_ALL Then

            iDataSourceOption = DYNAMO_UPDATE_AND_APPLY

        ElseIf g_ReturnFromPromptForChoiceOnConvert = PROMPT_DLG_SEL_DO_NOT_UPDATE_APPLY_TO_ALL Then

            iDataSourceOption = DYNAMO_NOT_UPDATE

        End If

    End If

    

    ' Convert option parameters

    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

    

    ' set options (it includes update option in case)

    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 FDS Converter, set Make Master option

    If g_iDynamoToolType = DYN_FDS_CONVERTER Then

        iUpdateOptions = iUpdateOptions + CONVERT_OPTION_MAKE_MASTER

    End If

    

    ' call Update A Dynamo

    PlugandSolve.GeometryHelperObj.Convert_A_Group_To_A_Dynamo_By_Ref objGroup, iUpdateOptions, mobjStrMgr.GetNLSStr(4143), iResult

    ' get a result string

    strReturnMsg = PlugandSolve.GeometryHelperObj.Get_Last_Result_String

    

    ' don't take the last prompt for choice

    ' get the last user choice from the prompt

    'If (g_WizardConfig.iDataSourceOption = DYNAMO_PROMPT_FOR_CHOICE) And _

    '    (g_ReturnFromPromptForChoiceOnConvert = 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_ReturnFromPromptForChoiceOnConvert = iPrompt

    '    End If

    'End If

    

    ' convert result code

    If (iResult And UPDATER_RESULT_SUCCESS_BIT) > 0 Then

        ConvertADynamo = DYNAMO_UPDATED

    End If

    If (iResult And UPDATER_RESULT_DYNAMO_NOT_UPDATED_BIT) > 0 Then

        ConvertADynamo = DYNAMO_NOTUPDATED

    End If

    If (iResult And UPDATER_RESULT_USER_CANCELLED_BIT) > 0 _

        Or (iResult And UPDATER_RESULT_SUCCESS_BIT) = 0 Then

        ConvertADynamo = DYNAMO_UPDATE_ABORTED

    End If

End Function