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:

VBScript-Automatic Drill Points on Screen


Recommended Posts

I try to write a VBScript file to automatically select and drill some points on screen. Let say there are 4 points (grey color) drawn on Mastercam screen and I like to use dia .250 drill to drill them. I attatched program below.

 

The program seems working. But there is a major flaw: After running it, it duplicate the existing points on screen at all the points' location. and the Drilling Operations in the Operations Manager is associated with the new points created. I want the dirlling association to go with the original points on the screen and do not want any extra points.

 

I kind of understand the reason. It must unintensionally created the new points when the program try to get the points' x,y,z coorditions in order to add necessary data to function, "AddDrillPoint". But that is only way I can think of select the points. Is any other way to select the points without creating new one? Maybe I can use function "SetEntityFromEptr()", but I don't know what Eptr mean. Thanks for helping me out.

[

Call Main()

 

Sub Main()

 

Call DRILL250()

 

End Sub 'END OF MAIN SUB

 

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

 

Sub DRILL250()

Dim intOperationID

Dim new_pt

Dim color_pt

Dim pointer, pre_pointer 'these variables for stopping the points searching at the end of loop

 

Call ZeroPts

 

If StartDBSearch(mc_alive,mc_pointtype) Then 'Start searching point with grey color

End If

Set new_pt = New McPt

If GetPointData(-1, new_pt) Then ' Get the coordinates of a current active point entity

End If

pointer=GetEntityEptr()

color_pt = GetEntityColor()

If color_pt = 7 Then

Call AddDrillPoint(new_pt.x, new_pt.y, new_pt.z)

End If

 

Do ' do while loop for searching all grey points and add them to drill list

pre_pointer = pointer

If NextDBSearch() Then

End If

pointer=GetEntityEptr()

If GetPointData(-1, new_pt) Then

End If

 

color_pt = GetEntityColor() 'Get the color of the current active entity

 

If color_pt = 7 Then

Call AddDrillPoint(new_pt.x, new_pt.y, new_pt.z)

End If

 

Loop While ( pointer <> pre_pointer)

 

SetDrillSortMethod(mcsort_xzmym)

intOperationID = MakeDrill ("My Drill Toolpath", .250, 118, 1, mcTOOL_drill) 'Apply drilling and return an operation Id

 

End Sub

]

 

Thanks

 

Kevin Qian

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...