1 Reply Latest reply on Sep 12, 2014 10:48 AM by Jesse Seger

    C# Extension.SelectByID2

    Ravindra Thorat

      Hi

       

      I want to Select the Face of Part to Create another shape on the Surface of Part. What Co-ordinates are to Be selected in Select By ID 2.

      boolstatus=swDoc.Extension.SelectByID2(" ","Face",-4.62,205.499,-2.47,true,1,null,0)
      4.62,205.499,-2.47 on what Basis these Co_ordinates to Be Selected.

       

      Please Help.

        • Re: C# Extension.SelectByID2
          Jesse Seger

          Below is an exert from the api help.

           

          "If you are using the Name parameter, then specify the XYZ coordinates in terms of the context where the item was created. For example, if you want to select a sketch point using its name (for example, "Point1") in the Name argument, then specify XYZ in terms of the sketch where the point was created. Even if the sketch is not active, specify the XYZ values in terms of sketch space when you use the Name parameter. In certain situations, you can also pass in the XYZ coordinates as simply ( 0,0,0 ). For example, to select a feature shown in the FeatureManager design tree, you do not need to specify an XYZ coordinates. However, to select objects such as notes or faces, or when you need a point location picked, you must specify the XYZ coordinates. If you are not using the Name parameter as a filter, then specify the XYZ coordinates in terms of model space. "

           

          The best thing to do is give a name to your face.  Right click on your face, click properties in the face section, and give it a name.  Then use PartDoc:GetEntityByName to select your face.

           

          Untitled.png

           

          Capture2.PNG

           

           

          And here is the code....

           

          Dim swApp As SldWorks.SldWorks

          Dim swModel As ModelDoc2

          Dim swPart As PartDoc

          Dim swFace As Face2

          Dim swSelMgr As SelectionMgr

          Dim swSelData As SelectData

           

           

          Sub main()

           

           

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swPart = swModel

              Set swSelMgr = swModel.SelectionManager

             

              Set swFace = swPart.GetEntityByName("FaceForFeature", swSelectType_e.swSelFACES)

                 

              If Not swFace Is Nothing Then

                  swApp.SendMsgToUser "Found face"

                  swModel.ClearSelection

                  Set swSelData = swSelMgr.CreateSelectData

                  swSelMgr.AddSelectionListObject swFace, swSelData

              Else

                  swApp.SendMsgToUser "Couldn't find face"

              End If

           

           

          End Sub