hexagon logo

passing text in a comment to script variable?

Does anyone know how to pull the text out of a report comment feature and into a variable in the basic script editor?
  • Should (hopefully) be possible as the report objects are exposed through the automation interface.

    Could you be more specific?
  • Post a code snippet and let us know what exactly you want pulled.
  • SCN1       =FEAT/SET,CARTESIAN
                THEO/<-0.0099,-0.0142,4.4921>,<0,0,1>
                ACTL/<-0.0099,-0.0143,4.4919>,<0,0,1>
                CONSTR/SET,BASIC,P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14,P15,P16,P17,P18,P19,P20,P21,P22,P23,P24,,
                ASSIGN/V1=DOT((SCN1.HIT[1..24].XYZ-SCN1.HIT[1..24].TXYZ),SCN1.HIT[1..24].TIJK)
                ASSIGN/V2=(MAX(V1)-MIN(V1))/2
                COMMENT/REPT,
                "Overall tolerance range here is: " + V2



    Basically anything you can put into a report comment. This was just a quick example I used, but you get the idea. I have started using excel more and more to sort through data, and I know I can make excel do the calculation here, but it sure would be a nice addition to my 'toolbox' if I could pull those comments out of a program and print into a text file like I do with the rest of the data.

    Also, I had the idea that if I assigned another variable, like ASSIGN/V3="what I would want in my comment here", and then set the comment equal to the variable instead of how I have above, I could pull the value out of the variable instead of the comment as a different means to accomplish the same end. I don't know how to do that, either. I've looked through dozens of threads but I guess I'm not sure what to really look for.

    I am not very savvy when it comes to coding, so if you post a code snippet you think might work could you please explain what the code is doing (how it 'talks' to the program). Thanks.
  • The problem is to know WHICH report comment contain the value you are looking for in the program?

    It would be a smarter solution to cast the text into a variable (just like you already thought of doing) because the variablename is constant and thus easier to fetch.

    ASSIGN/V2="Overall tolerance range here is: "


    Then create a report comment, you don't need to change anything so just leave it at the default value (the comment text):

    COMMENT/REPT,
    "Edit the comment text"


    Edit the comment text directly in the edit window, otherwise I am not sure if this will work. Change the comment text to "V2" (without the quotation marks):

    COMMENT/REPT,
    V2


    When you move the cursor from this command, PC-DMIS should ask you if you are referring to the variable V2 or not. Answer yes to that question, because we want to use whatever value V2 holds, instead of the text "V2".
  • Yeah I do this at the start of every program I run. Also keep in mind you can have any comment show in the report. It doesn't have to be a report comment specifically. If you create the comment, then place the cursor in the comment and hit F9. There is a little check box for show comment in report.

    $$ NO,====================================================
         ,PART INFORMATION:
         ,CMMPROGRAM=Part # & what is being checked
         ,PRINTREV1=Print #, and Rev
         ,PARTNAM=Part Name
         ,PARTNUM=Is Part # used in-house, may be the same as Print #
         ,====================================================
                ASSIGN/CMMPROGRAM=""
                ASSIGN/PRINTREV1=""+" , Rev."+""
                ASSIGN/PARTNAM=""
                ASSIGN/PARTNUM=""
    $$ NO,====================================================
         ,PROGRAM DISPLAY @ EXECUTION, Program Information
         ,====================================================
    EXECUTE    =COMMENT/YESNO,NO,
                                ,==================================
                                ,CMMPROGRAM
                                ,==================================
                                ,
                                ,
                                ,THIS PROGRAM INSPECTS THE FOLLOWING PART:  
                                , 
                                ,PARTNUM
                                ,PARTNAM
                                , 
                                ,"PRINT: " + PRINTREV1
                                , 
                                , 
                                ,DO YOU WISH TO CONTINUE ?
                IF_GOTO/EXECUTE.INPUT=="NO",GOTO = END
    


    I show the Yes/No question on my report. That way I can prove the operator hit yes. I also run a log to know if they crash the machine and don't tell me.
  • Now if you want to know how to pass variables into a script. I would suggest looking at these links:

    http://pcdmisforum.com/showthread.php?27337-How-to-Create-an-quot-Object-quot-with-Basic-Script
    http://pcdmisforum.com/showthread.php?27289-Variable-from-PCDMIS-to-Basic
    http://pcdmisforum.com/showthread.php?26990-Using-script-to-create-folder-for-prg-and-save-part-program

    I'm pretty sure that covers what you asked for. If not, say something. They can beat you to death with a mountain of knowledge that I have only begun scratching.
  • What indicator do you use to see if the machine was crashed?
  • What indicator do you use to see if the machine was crashed?


    I imagine you could log the dialog message events coming from PCDLRN, and even filter events to those specifically containing collision messages.

    Last year, we installed MTConnect-based machine monitoring software on a our lab CMMs; the software uses a "listener" that attaches to PCDLRN and handles application events for productivity monitoring.
  • I use a variation from this link that logs it to the same file. instead of just a "started" and "ended" value it also plugs in a "Program Run" time and then a "Program Completed". If it doesn't reach the end of my measurable features it will throw in an "Incomplete Run-Possible Crash" with a time. That displays a pop-up with the text "Program Error - Did the Machine Crash? Yes/No. I have it all logged including their answer. If I find out they lied, it's not my problem.

    http://pcdmisforum.com/showthread.php?27337-How-to-Create-an-quot-Object-quot-with-Basic-Script
  • I imagine you could log the dialog message events coming from PCDLRN, and even filter events to those specifically containing collision messages.


    It should be enough to catch the event PCD_ApplicationEventsEndExecution(...) as there is a parameter TerminationType in that call. You will get this event regardless of how the part program stopped.

    To also detect that PC-DMIS itself has crashed, you could have a watchdog timer (for a fairly long time) that gets reset on any event from PC-DMIS ('gotta catch them all' in that case), and signals an alarm if it finally triggers, which means that PC-DMIS has stopped in an uncontrolled way.