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:

Accessing the Post through VB script.


Recommended Posts

David H,

 

I am not sure if this is what you are after but it may help. Basically I have a drawing with a number of operations, one of them is a drilling operation with a comment of Drilling. This comment is important because this is the name the script function used in the example below assigns.

 

Let me know of this helps.

 

' ==== Begin Code Sample ======


' -- Start Script

Call Main()

 

' ////////////////////

' Sub Declaration

' ////////////////////

Sub Main()

 

Dim intCount

Dim i

Dim strOpName

Dim blnOpFound

 

' -- Clear screen

Call NewMC(False)

 

' -- Refresh

RepaintScreen True

 

' -- Flag

blnOpFound = False

 

' -- Open my test drawing, you will need to edit path to suit.

If OpenMC("C:Mcam9RouterMC9OPS TEST.MC9") Then

 

' -- Set the post, edit path to suit.

SetPostName "C:Mcam9RouterPOSTSMPROUTER.pst"

 

' -- Get a count of all operations in this drawing

intCount = GetOperationCount("C:Mcam9RouterMC9OPS TEST.MC9")

 

' -- Iterate all operations

For i = 1 To intCount

' -- Get an operation name.

' -- NOTE: This Name Is derived from the comment field when adding an operation

' -- for my example I added a drilling operation with a comment of Drilling

strOpName = GetOperationNameFromID("C:Mcam9RouterMC9OPS TEST.MC9", i)

' -- Look for our operation name (comment field)

If StrComp("Drilling", strOpName) = 0 Then

' -- Set flag

blnOpFound = True

' -- Ok we have it so output the drilling operation only.

If Not RunPost(i, "C:DrillTest.nc", True) Then

ShowString "Could not post operation"

Exit Sub

End If

End If

Next

 

' -- Did we find the operation we were looking for?

If Not blnOpFound Then

ShowString "Operation 'Drilling' not found"

End If

 

 

Else

ShowString "Could not open drawing"

End If

 

 

End Sub

 

====== End Code Sample =====

 

[ 04-17-2003, 07:58 PM: Message edited by: VBS ]

Link to comment
Share on other sites

Hello David H,

 

I see what you need to do. You will need to use the following function. This definition was taken from the VBScript html file accessable from the editors help menu.

 

// import an operation by name and apply it to the currently selected points or chains

// this function returns an operation ID # or mcOPERATION_INVALID

Integer MakeOperationFromName (

String, (Input: name of external MC9 or OP9 file containing toolpath operations

or “” for the currently open MC9 file)

String (Input: operationName)

String (Input: new operation comment)

)

 

I assume you will need to use an existing drilling operation from your *.OP9 file and then apply it to the selected points in the open drawing. To select points in a current drawing you can use the following code as a guide.

 


 

' -- Start Script

Call GetPoints()

 

 

' ////////////////////

' Sub Declaration

' ////////////////////

Sub GetPoints()

 

Dim intCount

Dim bRet

 

' -- Refresh

RepaintScreen True

 

' -- See if we can find a point

bRet = StartDBSearch(mc_alive, mc_pointtype)

 

' -- Found one?

If bRet Then

' -- Change its colour

SetEntityColor mcCOLOR_RED

 

' -- See if there are anymore

Do

' -- Get the next point

bRet = NextDBSearch()

' -- Keep a running total

intCount = intCount + 1

' -- Change this points colour

SetEntityColor mcCOLOR_RED

 

' -- Keep going until there are no more points found

Loop While bRet

 

Else

ShowString "No points found in drawing"

End If

 

' -- Refresh

RepaintScreen True

 

' -- How many points selected?

If intCount > 0 Then

ShowString intCount & " points selected"

End If

 

' -- unselect all selected points

Call UnselectAll

 

End Sub

 

Also take a look at the example script ops test.vbs on how to build a list of all available operations in your op9 file(s).

 

[ 04-18-2003, 01:56 PM: Message edited by: VBS ]

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