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:

VB Script for making points at all Intersections


Recommended Posts

I am thinking a script for making points at all intersection might be pretty easy. I think I remember a chook for doing this on all arc but I am thinking it might be very easy oy have one do this at all intersections.

 

What are anyone's thoughts on this and if you can throw one together to share to everyone would be cool. I am going ot mess around with it but since I am swaped and going on Vaction for 2 weeks the 22 might not get to it for a while.

 

As always thanks for any help or Ideas.

Link to comment
Share on other sites

A C-Hook would be much easier than a script since there aren't any entity intersection functions available to Mastercam VBS. In that case, you'd have to roll your own to look for intersections of lines and lines, lines and arcs, arcs and arcs and so on. For example, here's a function I quickly whipped up to test two lines to see if they intersect and which point they intersect at:

 

code:

' Purpose: Find the point of intersection of two Mastercam Line objects

' I: line 1

' I: line 2

' I/O: point of intersection

' O: True=intesect, False=doesn't intersect

Function LineIntersect2D(objLine1, objLine2, ByRef objIPoint)

Dim lTemp1

Dim lTempA

Dim lTempB

 

 

lTemp1 = ((objLine2.Y2 - objLine2.Y1) * (objLine1.X2 - objLine1.X1) - _

(objLine2.X2 - objLine2.X1) * (objLine1.Y2 - objLine1.Y1))

 

If (lTemp1 <> 0) Then ' not parallel to each other

' solve for the simultaneous equations

lTempA = ((objLine2.X2 - objLine2.X1) * (objLine1.Y1 - objLine2.Y1) - _

(objLine2.Y2 - objLine2.Y1) * (objLine1.X1 - objLine2.X1)) / lTemp1

 

lTempB = ((objLine1.X2 - objLine1.X1) * (objLine1.Y1 - objLine2.Y1) - _

(objLine1.Y2 - objLine1.Y1) * (objLine1.X1 - objLine2.X1)) / lTemp1

End If

 

If ((lTempA > 0) And (lTempA < 1) And (lTempB >) 0 And (lTempB < 1)) Then

' find the intersection point

objIPoint.X = objLine1.X1 + lTempA * (objLine1.X2 - objLine1.X1)

objIPoint.Y = objLine1.Y1 + lTempA * (objLine1.Y2 - objLine1.Y1)

 

' we have an intersection, folks

LineIntersect2D = True

Else

' move along, no intersection to see here

LineIntersect2D = False

End If

End Function

Loop through the database and compare all 2D lines using my above function. Because I'm returning a Mastercam Point object if an intersection is detected, you can use that point object with the CreatePoint() function to create the point you want. Create similar functions for comparing other entities and you're all set. But like I said, a C-Hook would be easier since there are already entity intersection functions available in the C-Hooks API.

Link to comment
Share on other sites

quote:

Ok but can we create chook using the Vb editor in Mastercam or do I still need the VB6 to do something like this?


For V8.x and V9.x, you can only use Microsoft Visual C++ 6.0 to create C-Hooks. You cannnot use Microsoft Visual Basic 6.0, Microsoft Visual Basic .NET or Mastercam VBS to create C-Hooks.

Link to comment
Share on other sites

Millman I would love this function in a Chook or script. As a Router guy I use points at intersections constantly to drill vacuum holes in fixtures. Would it be possible to have options like intersection of line color ? and Line color ?. I use one color for my vac groove cuts and another color for vertical table slots and another color for horizontal table slots.

Link to comment
Share on other sites

well to be honest I am thinking the color method would be the easy part of this equation. Calling colors from a Chook or Vb is very easy if you understand either which I have only scratched the suface of VB. Look to my Bounding box script I have the ability to selecet a level and a color to select just never got down the way to place it once they were selected but think I could not that I understand constants and Mastercam with using Mastercam Commands examples thanks to Rekd using a script to do Clipboard.

 

Chook or Vb I think I got a good time saving tool idea here and for those of use doing alot of holes to create points this way would be a real time saving tool where as in futher thought am I thinking we can create a way to not only make points from intersection but a way to store these to a buffer of sorts and then place them in a drilling operation or we could even do it in such a way where when we call the script not only do we got point creation we also get operation creation kind of like the method used in the solid drill where the operation are created via the parameters in the solid drill and you get all of the operation put in order as per what you have set up well in my crazy mind I amn thinking you could do the same thing Via the colors and the intersection creation with a filter control using question to point the operations to the creation of spot, drill tap or ream sircle mill or whatever you choose as part of the creation method of the script then when you call the script goes along the the APT part of script or the Chook method of something like ProDrill from what I have read about it and get creation od point for drilling to also have the operations created but by using the colors as you have suggeted give youself a time saving tool that is not only pratical but functional and time saving all in one call of the chook or script when used with a hot key.

 

Thad that one is for you 278 words in one paragraph think you might get a laugh out of that.

 

My 2 cents worth.

Link to comment
Share on other sites

Crazy Millman.....Wow...now you have my mind all blown to pieces. If only I understood everything you just said I would go in Monday and demand a raise!!haha The only thing I would have to do if this works is delete some of the holes so I wouldn't have too many in my fixture board. My boss already makes fun of me because I put twice the vac holes as anyone he knows. I figure it can't hurt right? More holes more volume is how I see it.

Link to comment
Share on other sites

Well Tommy you are 100% correct. What most people do not realize unless you have a very high pressure vacuum you need the voulme of air removed as well as the pressure in my opinion as well. The vacuum is good but if you try pullg a 4' x 8' area vacuum through 2 1" holes in my not not going to as effective as 40 1" holes. My thinking is that if you have little leaks then if the air is only getting pulled through a few holes the ends may not get as much pull wheree as if the pull is spead over the base as well as the part you will get much better results. I also would be considered over killing the amount of removed area for vacuum fixture but would rather to always air on the side of caution on pun intended. biggrin.gifbiggrin.gifbiggrin.gif

 

You do know about using the entites selction with all points wehn doing drilling operations and geomtery selection.

 

 

HTH

Link to comment
Share on other sites

~~~~~~~~~~~~~~

Why not just do a modify break at intersection and then do a screen endpoints?

 

You may want to copy the geo to another level first.

~~~~~~~~~~~

That was my first thought

But my solution will always catch only intersections .even when intersection same time the end entity of another entity IF YOU IN DRILLING OPTIONS DESELECT FILTER OUT DUPLICATES .

hth

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