7 Replies Latest reply on Nov 10, 2015 7:29 AM by Zhu Shuyan

    Cannot select axis on Section View

    Joecel Torres

      Hi,

       

      Has anyone of you guys ever tried selecting an Axis in a Section View?

      I tried recording a macro while doing it manually, a code was generated but when I debug it, the selection returns False.

      The code generated was ModelDoc2.Extension:: SelectByID2

      With this, I tried manually selecting FACE, SILHOUETTE, DRAWING VIEW and PLANE, all of which returned True EXCEPT for the PLANE.

       

      Is it possible that SolidWorks API does not allow selection of Axis and Plane in a Section View??

       

      Thanks is advance.

       

      Regards,

      Joecel

        • Re: Cannot select axis on Section View
          Keith Rice

          It isn't clear whether you are talking about section views in drawings or parts/assemblies, or whether you're referring to temporary axes or regular reference axes. Please be more descriptive in the future, so we don't risk solving a problem you don't have. In this case I would at least include a picture.

           

          If I had to guess, you are talking about selecting a temporary axis in a drawing section view.

           

          First of all, you need to have temporary axes visible, which you can do using this code:

           

          swModel.Extension.RunCommand swCommands_e.swCommands_ViewTemporaryAxes, Nothing
          

           

          Second, what you recorded probably looks something like this?

           

          Part.Extension.SelectByID2 <assembly component name>, "AXIS", 0.194120157609054, 0.06796452764311, 0, False, 0, Nothing, 0
          

           

          What I found is that if you change <assembly component name> to Empty, and let IModelDocExtension::SelectByID2 use only the Type and XYZ arguments, the temporary axis is successfully selected. Like this:

           

          Part.Extension.SelectByID2 Empty, "AXIS", 0.194120157609054, 0.06796452764311, 0, False, 0, Nothing, 0
          

           

          Hope that helps.

           

          Keith

          SolidWorks API Automation

            • Re: Cannot select axis on Section View
              Joecel Torres

              I apolgize for my vague question.

              Ok, I`ll try to explain it better.

                   "It isn't clear whether you are talking about section views in drawings or parts/assemblies, or whether you're referring to temporary axes or regular reference axes."

                   >> Sorry, I wasn`t aware that there are section views in parts/assembly too, I thought that sections views are specifically used for drawings(2D) only. I don`t know the difference of temporary vs regular axes too.

                  

                    "If I had to guess, you are talking about selecting a temporary axis in a drawing section view."     

                   >> Yes, I`m selecting an axis in drawing section view. I attached the image for reference.AxisSelection.png

               

                   swModel.Extension.RunCommand swCommands_e.swCommands_ViewTemporaryAxes, Nothing 

                   >> I tried this code, it worked as in all the hidden axes were shown.

                        BUT, still not successfull in selecting the axis.

               

                     "Second, what you recorded probably looks something like this?"

                   >> Yes.

               

                   "What I found is that if you change <assembly component name> to Empty, and let IModelDocExtension::SelectByID2 use only the Type and XYZ arguments, the temporary axis is successfully selected."

                   >> My program(creating 2D using 3D templates) is expected to be used in different assemblies so changing the <assembly component name> is not an option for me. The component name should be passed as parameter when selecting an axis.

               

               

              Regards,

              Joecel

                • Re: Cannot select axis on Section View
                  Keith Rice

                  Joecel,

                   

                  No worries. Indeed, you can create section views in parts and assemblies like this:

                  Thank you for clarifying your problem. I see that you are not trying to select temporary axes but a standard reference axis. Thank you for the picture.

                   

                  Anyway, I am able to select the Axis just fine using IModelDocExtension::SelectByID2 like this:

                   

                  Dim swApp As Object
                  Dim swModel As Object
                  
                  Sub main()
                      Set swApp = Application.SldWorks
                      Set swModel = swApp.ActiveDoc
                      swModel.Extension.SelectByID2 "Axis1@Part2-1@Drawing View1", "AXIS", 0, 0, 0, False, 0, Nothing, 0
                  End Sub
                  
                  

                   

                  If I only specify "Axis1", however, it doesn't work.

                   

                  I have attached the SolidWorks 2014 model I am using.

                   

                  PS: I see you are no longer using a Hunger Games avatar... I am slightly sad!

                   

                  Keith

                  SolidWorks API Training

                    • Re: Cannot select axis on Section View
                      Joecel Torres

                      Hi Keith,

                      I regret to inform you that I am using SW 2013, I was able to open the .SLDPRT file but not the .SLDDRW  T_T

                      However, I noticed in your code snippet that the <component name> you used was "Drawing View1".

                      I want to clarify that I`m having problem selecting in a SECTION VIEW and NOT in drawing view.

                      My understanding is that a section view is a "projected" view from a drawing view right?

                      And the two are different entities in SW right? Please see the image below.

                      sectionViewVSdrawingView.jpg

                       

                      I also attached the a sample model and macro.

                      Macro1 - recorded while clicking/selecting the Axis1 on the 2D view.

                      Macro2 - recoded while clicking/selecting the Axis1 on the tree view.

                      There are two things I noticed on the code generated,
                      1. "Drawing View2" does not exist in the 2D file.
                      2. How come "Axis1@Part1-SectionAssembly-1-1@/Part1-1@Part1-SectionAssembly-1" path was generated?

                          I cannot see the "Section View A-A" where the Axis1 is located.

                       

                      Note: Both macro failed to select the Axis1.

                      When you have time, please try selecting the Axis1 while generating macro too.
                      Let`s see if we have the same code and result.

                       

                       

                      P.S. I decided to use our company logo for now but I`m still a Hunger Games fan 

                       

                      Regards,

                      Joecel