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:

Deleting Entities


Recommended Posts

You could probably make a VB script for the`at, but as far as doing in as a function in Mastercam, I don't think so.

 

If you have a bunch of edge curves to delete inbetween two boundaries, just delete a poly/window with intersect.

 

Use the window like a line and cross all the ones you need to delete. It works real fast.

 

 

Murlin

Link to comment
Share on other sites

I wrote this script in a couple minutes but it might be useful.

 

code:

' *******************************************************************************

' The sample source code contained in this file is provided by CNC Software, Inc.

' for demonstration purposes. It is provided on an 'as-is' basis and is not

' directly supported.

'

' CNC Software, Inc. grants you the right to use the source code in your projects

' and to freely re-distribute it to others.

' Copyright 2002-2004 CNC Software, Inc. All Rights Reserved.

' *******************************************************************************

 

' -- Start Script

Call Main()

 

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

' Sub Declaration

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

Sub Main()

 

Dim CLine

Dim bRet

Dim intLines, intEPtr

 

' -- Initialize

intLines = 0

 

' -- Test for active drawing

If IsDrawing Then

' -- Prompt user

If askYesNo("Delete all Vertical and Horizontal lines?") = mcMSG_NO Then Exit Sub

 

Call ResetAll

 

' -- Start searching the database, mask on lines

bRet = StartDBSearch(mc_alive, mc_linetype)

 

' -- Ok?

If bRet Then

 

Do

' -- Create an instance of our line ent

Set CLine = New McLn

 

' -- Store the current ent id

intEPtr = GetEntityEptr

 

' -- Get the current ent

If GetLineData(intEPtr, CLine) Then

 

If CLine.X1 = CLine.X2 Or CLine.Y1 = CLine.Y2 Then ' And CLine.Z1 = CLine.Z2

' -- Blow it away

If DeleteEntity(intEPtr) Then intLines = intLines + 1

End If

 

End If

 

' -- Keep searching....

Loop While NextDBSearch

 

' -- Update the display

Call RepaintScreen(True)

 

' -- Show some feedback

ShowString intLines & " lines deleted"

 

End If

 

End If

 

 

 

 

End Sub

 

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

' Function Declaration

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

 

Function IsDrawing()

IsDrawing = StartDBSearch(mc_alive, -1)

End Function

 

 

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

' Sub Declaration

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

Public Sub ResetAll

 

' -- Just to be sure

Call FreeChains

Call UnselectAll

 

End Sub

Link to comment
Share on other sites

Hi Code_Breaker,

 

There have been a few postings about that very subject and I did recommend this book to help get people like yourself started.

 

 

The are a number of resources, links etc in the Mastercam VBScript editors help file, to open the editor run the chook (ALT+C) mcamvb.dll and choose the New button, once the editor is open use the Help menu to access the above mentioned help file.

 

There are also a number of example scripts installed to your VB folder under your mcam9 install, these should also be helpful and this forum is a very good resource too, do a search for script for plenty of examples cheers.gif

Link to comment
Share on other sites

The title of the book is "Teach Yourself Windows Script Host in 21 Days" and its published by Sams. Windows Script Host, aka WSH, is the component of Windows that allows scripts to interact with Windows (read: the interpreter). These scripts are written in either Visual Basic Script (VBS) or JScript (actually JavaScript but Microsoft calls it JScript because it hates Sun's dreaded "J" word). There are other scripting languages like Perl, Python and Tcl that do not use the WSH and cannot be used to automate Mastercam.

 

In the case of Mastercam, the scripting language used is VBS. I've never read "Teach Yourself Windows Script Host in 21 Days" but I'm sure it's loaded with VBS snippets to get you started wink.gif

 

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