×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Coordinates of point - macro

Coordinates of point - macro

Coordinates of point - macro

(OP)
Hello.I'm working with SolidWorks API not so long.I try make, then find macro which allow get coordintes of point (for example of surface). I don't want vertex and edge point because this I know how get. I want get coordinates any point of surface... If You have any odeas and have time to help me I willbe greatful...

RE: Coordinates of point - macro

How will the point be located?  Will it be a sketch point that is selected by the user?  An arbitrary point closest to where the user clicked to select the surface?

RE: Coordinates of point - macro

(OP)
It willbe good when this point is the closest to where the user clicked to select surface, if it is possible...

RE: Coordinates of point - macro

Gets X, Y, Z of selection point in millimeters.  

CODE

Private Sub SurfPoint()
Dim swApp As SldWorks.SldWorks
Dim swDoc As SldWorks.ModelDoc2
Dim SelMgr As SldWorks.SelectionMgr
Dim NumSelects As Long
Dim SelectedObj As Object
Dim PickPoint As Variant
Dim StickPoint As Variant
Dim sMsg As String
Dim UnitFactor As Double

UnitFactor = 1000 'Get from m to mm

Set swApp = Application.SldWorks
Set swDoc = swApp.ActiveDoc
Set SelMgr = swDoc.SelectionManager

NumSelects = SelMgr.GetSelectedObjectCount
If NumSelects = 0 Then
    MsgBox "Pick a surface and run macro again"
    Exit Sub
End If


Set SelectedObj = SelMgr.GetSelectedObject(NumSelects)
PickPoint = SelMgr.GetSelectionPoint2(NumSelects, -1)
If SelMgr.GetSelectedObjectType3(NumSelects, -1) = 2 Then
    sMsg = "X: " & Str(PickPoint(0) * UnitFactor) & vbCrLf & _
            "Y: " & Str(PickPoint(1) * UnitFactor) & vbCrLf & _
            "Z: " & Str(PickPoint(2) * UnitFactor)
    MsgBox sMsg
Else
    MsgBox "You must select a surface"
End If




Set SelectedObj = Nothing
Set SelMgr = Nothing
Set swDoc = Nothing
Set swApp = Nothing

End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources