VB Scripting for Dynamos

We have decided to start using HCD graphics at our site and use the frsModules_Theme dynamo set.  I am creating my first custom dynamo to have a similar look as these dynamos.  I created my form, wrote my scripts, tested it and FAIL.  I have two questions about the VB scripting behind my form:

1.  The Edit script behind my dynamo has frmDyn.Open to open my form, but this only works if the form is on the current display.  I obviously don't want to have the form on every graphic.  How do I open the form if I store it in the User global file?

2. Below is a part of my UserForm_Active script.  I do not know how to set Objdynamo to the current dynamo object so it gives me an error when my form opens - "Object variable or With block variable not set".  So, my question is, how do I set Objdynamo equal to the current dynamo?

Dim objTest As Object

'Get Friendly Name
Set objTest = Nothing
Set objTest = findlocalobject(Objdynamo, "ps_FriendlyName")
If Not objTest Is Nothing Then
    FriendlyName.EditText = objTest.CurrentValue
End If

Thanks for any help,

Kevin

  • Kevin,

    Typically, a subroutine in a User.fxg module would open a form, also stored in User.fxg. In the example below, frmMyDynamoForm would be the name of your custom form. The subroutine passes the selected dynamo object to the form. The form would need to have objDynamo declared as a public global object (Public objdynamo As Object). Then you can pass the current dynamo object to the form and retrieve properties to populate your form, using the "if not objTest is Nothing" code you have above.


    Public Sub EditMyDynamo(objdynamo As Object)

    On Error GoTo ErrorHandler

    Dim frmDyn As New frmMyDynamoForm
    If Not frmDyn Is Nothing Then
    Set frmDyn.objdynamo = objdynamo
    frrDyn.Show
    Unload frmDyn
    Set frmDyn = Nothing
    End If

    Exit Sub

    ErrorHandler:
    frsHandleError

    End Sub


    The _Edit script of the dynamo object itself ("dynMyDynamo1" in the example below) would look like:


    Private Sub dynMyDynamo1_Edit()
    On Error GoTo ErrHandler
    EditMyDynamo dynMyDynamo1
    Exit Sub
    ErrHandler:
    frsHandleError
    End Sub