hexagon logo

Reset to nominals

Here's one...

I got it from WILCOX
  • insert>basic script. Leave this in the program and at the end it will reset everything (make sure you put in a print command first), or insert this in the program and F9 it and hit the play button in the basic script edit window and it will run the script.


    what does the print command do?

    I created a variable called TimeToRun and set it by prompting the user. Then I insert a basic script which uses the getvariable to retrieve the value from the program. After calculations, I use setvariable to pass information from the basic program back to the part program. Unfortunately, these commands did not work. Will the print command do something magical? Wink

    Keith
  • what does the print command do?

    I created a variable called TimeToRun and set it by prompting the user. Then I insert a basic script which uses the getvariable to retrieve the value from the program. After calculations, I use setvariable to pass information from the basic program back to the part program. Unfortunately, these commands did not work. Will the print command do something magical? Wink

    Keith

    Not every version supports setting a variable value through automation. I went from V 3.2063 to V 3.7. I do know it is not in the basic language library for 3.2063 but it is in 3.7, what version it became a feature in I do not know. Perhaps someone with 3.25 or 3.5 could check their help file and let us know if the SetVariableValue method is supported or not. Or you could download the basic language reference (PCDBasic) from Wilcox. That has been a helpful document for me.

    Craig
  • Not every version supports setting a variable value through automation. I went from V 3.2063 to V 3.7. I do know it is not in the basic language library for 3.2063 but it is in 3.7, what version it became a feature in I do not know. Perhaps someone with 3.25 or 3.5 could check their help file and let us know if the SetVariableValue method is supported or not. Or you could download the basic language reference (PCDBasic) from Wilcox. That has been a helpful document for me.

    Craig



    I'm running 3.7 mr2 (soon to be 4.1)
  • can you post your script and PCDMIS code. SetVariableValue should work in 3.7. It must be something else. I'm not sure what the print is for. I don't have any print commands going on.

    Craig
  • can you post your script and PCDMIS code. SetVariableValue should work in 3.7. It must be something else. I'm not sure what the print is for. I don't have any print commands going on.

    Craig


    My program gives me this error:

    ---------------------------
    PC-DMIS Basic Scripting Engine
    ---------------------------
    Error on line: 8 - OLE Automation object does not have a default value
    ---------------------------
    OK
    ---------------------------


    My program is here:
    PART NAME : WarmUp
    REV NUMBER :
    SER NUMBER :
    STATS COUNT : 1

    STARTUP =ALIGNMENT/START,RECALL:, LIST= YES
    ALIGNMENT/END
    MODE/MANUAL
    PREHIT/ 1.27
    RETRACT/ 1.27
    CHECK/ 12.7,0.5
    COMMENT/DOC,NO,Press F5 to ensure DISPLAY ABSOLUTE SPEEDS is checked
    COMMENT/DOC,NO,Set MOVESPEED to 100 for calculating time accurately
    MOVESPEED/ 100
    TOUCHSPEED/ 1
    SCANSPEED/ 1
    MANRETRACT/20
    LOADPROBE/CURRENT
    TIP/T1A0B0, SHANKIJK=0, 0, 1, ANGLE=0
    FORMAT/TEXT,OPTIONS, ,HEADINGS,SYMBOLS, ;NOM,MEAS,DEV,TOL,OUTTOL, ,
    COMMENT/OPER,NO,Program first prompts for lower left, then upper right limits of a bounding box in which all movement will be contained.
    COMMENT/OPER,NO,Move probe to lower left rear of warmup region
    PNT1 =FEAT/POINT,RECT
    THEO/-114.2102,246.0056,-322.6612,0,0,1
    ACTL/150.7531,361.0903,-235.1847,0,0,1
    READPOINT/
    COMMENT/OPER,NO,Move probe to top right front of warmup region
    PNT2 =FEAT/POINT,RECT
    THEO/301.1047,13.9373,-179.6567,0,0,1
    ACTL/268.4931,312.5765,-201.2698,0,0,1
    READPOINT/
    ASSIGN/Z_STEP = (PNT2.Z - PNT1.Z)/10
    COMMENT/DOC,NO,PNT3 is a temporary variable to step in Z
    PNT3 =FEAT/POINT,RECT
    THEO/301.1049,13.9372,-179.6562,0,0,1
    ACTL/268.4929,312.5768,-192.7895,0,0,1
    READPOINT/
    ALN0 =ALIGNMENT/START,RECALL:STARTUP, LIST= YES
    ALIGNMENT/LEVEL,ZPLUS,PNT1
    ALIGNMENT/ROTATE,XPLUS,TO,PNT1,ABOUT,ZPLUS
    ALIGNMENT/TRANS,XAXIS,PNT1
    ALIGNMENT/TRANS,YAXIS,PNT1
    ALIGNMENT/TRANS,ZAXIS,PNT1
    ALIGNMENT/END
    COMMENT/DOC,NO,Obtain time needed for warm up
    C1 =COMMENT/INPUT,NO,'Enter time (in minutes) to warm up'
    ASSIGN/TIMETOMOVE = C1.INPUT*60
    CS1 =SCRIPT/FILENAME= O:\50-MANUFACTURE\130-INSPECT\DMIS PROGRAMS\TIMER.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDSCRIPT/
    COMMENT/DOC,NO,Switch to DCC Mode
    MODE/DCC
    ASSIGN/PNT3.Z = PNT2.Z-Z_STEP
    WHILE/PNT3.Z > PNT1.Z
    MOVE/POINT,NORMAL,PNT1.X,PNT2.Y,PNT3.Z
    MOVE/POINT,NORMAL,PNT1.X,PNT1.Y,PNT2.Z
    MOVE/POINT,NORMAL,PNT2.X,PNT1.Y,PNT3.Z
    MOVE/POINT,NORMAL,PNT2.X,PNT2.Y,PNT2.Z
    MOVE/POINT,NORMAL,PNT2.X,PNT2.Y,PNT3.Z
    ASSIGN/PNT2.Z = PNT2.Z-Z_STEP
    ASSIGN/PNT3.Z = PNT3.Z-Z_STEP
    END_WHILE/
    PROGRAM/END

    This is the TIMER.BAS file:

    Sub Main
    Dim MyApp As Object
    Set MyApp = CreateObject ("PCDLRN.Application")
    Dim MyPartProgram As Object
    Set MyPartProgram = MyApp.ActivePartProgram
    Dim MyVar As Object
    Set MyVar = MyPartProgram.GetVariableValue ("TIMETOMOVE")
    MSGBOX "TIMETOMOVE = ", MYVAR
    Dim I As Object
    If Not MyVar Is Nothing Then
    MyVar.LongValue = MyVar.LongValue + 1
    MyPartProgram.SetVariableValue "TIMETOMOVE", MyVar
    MsgBox "V1 is now: " & MyVar
    Else
    Msgbox "Could Not find variable"
    End If
    End Sub
  • According to the "line 8" error you are failing at the message box. I'll look at it and see if I can make a recommendation.

    Craig
  • According to the "line 8" error you are failing at the message box. I'll look at it and see if I can make a recommendation.

    Craig


    Yes, after the error msgbox, my msgbox appears "TimeToMove = "
  • Yes, after the error msgbox, my msgbox appears "TimeToMove = "

    That is because in quotes "TimeToMove = " is a string, message box data is a string in all cases and when you use variables of mixed type (integer, double, date) they are converted to strings. It is likely the comma and object that are screwing it up. You are asking the message box to display an object which it can not do. It needs a string. What is it you want the message box to display?

    Craig
  • Shouldnt the message box be something like this:

    MYVAR = MSGBOX ("TIMETOMOVE = ")

    Also, a msgbox only returns the key pressed not a type-in answer. Use inputbox instead for a type-in answer.
    MsgBox returns a string (as craig said) and MYVAR needs to be dim'd as a string.
  • i added a comment to the part program to display the variable value (120) before calling the basic program. i then changed the basic program to display TIMETOMOVE.LONGVALUE but it is displaying "" before entering the loop, then it displays 1.

    that tells me at least the loop is working and the basic program is displaying the value, but the GETVARIABLEVALUE isn't working. Any ideas?