hexagon logo

Updating the Serial Number field during a PCDMIS run; display updated value in report

This may be more useful to NC users than to anybody else, but here is a sample of code with which you can update the serial number field.

Problem: our parts are ALL serialized. So every time I run the part program, I ask for that serial number. But at that time, the header for my report file has already been generated. In NC, you do NOT have the luxury of being able to just redraw the report so it shows the updated field. It prints the old number. After a redraw, it will print the correct number, but that is not an option in NC.

Partial Solution: use an assigned variable and REPORT it in the report.

But I do not like that solution. I want the ACTUAL serial number field to be updated and shown, not some sort of variable. I want the File Header to show the latest.

Full solution: With the help of Hexagon tech support (Don Ruggieri produced the basic ideas and code), I was able to write the following script:


'This script takes the new serial number and makes it the latest active serial number. Refreshes report so it shows the latest.

Sub main(sn As String) 'bring sn in as ARG1 from PCDMIS

Dim App As Object 
Set App = CreateObject("PCDLRN.Application") 

Dim Part As Object 
Set Part = App.ActivePartProgram 

part.serialnumber=sn    'make the new control number, the serial number
part.refreshpart

part.save               ' save the part program so it has the latest serial number

Dim repwin As Object
Set repwin = part.reportwindow

repwin.refreshreport	'refresh report; now the report shows the latest serial number.

End Sub



In PC DMIS, put in the following (with variable NEWSN having the latest number):

CS1        =SCRIPT/FILENAME= C:\PCDMISW\CHANGESERNUMBER.BAS
            FUNCTION/Main,SHOW=YES,ARG1=NEWSN,,
            STARTSCRIPT/
            ENDSCRIPT/



This is simple and works great in my case.Sunglasses


Jan.
Parents
  • how to put variable instead of NEWSN......
    and its not taking fond like A569-5
    Neutral face

    This may be more useful to NC users than to anybody else, but here is a sample of code with which you can update the serial number field.

    Problem: our parts are ALL serialized. So every time I run the part program, I ask for that serial number. But at that time, the header for my report file has already been generated. In NC, you do NOT have the luxury of being able to just redraw the report so it shows the updated field. It prints the old number. After a redraw, it will print the correct number, but that is not an option in NC.

    Partial Solution: use an assigned variable and REPORT it in the report.

    But I do not like that solution. I want the ACTUAL serial number field to be updated and shown, not some sort of variable. I want the File Header to show the latest.

    Full solution: With the help of Hexagon tech support (Don Ruggieri produced the basic ideas and code), I was able to write the following script:


    'This script takes the new serial number and makes it the latest active serial number. Refreshes report so it shows the latest.
    
    Sub main(sn As String) 'bring sn in as ARG1 from PCDMIS
    
    Dim App As Object 
    Set App = CreateObject("PCDLRN.Application") 
    
    Dim Part As Object 
    Set Part = App.ActivePartProgram 
    
    part.serialnumber=sn    'make the new control number, the serial number
    part.refreshpart
    
    part.save               ' save the part program so it has the latest serial number
    
    Dim repwin As Object
    Set repwin = part.reportwindow
    
    repwin.refreshreport	'refresh report; now the report shows the latest serial number.
    
    End Sub
    
    


    In PC DMIS, put in the following (with variable NEWSN having the latest number):

    CS1        =SCRIPT/FILENAME= C:\PCDMISW\CHANGESERNUMBER.BAS
                FUNCTION/Main,SHOW=YES,ARG1=NEWSN,,
                STARTSCRIPT/
                ENDSCRIPT/



    This is simple and works great in my case.Sunglasses


    Jan.
Reply
  • how to put variable instead of NEWSN......
    and its not taking fond like A569-5
    Neutral face

    This may be more useful to NC users than to anybody else, but here is a sample of code with which you can update the serial number field.

    Problem: our parts are ALL serialized. So every time I run the part program, I ask for that serial number. But at that time, the header for my report file has already been generated. In NC, you do NOT have the luxury of being able to just redraw the report so it shows the updated field. It prints the old number. After a redraw, it will print the correct number, but that is not an option in NC.

    Partial Solution: use an assigned variable and REPORT it in the report.

    But I do not like that solution. I want the ACTUAL serial number field to be updated and shown, not some sort of variable. I want the File Header to show the latest.

    Full solution: With the help of Hexagon tech support (Don Ruggieri produced the basic ideas and code), I was able to write the following script:


    'This script takes the new serial number and makes it the latest active serial number. Refreshes report so it shows the latest.
    
    Sub main(sn As String) 'bring sn in as ARG1 from PCDMIS
    
    Dim App As Object 
    Set App = CreateObject("PCDLRN.Application") 
    
    Dim Part As Object 
    Set Part = App.ActivePartProgram 
    
    part.serialnumber=sn    'make the new control number, the serial number
    part.refreshpart
    
    part.save               ' save the part program so it has the latest serial number
    
    Dim repwin As Object
    Set repwin = part.reportwindow
    
    repwin.refreshreport	'refresh report; now the report shows the latest serial number.
    
    End Sub
    
    


    In PC DMIS, put in the following (with variable NEWSN having the latest number):

    CS1        =SCRIPT/FILENAME= C:\PCDMISW\CHANGESERNUMBER.BAS
                FUNCTION/Main,SHOW=YES,ARG1=NEWSN,,
                STARTSCRIPT/
                ENDSCRIPT/



    This is simple and works great in my case.Sunglasses


    Jan.
Children
No Data