Attempting to add Transformations to IF/THEN statement

Home Forums Problems and solutions in GDL Others Attempting to add Transformations to IF/THEN statement

Viewing 4 reply threads
  • Author
    Posts
    • #2270
      Patrick May
      Participant

      Sorry for the simplicity of this question; I should know how to do this, but I can’t figure it out. I am building an appliance and want a control to open the lid. I am trying to add a series of transformations into the script but keep coming up with an error. My script as typed is:
      IF HoodPosition = “Open” THEN
      ROTx 294
      ADDz 0′-10 3/4″
      ADDy -3′-6 5/32″ ELSE
      ENDIF
      !script here
      DEL TOP

      This is giving an error message as soon as I include the ADDy & z commands. Thoughts on what is wrong?

    • #2271
      Barry Kelly
      Participant

      I have never used Imperial measurements in a script but I suspect what you have shown is incorrect.
      ADD command requires just one value, you seem to have two for each.
      There must be another way of writing it as one figure.

      Barry.

      Versions 6.5 to 22
      Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
      Dell Precision M6800 - i7 4700MQ @ 2.40GHz, 16GB RAM, AMD FirePro M6100 (2GB), Windows 7 64bit

    • #2272
      Joachim Sühlo
      Participant

      ELSE must be put into a new line!

      GDL Object Developer
      b-prisma
      MAC OSx 10.14

    • #2279
      Patrick May
      Participant

      @joachim, that was it. I eventually tracked that down. Apparently I don’t even need the Else line for this stack to work, I just had it in there by habit.
      @barry, imperial feet and inches do work, as long as they are consistent. they can be foot + inch or decimal feet.
      Another odd thing about this script is the DEL command. for some reason DEL TOP works, but DEL 3 doesn’t. DEL TOP got the job done, but I’m not sure why I couldn’t be more selective.

      • #2284
        Dominika Bobály
        Keymaster

        Joachim is quite right.
        Another nice way to keep track of your transformation stack is to assign a variable to count every trafo you make:

        _nTrans = 0
        IF HoodPosition = “Open” THEN
          ROTx 294
          ADDz 0′-10 3/4″
          ADDy -3′-6 5/32″ 
          _nTrans = _nTrans + 3
        ELSE
          ! whatever, just keep track of transformations here as well, if you use any
        ENDIF
        !script here
        DEL _nTrans
        

        This way you don’t have to use the condition again to enable the DEL command.

        Dominika Bobály
        Product Manager
        GRAPHISOFT SE

    • #2280
      Joachim Sühlo
      Participant

      DEL 3 works only as follows:

      IF HoodPosition = “Open” THEN
      ROTx 294
      ADDz 0′-10 3/4″
      ADDy -3′-6 5/32″ 
      ELSE
      ENDIF
      !script here
      IF HoodPosition = “Open” THEN DEL 3

      Otherwise you will get an error if the condition is not true.

      GDL Object Developer
      b-prisma
      MAC OSx 10.14

Viewing 4 reply threads
  • The forum ‘Others’ is closed to new topics and replies.