5 Replies Latest reply on Jan 25, 2017 5:53 AM by Aleksandr Hohlatsov

    Vertex Position in View to Model Space

    Aleksandr Hohlatsov

      Hello,

      I select a vertex on drawing View and want to know it position in Assembly. How to do that? Is that possible?

      I ask it because transversing opperation is easy: I have 3D coordinates of point and can easily find it on view by ModelToViewTransform.

      But 2D to 3D!!!???

        • Re: Vertex Position in View to Model Space
          Viktor Bovzdarenko

          Hi Alexandr,

          Please look at this example: #CODE|Transform Drawing View To Assembly Coordinates

          If you select a vertex on drawing View the code will give you its position in Part and Assembly

          Regards

          Viktor

            • Re: Vertex Position in View to Model Space
              Dariusz Karcz

              Hi Victor,

              I've modified the code that you have posted, for now, I have urgent need to select face in drawing view, then make some stuff with selected face, this is my code so far (without cleanup yet):

               

              Dim swApp As SldWorks.SldWorks

              Dim swModel As SldWorks.ModelDoc2

              Dim swSelMgr As SldWorks.SelectionMgr

              Dim swVertex As SldWorks.Vertex

              Dim SwFace As SldWorks.Face2

              Dim swDraw As SldWorks.DrawingDoc

              Dim swMathUtils As SldWorks.MathUtility

              Dim swEnt As SldWorks.Entity

               

              Sub main()

                  Set swApp = Application.SldWorks

                  Set swModel = swApp.ActiveDoc

                  Set swMathUtils = swApp.GetMathUtility

                  Set swDraw = swModel

                  Set swSelMgr = swModel.SelectionManager

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

                   Dim swObjTYpe As Integer

                  swObjTYpe = swEnt.GetType

                

                  Dim swSafeEnt As Entity

                  Set swSafeEnt = swEnt.GetSafeEntity

                

                  Dim swComp As Component2

                  Set swComp = swEnt.GetComponent

                

                  Dim swCompPath As String

                  swCompPath = swComp.GetPathName

                

                  Dim swErr As Long

                  Dim swWarn As Long

                  Dim swOpt As Long

                  swApp.OpenDoc6 swCompPath, swDocPART, swOpenDocOptions_Silent, "", swErr, swWarn

                  swApp.ActivateDoc3 swCompPath, False, swOpt, swErr

                 swSafeEnt.Select2 False, -1

               

              and the question is about this line:

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

               

              how its is possible, that when will change index from 2 to 1, code fails?

              Could you explain to me, how come, that index is determining what is selected? there is no explanation of that in API help