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:

How do you get a .ge3 file into X?


Patrik Warren
 Share

Recommended Posts

Bullines posted some vbx code a couple of weeks back.

 

It runs under Mcam9 and does sort of a 'read directory' on ge3 files.

 

You also get to choose location of the ge3's and the destination of the mc9's

 

Mcam9 will complain all the way through but the result will be that if you keep on pressing enter at the complaints, you will get the ge3's converted to mc9's

 

It sure beats 1 at a time !!!

Thanks again Bullines , I used it for approx 300 .ge3's

 

With Bulline's permission , I will post the latest code he emailed me

 

biggrin.gifcheers.gifbiggrin.gif

Link to comment
Share on other sites

It is common in many types of software to only support 2 version back. By supporting more then that you increase the costs of making the product while adding a function that a very small precentage of users would use. Better to spend the money on function most users use and getting the product out on time smile.gif

 

Sorry I had to add that last little dig.

Link to comment
Share on other sites

Just got back from a small vacation:

 

Here is Bullines code for those who can't access the ftp site.

 

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

' * Source Code : GE3_2_MC9.vbs *

' * Description : Convert GE3 files to MC9 format *

' * Date : 08/11/2005 2:37 PM *

' * Version : 0.0.1 *

' * Programmer : Christopher V. Bellini *

' * *

' * ---------------- *

' * | REVISION LOG | *

' *----------------------------------------------------------------------------*

' * Programmers Notes: *

' * - cvb (08/11/2005): V0.0.1 completed but not tested...no GE3 files frown.gif *

' * *

' * ///////////////////////////////////////////////////////////////////////////*

' * This library is free software; you can redistribute it and/or modify it *

' * under the terms of the GNU Lesser General Public License as published by *

' * the Free Software Foundation; either version 2.1 of the License, *

' * or (at your option) any later version. This library is distributed in the*

' * hope that it will be useful, but WITHOUT ANY WARRANTY; without even the *

' * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *

' * See the GNU Lesser General Public License for more details. *

' * *

' * You should have received a copy of the GNU Lesser General Public *

' * License along with this library; if not, visit: *

' * http://www.gnu.org/licenses/lgpl.txt or write to the Free Software *

' * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*

' * ///////////////////////////////////////////////////////////////////////////*

' *----------------------------------------------------------------------------*

 

Const DEF_GE3_EXT = "GE3"

Const DEF_MC9_EXT = "MC9"

 

Dim g_iDicIdx ' index for the dictionary object

 

Call Main()

 

' Purpose: the main subroutine

Sub Main()

Dim objFSO ' FileSystem object

Dim strSourceDir ' source directory with MC9 files to post

Dim strDestDir ' destination directory for posted NC code

Dim dicGE3 ' GE3 files to be converted

Dim objDicItem ' Dictionary item

Dim strMC9Fname ' MC9 filename of the current GE3

Dim iX ' counter

 

 

' prompt user for source directory containing MC9 files to be posted

Call ClearPromptLines()

Call WriteString("Select the source directory.")

strSourceDir = FolderBrowser("Select the source directory containing GE3 files.", "")

If (strSourceDir = vbNullString) Then

ShowString "Source directory for GE3 files was not selected. Exiting..."

Exit Sub

End If

 

' prompt user for source directory containing MC9 files to be posted

Call ClearPromptLines()

Call WriteString("Select the destination directory.")

strDestDir = FolderBrowser("Select the destination directory to put the MC9 files.", "")

If (strDestDir = vbNullString) Then

ShowString "Destination directory for MC9 files was not selected. Exiting..."

Exit Sub

End If

 

' init

g_iDicIdx = 0

 

' create a Dictionary object

Set dicGE3 = CreateObject("Scripting.Dictionary")

 

' get all of the GE3 files from the selected directory and its subdirectories

Call RetrieveGE3FilePaths(strSourceDir, dicGE3)

 

' loop through dictionary

objDicItem = dicGE3.Items

If (dicGE3.Count <> 0) Then

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

For iX = 0 To dicGE3.Count - 1

If (OpenMC(objDicItem(iX)) = False) Then ' can't open GE3 file

ShowString "Can't open " & objDicItem(iX)

Else

