7 Replies Latest reply on May 7, 2018 7:58 AM by Balu N.

    HOW SELECT AND DISPLAY VERTEX IN PART FROM ITS XYZ COORDINATES

    Korbi Anis

      Hi friends ! how can I select and display vertex in part if I have its XYZ coordinates ! thanks

        • Re: HOW SELECT AND DISPLAY VERTEX IN PART FROM ITS XYZ COORDINATES
          Peter Brinkhuis

          Let me take this moment to ask you why all of your topic titles are in all caps? In looks like you're yelling. There's no need to do that.

           

          There are two ways that I use to select objects in a model, SelectByRay and SelectByID2. With SelectByRay, you first make sure a known view is used. Then you enter a location, a direction and a radius for selecting the object. For most cases this method isn't ideal, but sometimes it's just necessary.

           

          With SelectByID2, you enter the name of an object and/or its position, together with a type. I'd start with this one if I were you.

           

          2015 SOLIDWORKS API Help - SelectByRay Method (IModelDoc2)

          2015 SOLIDWORKS API Help - SelectByID2 Method (IModelDocExtension)

          • Re: HOW SELECT AND DISPLAY VERTEX IN PART FROM ITS XYZ COORDINATES
            Korbi Anis

            Hello friends ! when I tried to run this macro it does not work especially in the line : INSERTREFPLAN !!

            THIS THE MACRO :

            Set swApp = Application.SldWorks

             

                Set swModel = swApp.ActiveDoc

                Set swModelDocExt = swModel.Extension

             

             

            boolstatus = swModelDocExt.SelectByID2("POINTSKETCH@P ROUGE-1@Assemblage2radif", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)

             

             

                Set swSelMgr = swModel.SelectionManager

                Set swFeat = swSelMgr.GetSelectedObject6(1, -1)

                Set swSketch = swFeat.GetSpecificFeature2

                vPoint = swSketch.GetSketchPoints

                swModel.ClearSelection2 True

              

                

                If IsEmpty(vPoint) Then Exit Sub

             

                For i = 0 To UBound(vPoint)

                    Set swPOINT = vPoint(i)

                    swPOINT.Select4 True, Nothing

            Set swSelMgr = swModel.SelectionManager

            Set swPOINT = swSelMgr.GetSelectedObject6(1, -1)

                '-------------------------------------------------------SELECT FACE-----------------------------------------------------------'

             

             

            Set swApp = Application.SldWorks

            Set swModel = swApp.ActiveDoc

            Set swAssy = swModel

            Set swSelMgr = swModel.SelectionManager

            Set swSelData = swSelMgr.CreateSelectData

            lMark = 1

            Set swComp = swAssy.GetComponentByName("P ROUGE-1")

            Set swBody = swComp.GetBody

            If (swBody Is Nothing) Then

            swApp.SendMsgToUser "Component Body Unavailable."

            swApp.SendMsgToUser "Make sure not lightweight or suppressed"

            Exit Sub

            End If

            Set swFace = swBody.GetFirstFace

            Do While Not swFace Is Nothing

            sCurFaceName = swModel.GetEntityName(swFace)

            If sCurFaceName Like "R1" & "*" Then

            Set swEnt = swFace

            bRet = swEnt.Select4(True, swSelData)

            swSelData.mark = lMark

            lMark = lMark + 1

            End If

            Set swFace = swFace.GetNextFace

            Loop

            Set swSelMgr = swModel.SelectionManager

            Set swFace = swSelMgr.GetSelectedObject6(2, -1)

            '------------------------------------------------------INSERT REF PLANE ---------------------------------------------------------------------------------'

             

             

             

             

             

             

            Set swApp = Application.SldWorks

             

             

             

             

             

             

            Set swModel = swApp.ActiveDoc

             

             

            Set swModelDocExt = swModel.Extension

             

             

            Set swFeatureManager = swModel.FeatureManager

             

             

            Set swSelMgr = swModel.SelectionManager

             

             

             

             

             

            ' Create a constraint-based reference plane

             

             

             

             

             

             

            Set swRefPlane = swFeatureManager.InsertRefPlane(4, 0, 1, 0, 0, 0)

             

             

             

             

             

             

             

              Next i

             

             

             

            Thanks !!!