hexagon logo

How to grab current alignment name with VB?

Within PC-DMIS, we can hard code an assignment to make a variable's value to be a text string of the name of the current alignment, like so:
ASSIGN/VARIABLE1=GETSETTING("Current Alignment")


However, I have a need to obtain with VB the name of the current alignment at the point in the program where the cursor is when I run a button-launched BAS script.

I just want the name as a text string so that when I automate adding Constructed 3D Lines (made from current coord sys axis) their names include the alignment name. Right now they come in with the name X_AXIS_ALIGNMENT_EDIT and I have to (ugh) manually edit them. Ain't nobody got time for that.

Nothing I try in VB works, the GETTEXT, GETCOMMAND, GETSETTING etc string handlers are not valid VB commands ha ha.

I'm thinking I do not know how to dig deep enough, that I'm missing some string functions that VB can easily grab.

Any ideas?
Parents
  • I'm fairly new but if I understand the question, this works on my end as long it is executed from a button.
    '==========================================================
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object

    Function GetAlignmentUpToNow (GAUTN_ID As String, GAUTN_TYPE As Integer) As String
    Dim GAUTN_OBJ As Object
    Dim ReturnValue As String
    ReturnValue="STARTUP"
    For Each GAUTN_OBJ In DmisCommands
    If GAUTN_OBJ.ID=GAUTN_ID And GAUTN_OBJ.Type = GAUTN_TYPE Then Exit for
    If GAUTN_OBJ.Type=1 Then
    ReturnValue=GAUTN_OBJ.ID
    End if

    Next GAUTN_OBJ
    GetAlignmentUpToNow=ReturnValue
    End Function

    Sub Main ()


    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    'Set DOFCmd As DmisCommands.CurrentCommand
    MsgBox GetAlignmentUpToNow ( DmisCommands.CurrentCommand.ID , DmisCommands.CurrentCommand.Type)

    Set DmisApp = Nothing
    Set DmisPart = Nothing
    Set DmisCommands = Nothing
    End Sub
    '==========================================================
    Hope it helps


    This works great - thank you!
Reply
  • I'm fairly new but if I understand the question, this works on my end as long it is executed from a button.
    '==========================================================
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object

    Function GetAlignmentUpToNow (GAUTN_ID As String, GAUTN_TYPE As Integer) As String
    Dim GAUTN_OBJ As Object
    Dim ReturnValue As String
    ReturnValue="STARTUP"
    For Each GAUTN_OBJ In DmisCommands
    If GAUTN_OBJ.ID=GAUTN_ID And GAUTN_OBJ.Type = GAUTN_TYPE Then Exit for
    If GAUTN_OBJ.Type=1 Then
    ReturnValue=GAUTN_OBJ.ID
    End if

    Next GAUTN_OBJ
    GetAlignmentUpToNow=ReturnValue
    End Function

    Sub Main ()


    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    'Set DOFCmd As DmisCommands.CurrentCommand
    MsgBox GetAlignmentUpToNow ( DmisCommands.CurrentCommand.ID , DmisCommands.CurrentCommand.Type)

    Set DmisApp = Nothing
    Set DmisPart = Nothing
    Set DmisCommands = Nothing
    End Sub
    '==========================================================
    Hope it helps


    This works great - thank you!
Children
No Data