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:

Visual Basic File for color selection


Recommended Posts

1> Look thru the sample VBS files in the Shared mcamx6\VB folder.

2> Look at the VBScript.htm file in the \Program Files\mcamx6\help folder.

 

' -- Search thr the database for entities 'by Color' --

' -- Start Script
Call Main()


' ///////////////
' Sub Declaration
' ///////////////
Sub Main()         

	Dim msg
Dim entityType
Dim bRet
Dim matchColor
Dim entityCounter
Dim pointCounter, lineCounter, arcCounter	
Dim searchSelMask 
Dim searchEntMask
Dim entityColor


if Not askColor(matchColor) Then
	Exit Sub
End If

' -- Initialize
entityCounter = 0
pointCounter = 0
lineCounter = 0
arcCounter = 0

searchSelMask = mc_alive 'Or mc_selected
searchEntMask = mc_pointtype Or mc_linetype Or mc_arctype

' -- Search through the database  looking 
' -- for all 'alive' Point/Lines/Arcs
bRet = StartDBSearch(searchSelMask, searchEntMask)

' -- Loop while we have something
Do While bRet								 
	entityCounter = entityCounter + 1

	entityColor = GetEntityColor()
	If (entityColor = matchColor) Then			

		' -- Find out what type of entity we have
		Select Case GetEntityType      
			Case mc_pointtype					
				pointCounter = pointCounter + 1

			Case mc_linetype 					
				lineCounter = lineCounter + 1

			Case mc_arctype 					
				arcCounter = arcCounter + 1       			
		End Select

	End If

	' -- Get next entity
	bRet = NextDBSearch    
Loop 

msg = "Total # of entities looked at = " & entityCounter & vbCrLf & vbCrLf _
& "Entities matching Color# " & matchColor & vbCrLf _
& "Points = " & pointCounter & vbCrLf _
& "Line = " & lineCounter & vbCrLf _
& "Arc = " & arcCounter
ShowString msg

End Sub

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