' Clear the current geometry and save the newly imported file

' as an MC9.

Call NewMC(False)

 

'Call ImportFile(objDicItem(iX))

If Not OpenMC(objDicItem(iX)) Then ShowString "Can't open the file: " & objDicItem(iX)

 

If (IsDrawing()) Then

strMC9Fname = strDestDir & "" & objFSO.GetBaseName(objDicItem(iX)) & _

"." & DEF_MC9_EXT

 

If (SaveMCAs(strMC9Fname, True) = False) Then

ShowString "Unable to save: " & strMC9Fname

End If

Else

ShowString "No geometry in file: " & objDicItem(iX)

End If

End If

Next

 

' Cleanup

Set objFSO = Nothing

Else

ShowString "No GE3 files found."

Exit Sub

End If

 

End Sub

 

 

' Purpose: Prompt the user to select a directory and retrieve the selected path

' I: prompt to give the user on the directory selection dialog

' I: directory to start looking in

' O: string containing the directory selected (vbNullString if there's an error)

Function FolderBrowser(strPrompt, strStartFolder)

Const DEF_WINDOW_HANDLE = 0

Const DEF_NO_OPTIONS = 0

Dim objShell ' Shell Application object

Dim objFolder ' Folder object

Dim objFolderItem ' FolderItem object

 

 

On Error Resume Next

 

' Create Shell Application, Folder and FolderItem objects

Set objShell = CreateObject("Shell.Application")

Set objFolder = objShell.BrowseForFolder(DEF_WINDOW_HANDLE, strPrompt, DEF_NO_OPTIONS, strStartFolder)

Set objFolderItem = objFolder.Self

 

' Return a null string if there was an error

If Err.Number <> 0 Then

FolderBrowser = vbNullString

Err.Clear

Exit Function

End If

 

' Return the selected directory

FolderBrowser = objFolderItem.Path

 

' Cleanup

Set objShell = Nothing

Set objFolder = Nothing

Set objFolderItem = Nothing

End Function

 

 

' Purpose Retreives full path of all files in a directory and optionally in sub

' directories as well

' I: directory of files

' I/O: Dictionary object containing full paths of all files

Sub RetrieveGE3FilePaths(ByVal strDir, ByRef objDic)

Dim objFSO

Dim objFolder

Dim objFileCollection

Dim objFolderCollection

Dim objItem

Dim objSubFolder

 

 

' create an FSO object

Set objFSO = CreateObject("Scripting.FileSystemObject")

 

On Error Resume Next

Err.Clear

 

Set objFolder = objFSO.GetFolder(strDir)

 

If Err.Number = 0 Then

On Error GoTo 0

Set objFileCollection = objFolder.Files

 

' Determine maximum length of a filename

For Each objItem In objFileCollection

' only add MC9 files to our dictionary

If (UCase(objFSO.GetExtensionName(objItem.Name)) = DEF_GE3_EXT) Then

g_iDicIdx = g_iDicIdx + 1

objDic.Add g_iDicIdx, strDir & "" & objItem.Name

End If

Next

 

' comment this out if we don't need to go into sub dirs

Set objFolderCollection = objFolder.SubFolders

' process each subdirectory within the current directory

For Each objSubFolder In objFolderCollection

' recursive call to process a subdirectory

Call RetreiveFilePaths(objSubFolder.Path, objDic)

Next

 

' cleanup

Set objItem = Nothing

Set objFileCollection = Nothing

Set objSubFolder = Nothing

Set objFolderCollection = Nothing

Else

MsgBox "GetFolder Error" & vbLf & _

Err.Description & "(" & Err.Number & ")" & vbLf & _

strDir, vbCritical

On Error GoTo 0

End If

 

' cleanup

Set objSubFolder = Nothing

Set objFolder = Nothing

Set objFSO = Nothing

End Sub

 

 

' Purpose: determine if the current file contains something...anything

' I: (none)

' O: True=yes, False=no

Function IsDrawing()

Dim bRet

 

bRet = StartDBSearch(mc_alive, -1)

 

UnselectAll

 

IsDrawing = bRet

End Function

 

 

******************************

cheers.gif

 

cp

  • Like 1
Link to comment
Share on other sites
  • 1 year later...

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