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


Denis Blain
 Share

Recommended Posts

I want to write an application where there is a variable amount of entities to which I have to paste an operation to.

The only way I can think of is to iterate through the entites that match certain criteria such as the level or the color then connect them with an operation already saved in an OP9 file.

Since I did a lot of programming in VB, VBA and VB Script I would like to to it in this language as well.

 

Any idea?

Link to comment
Share on other sites

Denis,

 

This sounds like you are looking at layer (level) mapping, map an operation or operations to a specific level. The process of mapping to a level is actually pretty simple using Mastercam VBScript.

 

If you are creating the geometry before you want to apply operations then I would highly recommend your creating named levels before creating geoemtry, this makes it dead easy to then go back and select entites on a specific level. You would use a combination of the following;

 

code:

' -- Set layer to inside geo, this makes it easy to select it later for machining

Call SetLevelName(2, "Inside Contour")

The above code creates a named level called Inside Contour on level number 2. You would then create the applicable geometry on that level before moving on to another SetLevelName call to create more geometry and so on..

 

The code below would be used to select all the entities on a named level:

 

code:

' -- Select the inside contour

If ChainAll(True, True, 2, "Inside Contour") Then

' -- Apply our saved operation

If MakeOperationFromName("C:mcam9RouterOPSMyOps.op9", "Inside Contour Route", "Added by VBScript", ovOverRides) = mcOPERATION_INVALID Then

The call to MakeOperationFromName will apply the saved operation called "Inside Contour Route" located in the OP9 library called MyOps.op9 and apply it to the selected entities. A return value of mcOPERATION_INVALID means there was a problem otherwise the new operation Id would be returned. The variable ovOverRides is an object variable of type mcOverRides this allows you to over-ride the speeds, feeds and depth of cut that is stored in the specified operation.

 

If you need to select points and arcs then you would want to use the SearchDB functions.

 

code:

' -- Lets select something

bRet = MarkWindow(sPrompt, mc_arctype, mcWINDOW_INSIDE)

 

' -- Assume no arcs

bHaveArcs = False

 

If bRet Then

' -- Loop through and see what was selected

bRet = StartDBSearch(mc_selected, mc_arctype)

 

Do While bRet

' -- Create a new arc object

Set CArc = New McAr

' -- Get this arc

If GetArcData(-1, CArc) Then

' -- Add this arc to the points list

AddArcPoint CArc.X, CArc.Y, CArc.Z, CArc.R, CArc.SA, CArc.SW

' -- Flag it

bHaveArcs = True

End If

 

' -- Get another arc

bRet = NextDBSearch

Loop

 

' -- Did we get any arcs?

If bHaveArcs Then

' ---- Lets do something with them...

*** NOTE *** To use a saved operation you must have saved it with a comment, this is the only way we can get an operation from an OP9 library.

Link to comment
Share on other sites

Hey if you guys don't mind me asking where did you learn the Vb at. I am learning MP out of the need and desire to use it more effective posts and things of that such. I can also see the need for things to automate like in Access and Excel and thinks the thing I have found for that are cool. I can think of alot fo thing I would like to do but to get there from a Basic background to the VB without soem schooling ro the stuff needed to d oit right seem near impossible. Am I wrong or would a developers kit be the thing I need to get an understand of using VB.

 

 

 

Crazy Millman

Link to comment
Share on other sites

Millman,

 

I started teaching myself Basic (MSDOS) when I created that proggie to do the sub programs. It was out of necessity but moved quickly into desire.

 

There's plenty of on-line places to get tutorials if you want to dive in. (Guarenteed you'll like it) I learned on my own, thru trial and error. No school, no books, no nuthin. I bought VB 6 a few years ago and have been going wild ever since.

 

Since then I've picked up several books as references, but to learn, you don't need anything but the IDE (in Access, Excel, Word etc, hit ALT-F11 to open the IDE).

 

'Rekd

Link to comment
Share on other sites

Millman^Crazy,

 

I highly recommend your searching for some evening classes at a local college or computer centre that can give you a good introduction to VB programming, syntax, fundamentals and so on. Once you have that under your belt it will make learning on your own a lot more productive and fun.

 

I personally like to pick up programming books whenever and wherever I see them, Comp USA, for example, always seem to have a half dozen or so VB programming books for $15, well worth the dollar investment.

 

There are also a number of VB weblinks located in the Mastercam VBScript editors help file that will certainly be of help, and there is always this forum biggrin.gif

Link to comment
Share on other sites

Thnaks guys been doing the internet thing and got some really cool scripts and turtorials from everything to making calanders, toolbars and button dialog boxes. I have been playing just time is real short and tryign to get ready for the new machines, got this real pain in but job trying to get straighten out for Boeing, getting ready to be a dad again, do all the quoting, programming, ordering for my part of the company, and other general put of problems things that coem across for me to solve. I think after the first of the year I will have soem time to go take a class I would like to be able to get soem college credit one done to be clsoer to my AS in engineering about 8 credit hours short right now.

 

Well I appericate the advice guy and think is soemthing I can figure out just have to make the time and get it done and right got more important thing to need my attention. Besides if I get stuck you guys have been a great help and I appercaite it as always.

 

Crazy Millman

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