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:

Changing "X- " to X+"


?Mark
 Share

Recommended Posts

We have a bunch of old programs we run on a mori lathe which have an opposite x axis direction then our new mori. Is there an editor that could handle flipping the program from x- to x+ together with adjusting G2 and G3 codes.

headscratch.gif

 

Any suggestion will be appreciated.

 

Regards, Mark

Link to comment
Share on other sites

Mark,

 

I'm sure you could find a text editor with macro capability. But you could probably create a VB Script program (a more robust solution) in less time than it would take to figure out the macro programming for that editor.

 

Also don't forget about the 'I' on the G2/G3 blocks if you are using that format. You may need to flip the signs on them.

Link to comment
Share on other sites

quote:

We have a bunch of old programs we run on a mori lathe which have an opposite x axis direction then our new mori. Is there an editor that could handle flipping the program from x- to x+ together with adjusting G2 and G3 codes.

We started out a long time ago with some old Mori lathes.

They too were X- (away from spindle).

We have purchased many new Mori's and we just have parameters and what not changed to X- so we don't run into this.

 

Many of times I have to take a rotab program from a vertical and swap everything over to run on a rotab horizontal.

I end up doing it in the editor much like mayday described. wink.gif

Link to comment
Share on other sites

quote:

Is there a parameter on the machine to change the x direction.

No, it is hard wired.

 

quote:

I'm sure you could find a text editor with macro capability

We currently use cimco editor that came with mc.

Anyone aware if upgrade could handle this task?

 

headscratch.gif

 

Mark

Link to comment
Share on other sites

I just flipped one like that the other day, it went from a vertical to a horizontal. im not sure there is a fool proof way. i just did one axis at a time

ie: changed all x's to x- which would give you x-- on some values then changed all x-- to x. same with y,i,j,k. i know there is a website with a utility on it i will also look for that

Link to comment
Share on other sites

quote:

Also don't forget about the 'I'

Thanks Roger I remember this, thats why i'm looking for something that is fool-proof.

As for vb scripting i just wish i had time to learn it...

banghead.gifbanghead.gif

 

The solution to change X G2 G3 ... one at a time works good when done one program at a time, this way we can visualy check if all looks good, but doing hundreds gives me headache just thinking about it...

 

Mark

Link to comment
Share on other sites

I put this together pretty quickly so it might not be perfect but it seemed to work ok with what I tested it on. Feel free to play with it.

 

The script will prompt for an NC file, when run the script will create a new file called switched.nc and it will be saved to your NC folder depending on what module you run this from. You might want to edit the script to prompt for a new file name or parse the selected file and append something to the name so it is easily recognized.

 

 

code:

Call Main

 

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

' Sub Declaration

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

Sub Main()

 

Dim strOriginal

Dim strSwitched

Dim strLineToRead, strCleanedLine

Dim FSO, fsoDirty, fsoClean

Dim intX, intXminus

 

 

Set FSO = CreateObject("Scripting.FileSystemObject")

 

' -- Prompt for a file

If AskForFileName("*.NC", mcFILE_ACCESS_READ, strOriginal) Then

 

' -- Make sure it really does exist

If FSO.FileExists(strOriginal) Then

 

' -- Open the File

Set fsoDirty = FSO.OpenTextFile(strOriginal)

 

' -- Build path to our output file

strSwitched = GetPathFromExtension("NC")

 

' -- You may want to expand on the name here....

strSwitched = AddBackSlash(strSwitched) & "switched.nc"

 

' -- Open our clean file

Set fsoClean = FSO.CreateTextFile(strSwitched)

 

With fsoDirty

 

Do While Not .AtEndOfStream

 

' -- Get a line from the file

strLineToRead = .ReadLine

 

If Len(Trim(strLineToRead)) > 0 Then

 

intX = InStr(1, strLineToRead, "x", vbTextCompare)

intXminus = InStr(1, strLineToRead, "x-", vbTextCompare)

 

' -- initialize

strCleanedLine = vbNullString

 

' -- Check for a minus first!!

If intXminus > 0 Then

strCleanedLine = Replace(strLineToRead, "X-", "X")

 

ElseIf intX > 0 Then

strCleanedLine = Replace(strLineToRead, "X", "X-")

 

Else

strCleanedLine = strLineToRead

End If

 

' -- Write to our file as is

fsoClean.WriteLine strCleanedLine

 

Else

' -- Write to our file as is

fsoClean.WriteLine strLineToRead

End If

 

 

Loop

 

.Close

 

fsoClean.Close

 

End With

 

Call EditFile(strSwitched)

'Call EditFile(strOriginal)

 

Else

ShowString "Could not open file for editing"

 

End If

 

End If

 

 

 

Set FSO = Nothing

Set fsoClean = Nothing

Set fsoDirty = Nothing

 

End Sub

 

 

 

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

' Function Declaration

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

 

Function AddBackSlash(sPath)

 

If Right(sPath, 1) <> "" Then sPath = sPath & ""

AddBackSlash = sPath

 

End Function

Link to comment
Share on other sites

O'k now, I greatly appreciate your help but without soundng too stupid (wouldn't be a first time) what do I do with this file?

I understand its vb script and I know I can run it from within mc, but how do i do it?

 

headscratch.gif

 

Kind regards to guys from CNC Software

Mark

Link to comment
Share on other sites

*NOTE*

If you downloaded FLIP.ZIP prior to 5:40pm (Eastern Time) there is a bug in that version of FLIP.VBS

 

I’ve replaced the FLIP.ZIP on the forum FTP with the corrected version.

 

The problem was here is this section of code...

code:

If intIminus > 0 Then

strLine = Replace(strLine, "I-", "I")

ElseIf intX > 0 Then

strLine = Replace(strLine, "I", "I-")

End If

the line “ElseIf intX > 0 Then” should read “ElseIf intI > 0 Then”

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