Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

getting point coordinate with vbscript


Recommended Posts

Hello All

I'm trying to write a vbscript that will ask for a point and then return the values. I have been trying on my own with very little success.

I'm a bit confused with the GetPointData (EntityEptr as Integer,  Point as McPt) As Boolean

If anyone could point me in the right direction and possibly with a example script, it would be much appreciated.

Thanks, HollisT

Link to comment
Share on other sites
' Ask the user to select a point position 
' -- Start Script
Call Main()
'Call OtherAskPoint()

' Sub Declaration
Sub Main()
Dim objPoint
Dim strX, strY, strZ
Set objPoint = New McPt

' Prompt for a point location and fill a McPt with the result
If askPoint(objPoint) Then 
    ' Show the user some properties of this point
    With objPoint 
      strX = "X = " & FormatNumber(.X, 4, -1)
      strY = "Y = " & FormatNumber(.Y, 4, -1)
      strZ = "Z = " & FormatNumber(.Z, 4, -1)       
    End With     
    ShowString PointPickType & vbCrLf & "Point Coordinates" & vbCrLf & strX & vbCrLf & strY & vbCrLf & strZ
Else
    Call ShowString("No point selected")
End If

Set objPoint = Nothing
End Sub

' Another method of asking for a point position
Sub OtherAskPoint()
Dim strX, strY, strZ

if AskForPoint () Then
    ' Show the user some properties of this point
    strX = "X = " & FormatNumber(GetPoint(0), 4, -1)
    strY = "Y = " & FormatNumber(GetPoint(1), 4, -1)
    strZ = "Z = " & FormatNumber(GetPoint(2), 4, -1)    
    ShowString PointPickType & vbCrLf & "Point Coordinates" & vbCrLf & strX & vbCrLf & strY & vbCrLf & strZ    
Else
    Call ShowString("No point selected")
End If
End Sub

' Retrieve the point pick type "description"
Function PointPickType ()
    Dim str
    Dim ptType
   
    ptType = GetPointType ()
    Select Case ptType
        Case "1"
            str = "EndPoint #1"
        Case "3"
            str = "EndPoint #2"
        Case "C"
            str = "Center"
        Case "I"
            str = "Intersection"
        Case "K"
            str = "Sketch"
        Case "M"
            str = "MidPoint"                        
        Case "O"
            str = "Origin"
        Case "P"
            str = "Point"
        Case "U"
            str = "Quadrant"
        Case Else
            str = "UnKNown"
        End Select

    PointPickType = "*" & str & "*" ' returned
End Function

 

  • Like 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...