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
  • Hi,

    Next problem which I can't overcome related with ID of dimensions.
    This is piece of code:


    [If Cmd.IsDimension Then
    If Cmd.Type = DIMENSION_START_LOCATION Or _
    Cmd.Type = DIMENSION_TRUE_START_POSITION Then
    Set DcmdID = Cmd.DimensionCommand
    DimType = left(right (DcmdID.ID, 2),1)
    ReportDim = Cmd.GetText ( OUTPUT_TYPE, 0)
    End If
    If Cmd.Type <> DIMENSION_START_LOCATION And _
    Cmd.Type <> DIMENSION_END_LOCATION And _
    Cmd.Type <> DIMENSION_TRUE_START_POSITION And _
    Cmd.Type <> DIMENSION_TRUE_END_POSITION Then
    Set DCmd = Cmd.DimensionCommand
    CheckDim = Cmd.GetText ( OUTPUT_TYPE, 0)
    If CheckDim <> "" Then
    ReportDim = CheckDim
    End If
    If ReportDim = "BOTH" Or ReportDim = "REPORT" Then
    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.

    [ [B] xlSheet.Cells(RCount,2).Value = fncsheet.Round((DCmd.Nominal - DCmd.Minus),RND)[/B]
    xlSheet.Cells(RCount,3).Value = fncsheet.Round((DCmd.Nominal + DCmd.Plus),RND)
    If DCmd.Plus <> DCmd.Minus Then
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal,RND) & "+" & fncsheet.Round(DCmd.Plus,RND) & "/-" & fncsheet.Round(DCmd.Minus,RND)
    Else
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal,RND) & "+/-" & fncsheet.Round(DCmd.Plus,RND)
    End If
    If DimType = "B" Then
    xlSheet.Cells(RCount,5).Font.ColorIndex = 32
    xlSheet.Cells(RCount,5).Value = "[" & fncsheet.Round(DCmd.Nominal,RND) & "]" & "+/-" & fncsheet.Round(DCmd.Plus,RND)
    Else
    If DimType = G Then
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal - DCmd.Minus,RND) & "-" & fncsheet.Round((DCmd.Nominal + DCmd.Plus),RND)
    Else
    If DimType = "R" Then
    xlSheet.Cells(RCount,5).Font.ColorIndex = 53
    xlSheet.Cells(RCount,5).Value = "(" & fncsheet.Round(DCmd.Nominal,RND) & ")" & "+/-" & fncsheet.Round(DCmd.Plus,RND)
    Else
    If DCmd.Plus <> DCmd.Minus Then
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal,RND) & "+" & fncsheet.Round(DCmd.Plus,RND) & "/-" & fncsheet.Round(DCmd.Minus,RND)
    End If]


    I'm using two lines (see below) of code to set DcmdiD and extract letter as DimType. I do understand that probably I don't need to use two identical line for the same purpose but It was method of tries and mistakes.

    Set DcmdID = Cmd.DimensionCommand
    DimType = left(right (DcmdID.ID, 2),1)

    Script extracting letters, not returning error, doing actions related with letters and giving result. Letters representing different kind of dimensions:






    [63]+/-0.1
    5.25-5.65





    (73.25)+/-0.15





    73.25+/-0.15

    My problem is that code sometime giving wrong type of dimensions. I would guess that it is because of letters, as example G and "G", G working better than "G". My question is what can I do to ensure that script will always proper read letter and will interpret the same letter as same variable in all script?
Reply
  • Hi,

    Next problem which I can't overcome related with ID of dimensions.
    This is piece of code:


    [If Cmd.IsDimension Then
    If Cmd.Type = DIMENSION_START_LOCATION Or _
    Cmd.Type = DIMENSION_TRUE_START_POSITION Then
    Set DcmdID = Cmd.DimensionCommand
    DimType = left(right (DcmdID.ID, 2),1)
    ReportDim = Cmd.GetText ( OUTPUT_TYPE, 0)
    End If
    If Cmd.Type <> DIMENSION_START_LOCATION And _
    Cmd.Type <> DIMENSION_END_LOCATION And _
    Cmd.Type <> DIMENSION_TRUE_START_POSITION And _
    Cmd.Type <> DIMENSION_TRUE_END_POSITION Then
    Set DCmd = Cmd.DimensionCommand
    CheckDim = Cmd.GetText ( OUTPUT_TYPE, 0)
    If CheckDim <> "" Then
    ReportDim = CheckDim
    End If
    If ReportDim = "BOTH" Or ReportDim = "REPORT" Then
    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.

    [ [B] xlSheet.Cells(RCount,2).Value = fncsheet.Round((DCmd.Nominal - DCmd.Minus),RND)[/B]
    xlSheet.Cells(RCount,3).Value = fncsheet.Round((DCmd.Nominal + DCmd.Plus),RND)
    If DCmd.Plus <> DCmd.Minus Then
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal,RND) & "+" & fncsheet.Round(DCmd.Plus,RND) & "/-" & fncsheet.Round(DCmd.Minus,RND)
    Else
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal,RND) & "+/-" & fncsheet.Round(DCmd.Plus,RND)
    End If
    If DimType = "B" Then
    xlSheet.Cells(RCount,5).Font.ColorIndex = 32
    xlSheet.Cells(RCount,5).Value = "[" & fncsheet.Round(DCmd.Nominal,RND) & "]" & "+/-" & fncsheet.Round(DCmd.Plus,RND)
    Else
    If DimType = G Then
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal - DCmd.Minus,RND) & "-" & fncsheet.Round((DCmd.Nominal + DCmd.Plus),RND)
    Else
    If DimType = "R" Then
    xlSheet.Cells(RCount,5).Font.ColorIndex = 53
    xlSheet.Cells(RCount,5).Value = "(" & fncsheet.Round(DCmd.Nominal,RND) & ")" & "+/-" & fncsheet.Round(DCmd.Plus,RND)
    Else
    If DCmd.Plus <> DCmd.Minus Then
    xlSheet.Cells(RCount,5).Value = fncsheet.Round(DCmd.Nominal,RND) & "+" & fncsheet.Round(DCmd.Plus,RND) & "/-" & fncsheet.Round(DCmd.Minus,RND)
    End If]


    I'm using two lines (see below) of code to set DcmdiD and extract letter as DimType. I do understand that probably I don't need to use two identical line for the same purpose but It was method of tries and mistakes.

    Set DcmdID = Cmd.DimensionCommand
    DimType = left(right (DcmdID.ID, 2),1)

    Script extracting letters, not returning error, doing actions related with letters and giving result. Letters representing different kind of dimensions:






    [63]+/-0.1
    5.25-5.65





    (73.25)+/-0.15





    73.25+/-0.15

    My problem is that code sometime giving wrong type of dimensions. I would guess that it is because of letters, as example G and "G", G working better than "G". My question is what can I do to ensure that script will always proper read letter and will interpret the same letter as same variable in all script?
Children
No Data