1 post, 2 file extensions...

1 post, 2 file extensions...

DarthBane55
Advisor Advisor
357 Views
5 Replies
Message 1 of 6

1 post, 2 file extensions...

DarthBane55
Advisor
Advisor

Hi, I have a hurdle that I can't figure out.  I have created a property that dictates if the post should output in 3-axis or 5-axis mode.  This happens with a property as seen below: 

1.png

 

I want to change the file extension depending on that mode.  For 3-axis it should be *.RBD, as seen on pic above.  For 5-axis, it should be *.RBX.

I wrote this code:

if (properties.A__Has_5Axis){
	extension = "RBX";
} else {
	extension = "RBD";
}

But it has no effect, I don't think it can read from the property when it is changed during posting.  Right it uses the extension RBD for 3 or 5-axis mode.

Is there a way to do this?

Thanks!

0 Likes
Accepted solutions (1)
358 Views
5 Replies
Replies (5)
Message 2 of 6

kevinastrom
Contributor
Contributor

@DarthBane55 Have you tried moving the code you've written to a line after the property definitions?

 

Also, it might be easier to remove the extension definition from the post and type the desired extension into the input field in the NC Program.

0 Likes
Message 3 of 6

DarthBane55
Advisor
Advisor

Ya, I tried that, but it had no effect.

This made me realize that I don't know what makes the post actually write the g-code file!  I can't find a command that creates a file or anything like that... If I knew that, I think maybe I could do something about this issue.

Maybe the file is created before it reads the properties, and it's too late to change the extension, I really don't know...

0 Likes
Message 4 of 6

boopathi.sivakumar
Autodesk
Autodesk
Accepted solution

Hi @DarthBane55 

"extension" is a global property you cannot set the extension in any of the section in the post processor.

As workaround what you can do is you can create a logic in the onTerminate function to copy paste the output file with different extension based on the property you have selected.

function onTerminate() {
  if (properties.A__Has_5Axis) {
    var outputPath = getOutputPath();
    var programFilename = FileSystem.getFilename(outputPath);
    var name = String(programFilename).split("." + extension);
    var newFolder = getFolderPath(outputPath) + "\\" + name[0] + ".RBX";
    FileSystem.copyFile(outputPath, newFolder);
    FileSystem.remove(outputPath);
  }
}

The one problem will be here is though we are removing the original nc file you may get error saying that the nc file is not found.


Boopathi Sivakumar
Senior Technology Consultant

Message 5 of 6

DarthBane55
Advisor
Advisor

@boopathi.sivakumar 

wow, that worked!  Thank you very much!

Few questions still:

I do set the extension in the post, all my posts have this at the beginning, which sets the extension:

minimumRevision = 24000;
longDescription = "Generic post for Fanuc.";
extension = "RBD";
programNameIsInteger = false;
setCodePage("ascii");

-Did you mean that yes, it is set in the post, but you cannot change it in code after it is set?  And we cannot set it with "if" statements neither, I guess it reads this at the very beginning and already creates the file name maybe?

-I did not get an error about the missing .nc file (I never have a .nc file as I set the extensions to something else based on what machine the program is for), but, I get the log to output and not delete itself.  Usually, the log deletes itself if there are no errors.  Do you have a way to do this?  Otherwise, not bad, we'll get used to delete it.

 

But all in all, your solution did the trick, thank you very much!

 

0 Likes
Message 6 of 6

boopathi.sivakumar
Autodesk
Autodesk

-Did you mean that yes, it is set in the post, but you cannot change it in code after it is set?  And we cannot set it with "if" statements neither, I guess it reads this at the very beginning and already creates the file name maybe?


Yes extension cannot be changed in the code after it is and it is defined as a global variable. So you cannot make a logic to check against the property which is not available at the moment.


Boopathi Sivakumar
Senior Technology Consultant