6 Replies Latest reply on Feb 11, 2015 11:29 AM by 3dsolutions

    if and then take and action

    3dsolutions Level 1

      Hi,

       

      I am moving this question that was at Richmedia & 3d to this section, considering that it is more like a javascript task.

       

      I have created a document with some interactivity. In the document there is a group of four buttons. Depending on user´s choice one of this buttons is shown and the rest is hidden.

      Now I like to create another button that depending on which of previous button is shown an action will take place allowing to show/hide different objects in the 3d scene.

      A Javascript file is already embed with the function to show/hide objets ( courtesy of Dave Merchant )

       

      //Hiding or showing objects can be done by setting the "visible" node property to false or true

      //e.g. meshVisW("leg",true) affects anything with "leg" in the name (leg1, myleg...)

          function meshVisW(_name, _vis) { 

              var currMesh = null; 

              for (i=0; i<scene.meshes.count; i++) { 

                  currMesh = scene.meshes.getByIndex(i); 

                  if (currMesh.name.toString().indexOf(_name) > -1) currMesh.visible = _vis; 

                  }

          }

       

      The syntax is something like,

       

      If button_one is shown then a group of objects will hidden

      If button_one is shown then a group of objects will shown

       

      If button_two is shown then a group of objects will hidden

      If button_two is shown then a group of objects will shown

       

      If button_three is shown then a group of objects will hidden

      If button_three is shown then a group of objects will shown

       

      If button_four is shown then a group of objects will hidden

      If button_four is shown then a group of objects will shown

       

      Is this possible?

       

      I guess the second part can be something like,

      e.g. if button_one is shown then getAnnots3D(this.pageNum)[0].context3D.meshVisW("leg",true);

       

      Thanks in advance

        • 1. Re: if and then take and action
          Dave Merchant MVP & Adobe Community Professional

          It depends if the names of the meshes can be formatted so that your groups are selectable via wildcards or substrings. If so, you can use my function and choose an appropriate parameter - if not, you'll have to use arrays to list the nodes within each group and process them individually.

           

          If you can describe the model naming tree we can be of more help.

          • 2. Re: if and then take and action
            3dsolutions Level 1

            Oh, yes!!!

             

            This is the 3dscene.

            Dropbox - seats.jpg

             

            In the document I have created 4 buttons.  These buttons will make the first selection.

            03, 04, 05, 06 will show/hide the group of seats.

            03_seats, 04_seats, 05_seats, 06_seats

             

            Then there is another group of buttons where user can choose arms, tables, and bases.

            03_arms, 03_tables, 03bases

            04_arms, 04_tables, 04bases

            05_arms, 05_tables, 05bases

            06_arms, 06_tables, 06bases

             

            So depending on which button is selected from 03,04,05,06 then the corresponding arm, table or base will be shown/hidden.

            At this point I understand that second part of the code (then getAnnots3D(this.pageNum)[0].context3D.meshVisW("leg",true);) resolves the equation.

            Now I need to figure out how to write the first part. If button_one is shown


             

             

             

            I like to give a further step to the document making available to choose the kind of arm and the kind of table.

            This  group of buttons has to be able to show/hide objects depending on two buttons selected previously. The one from the number of seats and the one from the arm or table´s model.
            So first part of equation gets more complicated.

             

            Thanks a lot!


            • 3. Re: if and then take and action
              Dave Merchant MVP & Adobe Community Professional

              When you say "if button is shown" - so you mean 'pressed' or 'made visible'? In your first message you list the actions when the buttons are 'shown' but not the opposite.

               

              You should be adding the 3D function calls to the logic that is controlling the buttons - e.g. in the Actions tab of the properties for each button you can assign a JavaScript command to the "On Press" event.

              • 4. Re: if and then take and action
                3dsolutions Level 1

                I mean when button is 'made visible'.
                I have made another group of buttons that are visible when proper button is clicked and work like a witness showing which option is selected.

                visible.jpg

                "On Press" event won´t work because the same button must distinguish which number of seats are in the scene before take action. Depending on the number of seats it will show a different object .

                Let´s say I click, 03 . This will make appear in the scene 3 seats.

                Now I click the button, VIT, then in the scene must appear the arm that is ready for the 3 seat´s model.

                The same button, VIT, will wok for the the, 4, 5, and 6 seats model. Each group of seat has each owm arm object ready and put at proper place.

                 

                Clicking VIT button,

                If 03_Selection button is visible then all arms will be hidden

                If 03_Selection button is visible then VIT ARMS FOR 03SEATS will be shown

                 

                If 04_Selection button is visible then all arms will be hidden

                If 04_Selection button is visible then VIT ARMS FOR 04SEATS will be shown

                 

                If 05_Selection button is visible then all arms will be hidden

                If 05_Selection button is visible then VIT ARMS FOR 05SEATS will be shown

                 

                If 06_Selection button is visible then all arms will be hidden

                If 06_Selection button is visible then VIT ARMS FOR 06SEATS will be shown

                 

                I do hide all arms first and then I show the object that I want.

                I know this is a very "primitive" way of working but I am not a programmer and this is as far as I can go.

                 

                So returning to the task. I think the second part is resolved

                ...then getAnnots3D(this.pageNum)[0].context3D.meshVisW("arm_",false);.

                ...then getAnnots3D(this.pageNum)[0].context3D.meshVisW("arm_vit_03",true);.

                My question is how to write the first part.

                • 5. Re: if and then take and action
                  Dave Merchant MVP & Adobe Community Professional

                  You should be storing the various parameters (number of seats, etc.) as document-level variables which are updated when the "selection" buttons are pressed, then are checked by the other buttons when their 'on Press' action is executed, so they can perform the appropriate calls to the 3D scene. Simple add a doc-level script block which defines all your variables and gives them the default values, then read/write them in the button code. It's all pretty standard stuff, just takes a while to attach to all those buttons.

                   

                  please remember we're not here to teach people the basics of JavaScript programming or to supply off-the-shelf solutions.

                  • 6. Re: if and then take and action
                    3dsolutions Level 1

                    Thanks for your answer Dave, and yes, you are right, I should learn some JS programming...

                    It is a matter of lack of time and priorities. This is an occasional work.

                    I will have to go on the "primitive" way.

                    Just let me ask for one more question.

                     

                    Actually I am using at document-level a code for show/hide one layer. LayerVis

                    As the document is quite complex I want to use a function to hide several layers at once.

                    And also another function to show several layers at once.

                    I know wildcards and substrings are used for fields. Can this be used for layers too?

                    Any help will be appreciated.