hexagon logo

Data from script to dc dmis

Hello,

My target is to create unique number for every single report, number should be in a format 00000. Script should read this number from .txt file, then increase by 1 and add text "Report no.: ". Final result should be: like "Report no.: 0015". I have script:

[Sub Main

Dim App As Object
Set App = CreateObject ("PCDLRN.Application")
Dim Text As String
Dim Part As Object
Set Part = App.ActivePartProgram
Dim RepNo As String
Dim No As Integer
Dim V100 As Object
Set V100 = part.getvariablevalue ("V100")

Open "X:\CMM_Data\Proven programs\SCRIPT\REPORTNO.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, No
Loop
Close #1

No=No+1

If No>9999Then
Set Text = "Report no.: "
End If
If No>999 Then
Set Text = "Report no.: 0"
End If
If No>99 Then
Set Text = "Report no.: 00"
End If
If No>9 Then
Set Text = "Report no.: 000"
End If
If No<=9 Then
Set Text = "Report no.: 0000"
End If
'MsgBox Text
'MsgBox No

RepNo = Text & No

MsgBox RepNo

PART.SetVariableValue "V100", RepNo

Part.RefreshPart


End Sub]

This script giving report number which I want but I can't transfer RepNo (report number) to pc dmis, pc dmis showing massage "Runtime error on line: 43 - type mismatch". line 43: "PART.SetVariableValue "V100", RepNo" I did try the way of tries and mistakes but no result achieved. Can please any one tel me what is the problem with this script?


Code in Pc dmis:
[ASSIGN/100="REPORT NO.: 0001"
CS3 =SCRIPT/FILENAME= C:\USERS\DMILIUS\DESKTOP\DELETE\TEST.BAS
FUNCTION/Main,SHOW=NO,,
STARTSCRIPT/
COMMENT/OPER,NO,FULL SCREEN=NO,AUTO-CONTINUE=NO,
V100]

Regards
Parents


  • Set DcmdID = Cmd.DimensionCommand
    DimType = right (DcmdID.ID, 1)]

    DcmdID.ID is ID of dimension. In end of ID is letter B, letter R, letter G or no letter and target of above code is to extract B or R or G. Code below should to do actions which depends on letters B R and G from previous piece.


    It should be possible to write directly
    DimType = Right(Cmd.DimensionCommand.ID, 1),

    but what do you mean by "or no letter" above - that there is nothing there? Doesn't work, as the Right(anything, 1) will always find the last character, and the ID can't be zero characters long.

    If DimType = G Then
    


    This is wrong - you're comparing DimType to the variable G, which is probably not even declared, and certainly has no value assigned to it. To make it impossible to do such mistakes, you begin your script with
     Option Explicit
    

    to get an error message for each undeclared variable/misspelling.


    I think the main problem is that Cmd.DimensionCommand.ID is only valid on single command line dimensions and the DIMENSION_START_xxx commands, not on the subsequent 'real' dimension axis commands that lie between the DIMENSION_START_xxx and DIMENSION_END_xxx.

    In my export script the similar part of code looks as (lots of detail removed…):
    
    State = 1
    
    For ix = 1 To DmisCommands.Count
    
        Set DmisCommand = DmisCommands(ix)
    
        If DmisCommand.IsDimension Then
    
          Skip = FALSE
    
          Set DmisDimension = DmisCommand.DimensionCommand
    
          Select Case State
    
            Case 1 '  Normal Case
                ID = DmisDimension.ID
                ...
                If (DmisCommand.Type = DIMENSION_TRUE_START_POSITION) Then
                  State = 2
                ElseIf (DmisCommand.Type = DIMENSION_START_LOCATION) Then
                  State = 3
                Elseif (DmisCommand.Type = DATDEF_COMMAND) Then
                   State = 1
                   Skip = TRUE
                End If
    
                If (SKIP = FALSE) And (State = 1) Then
                   ' single command line dimension
                   ...
                End If
    
            Case 2 '  True Position
                  ' one or more command lines for the actual position axes, handle and stay in state 2
                  ...
    
            Case 3 '  Location 
                  ' one or more command lines for the actual location axes, handle and stay in state 3
                   ...
    
          End Select
    
          Set DmisDimension = Nothing
    
        ElseIf (DmisCommand.Type = DIMENSION_TRUE_END_POSITION) Then
    
          State = 1
    
        ElseIf (DmisCommand.Type = DIMENSION_END_LOCATION) Then
    
          State = 1
    
        Elseif (DmisCommand.Type = FEATURE_CONTROL_FRAME) Then
    
            ...
            State = 1
    
        End If
    
        Set DmisCommand = Nothing
    
      Next ix
    
    
    
  • By "or no letter" I meant that as last symbol can be R G B or number but only R G B is a meter.
    Actually G is error but not mistake. I did try a lot of things and I do understand that to use just G is wrong, but somehow it did work better than "G". Yeah probably I will use Option Explicit.
    I will try think about your piece of code if I will be capable to digest it.
    Thanks
Reply
  • By "or no letter" I meant that as last symbol can be R G B or number but only R G B is a meter.
    Actually G is error but not mistake. I did try a lot of things and I do understand that to use just G is wrong, but somehow it did work better than "G". Yeah probably I will use Option Explicit.
    I will try think about your piece of code if I will be capable to digest it.
    Thanks
Children
No Data