Need Help Getting a Scrip to work

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need Help Getting a Scrip to work

    SOLVED!!! See post #8.


    I need some help get this script to work. No experience. I need to evaluate my assignments circle1 and circle2 and depending on the results, move to a certain label. The assignments are in my program an I didn't include them into the script. The script compiles successfully in the script editor but when I execute the routine, pcdmis freezes. It looks like its gets locked up when it gets to the script and becomes unresponsive. Then I have to force pcdmis to close and try again.

    I exported by program as basic and deleted everything I thought was not needed. I either deleted something I wasn't suppose to OR need to add extra command, idk. I need to check if my circle1 AND circle2 fit my criteria. If yes, goto label pass, Else, goto label fail. Labels in my program lead to folder locations. I can get it work in my program however I need to add way more features and my line ran out of room so I figured a script was the way to go.

    Any advice?

    Code:
    IF/CIRCLE1<0.005 AND CIRCLE2<0.005
    GOTO/PASS
    END_IF/
    ELSE/
    GOTO/FAIL
    END_ELSE/
    Code:
    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object
    
    Sub Part1
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    CommandCount = DmisCommands.Count
    Set DmisCommand = DmisCommands.Item(CommandCount)
    DmisCommands.InsertionPointAfter DmisCommand
    
    
    
    
    Set DmisCommand = DmisCommands.Add(IF_BLOCK_COMMAND, True)
    DmisCommand.Marked = True
    ' Set Mode = 3
    retval = DmisCommand.PutText ("3", MODE_TYPE, 0)
    ' Set Source Expression = 1
    retval = DmisCommand.PutText ("1", SRC_EXPR, 0)
    Result = DmisCommand.SetExpression("CIRCLE1<0.005 AND CIRCLE2<0.005", SRC_EXPR, 0)
    
    Set DmisCommand = DmisCommands.Add(GOTO_COMMAND, True)
    DmisCommand.Marked = True
    ' Set Mode = 0
    retval = DmisCommand.PutText ("0", MODE_TYPE, 0)
    ' Set Label = PASS
    retval = DmisCommand.PutText ("PASS", LABEL_ID, 0)
    
    Set DmisCommand = DmisCommands.Add(END_IF_COMMAND, True)
    DmisCommand.Marked = True
    ' Set Mode = 3
    retval = DmisCommand.PutText ("3", MODE_TYPE, 0)
    
    Set DmisCommand = DmisCommands.Add(ELSE_COMMAND, True)
    DmisCommand.Marked = True
    ' Set Mode = 5
    retval = DmisCommand.PutText ("5", MODE_TYPE, 0)
    
    Set DmisCommand = DmisCommands.Add(GOTO_COMMAND, True)
    DmisCommand.Marked = True
    ' Set Mode = 0
    retval = DmisCommand.PutText ("0", MODE_TYPE, 0)
    ' Set Label = FAIL
    retval = DmisCommand.PutText ("FAIL", LABEL_ID, 0)
    
    Set DmisCommand = DmisCommands.Add(END_ELSE_COMMAND, True)
    DmisCommand.Marked = True
    ' Set Mode = 5
    retval = DmisCommand.PutText ("5", MODE_TYPE, 0)
    
    
    
    End Sub
    
    Sub Main
    
    Part1
    Part2
    
    DmisPart.RefreshPart
    End Sub
    Last edited by acgarcia; 11-04-2020, 10:50 AM.

  • #2
    Why not just do this in PCDMIS? Not a script?

    Comment


    • acgarcia
      acgarcia commented
      Editing a comment
      I did but I ran out of room. I need to check cricle1<0.005 AND circle2<0.005 AND circle3 etc... and I ran out of room in the line.

    • LaserJay
      LaserJay commented
      Editing a comment
      Gotcha, let me see what I can come up with

  • #3
    So... where is "Part2" of the script? You call Part1 one and then Part2 in Main()...

    Tried encapsulating the two clauses to one?

    Code:
    CIRCLE1<0.005 AND CIRCLE2<0.005
    becomes
    (CIRCLE1<0.005 AND CIRCLE2<0.005)
    PC-DMIS CAD++ 2o19 R1 SP11

    Comment


    • acgarcia
      acgarcia commented
      Editing a comment
      I have not idea where or what part2 even is.

  • #4
    Why not measure what you need, call a sub to determine if things are good or bad, set a pcdmis variable to indicate that, return to pcdmis to continue execution based on that variable of where to branch to.

    Comment


    • #5
      If you ran out of room in your line code, couldn't you just do multiple arrays, find the max/min of those arrays and apply it to your if statement?

      Comment


      • #6
        if/goto statement might solve this.

        IF/GOTO is kind of an open statement, it needs no end, if it meets the IF portion, it does the goto, if it doesn't meet the if, it just continues with the program.

        Since you need BOTH to pass (and more apparently), put an IF/GOTO after each one, all pointing to the 'fail' label. As soon as a bad one shows up, it stops.
        sigpic
        Originally posted by AndersI
        I've got one from September 2006 (bug ticket) which has finally been fixed in 2013.

        Comment


        • #7
          sample of IF/GOTO in action

          Code:
          CL1 =COMMENT/INPUT,NO,''1=Validator
          ,2=Global'
          ,3=Global slow for testing'
          IF_GOTO/CL1.INPUT<1,GOTO = LAB1
          IF_GOTO/CL1.INPUT>3,GOTO = LAB1
          IF_GOTO/CL1.INPUT>2,GOTO = GLO2
          IF_GOTO/CL1.INPUT>1,GOTO = GLO
          IF_GOTO/CL1.INPUT<2,GOTO = VAL
          GOTO/CL1
          VAL =LABEL/
          ASSIGN/MS = 150
          ASSIGN/TS = 2.5
          GOTO/LAB2
          GLO =LABEL/
          ASSIGN/MS = 500
          ASSIGN/TS = 6
          GOTO/LAB2
          GLO2 =LABEL/
          ASSIGN/MS = 150
          ASSIGN/TS = 6
          GOTO/LAB2
          LAB2 =LABEL/
          MOVESPEED/ MS
          TOUCHSPEED/ TS
          ASSIGN/ACL = MS*2
          ACCELERATION/MAXACCELX=ACL, MAXACCELY=ACL, MAXACCELZ=ACL
          sigpic
          Originally posted by AndersI
          I've got one from September 2006 (bug ticket) which has finally been fixed in 2013.

          Comment


          • #8
            Would this work for you?
            If any of the dimensions go out of tolerance it will send it to the fail label

            Code:
            ASSIGN/DIMS1=LOC1.D.OUTTOL+LOC2.D.OUTTOL+LOC3.D.OUTTOL+LOC4.D.OUTTOL
            ASSIGN/DIMS2=LOC5.D.OUTTOL+LOC6.D.OUTTOL+LOC7.D.OUTTOL
            ASSIGN/TEST1=DIM1+DIM2
            IF/TEST1>0
            GOTO/FAIL
            END_IF/
            GOTO/PASS
            PASS =LABEL/
            FAIL =LABEL/

            Comment


            • acgarcia
              acgarcia commented
              Editing a comment
              This might work, i'll try it out.

            • acgarcia
              acgarcia commented
              Editing a comment
              This works perfectly, thanks for the help.

            • LaserJay
              LaserJay commented
              Editing a comment
              Yes sir! No problem!

          • #9
            ASSIGN/PASS_FAIL=IF(CIRCLE1.X.MEAS<0.005 AND CIRCLE2.X.MEAS<0.005,"Pass","Fail")

            Comment


            • acgarcia
              acgarcia commented
              Editing a comment
              I can make it work within pcdmis but there is a limit on how many characters I can in 1 line.

          • #10
            Use a min or max array and sort the values that way.

            Comment


            • acgarcia
              acgarcia commented
              Editing a comment
              Can u show me what that might look like?

          Related Topics

          Collapse

          Working...
          X