找回密码 注册 QQ登录
一站式解决方案

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 21551|回复: 12
打印 上一主题 下一主题

[分享] GPP2分割和重命名文件的方法

[复制链接]
跳转到指定楼层
1
发表于 2010-11-8 22:39:25 | 只看该作者 回帖奖励 |正序浏览 |阅读模式

马上注册,结交更多同行朋友,交流,分享,学习。

您需要 登录 才可以下载或查看,没有帐号?注册

x
中英文合并多看几遍也就看懂了。
希望对有些人有用。


一,分割

Anyway, this all revolves around the [size=105%]CUT_FILE system variable.
[size=105%]CUT_FILE系统变量正是这么做的,它减少了输出文件。
The [size=105%]CUT_FILE system variable does exactly that, it cuts the output file.
您将执行以下行添加到您的邮寄方式:
You would implement it by adding the following line to your post:

[size=105%]CUT_FILE = [size=105%]TRUE_;
[size=105%]CUT_FILE = [size=105%]TRUE_ ;

当GPP2发布引擎看到这个变量的值被设置为这个[size=105%]TRUE_,下列事件发生:
When the GPP2 posting engine sees that the value of this variable has been set to [size=105%]TRUE_ , the following events occur:


  • 后跳转到[size=105%]磁带的末尾作者:beforecut:块,并执行代码中有。
    The post jumps to the [size=105%]END OF TAPE: beforecut: block, and executes the code there.
    这是您将添加代码以启动行输出任何你需要在新的文件。
    This is where you would add code to output any startup lines you'll need in the new file.
    你很可能需要添加到您的文章这个区块,因为它是不包括在标准职位。
    You will most likely need to add this block to your post, as it is not included in the standard posts.
  • 切割后的G代码文件,并启动一个新的文件。
    The post cuts the g-code file and starts a new file.
  • 后跳转到[size=105%]磁带的开头作者:aftercut:块,并执行代码中有。
    The post jumps to the [size=105%]BEGINNING OF TAPE: aftercut: block, and executes the code there.
    这是您将代码添加到文件中的行输出任何的结束时,您将需要在您的新文件。
    This is where you would add code to output any end of file lines you'll need in your new file.
    再次,你最有可能需要添加到您的文章这个区块,因为它是不包括在标准职位。
    Once again, you will most likely need to add this block to your post, as it is not included in the standard posts.
  • 变量值的[size=105%]CUT_FILE系统重新设置为[size=105%]FALSE_。
    The value of the [size=105%]CUT_FILE system variable is set back to [size=105%]FALSE_ .

因此,如果添加[size=105%]CUT_FILE = [size=105%]TRUE_代码?
So, where to add the [size=105%]CUT_FILE = [size=105%]TRUE_ code?
那么,你要削减在刀具路径,所以你有两个选择。
Well, you want to cut at the toolpath, so you have two options.


  • [size=105%]年初[size=105%]TLPATH:
    The [size=105%]BEGINNING OF TLPATH: block
  • [size=105%]刀具路径[size=105%]会期:
    The [size=105%]END OF TOOLPATH: block

起初,你可能认为[size=105%]刀具路径会期:块将是最好的,因为它似乎是有意义的每缩短刀具路径的文件结尾。
At first, you might think the [size=105%]END OF TOOLPATH: block would be best, as it would seem to make sense to cut the file at the end of every toolpath.
不幸的是,这将增加在您的文件非常切成末,几乎没有给你一个额外的文件,如果任何代码。
Unfortunately, this would add a cut at the very end of your file, giving you an extra file with little, if any code in it.
因此,我们将不得不[size=105%]使用TLPATH开始:块。
So we'll have to use the [size=105%]BEGINNING OF TLPATH: block.
同一类型的问题,虽然在这里存在,因为我们不希望在削减后的第一刀路文件开始,所以我们需要做一个计数器来计算刀具路径,并在第二次才开始切割toolath。
The same type of problem exists here though, as we don't want the post to cut the file at the beginning of the first toolpath, so we'll need to make a counter to count the toolpaths, and only start cutting at the second toolath.
所以,首先你需要做的就是定义一个[size=105%]序列变量叫[size=105%]TPCOUNTER来计算刀具路径。
So the first thing you'll need to do is define a [size=105%]SEQUENCING variable called [size=105%]TPCOUNTER to count the toolpaths.
你一定想一[size=105%]开始就设置变量1 [size=105%]磁带的初始这个值[size=105%]块。
You'll want to set the initial value of this variable to 1 in the [size=105%]BEGINNING OF TAPE: block.
有一个在这个地方很多的变量初始化块的底部,所以只添加了那里。
There is a section at the bottom of this block where a lot of variable are initialized, so just add it there.

现在去你的[size=105%]开头TLPATH:块(此区块员额的标准在所有E8.5SP2P2,但需要被添加到旧文章),并添加以下行:
Now go to your [size=105%]BEGINNING OF TLPATH: block (this block is standard in all the E8.5SP2P2 posts, but will need to be added to older posts), and add the following lines:

[size=105%][size=105%]中频(TPCOUNTER“1)
[size=105%][size=105%]IF ( TPCOUNTER > [size=105%]1 )
[size=105%][size=105%]CUT_FILE = [size=105%]TRUE_;
[size=105%][size=105%]CUT_FILE = [size=105%]TRUE_ ;
[size=105%][size=105%]END_IF;
[size=105%][size=105%]END_IF ;
[size=105%]TPCOUNTER = TPCOUNTER + [size=105%]1;
[size=105%]TPCOUNTER = TPCOUNTER + [size=105%]1 ;


——www.jt258.com
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏3 分享淘帖 赞一下!赞一下!
13
发表于 2018-11-6 18:35:27 | 只看该作者
谢谢分享
12
发表于 2018-6-23 02:36:04 | 只看该作者
谢谢分想,谢谢
11
发表于 2015-10-29 17:10:43 | 只看该作者
不知道gpp能否使用呢
10
发表于 2015-10-21 18:38:07 | 只看该作者
这个中英文看的蛋疼。。
9
发表于 2013-11-19 22:31:32 | 只看该作者
  惭愧 看不懂英文。。。。。。。。。
8
发表于 2010-11-9 17:43:00 | 只看该作者
这个中英文看的蛋疼。。
7
发表于 2010-11-9 14:04:26 | 只看该作者
6
发表于 2010-11-9 07:26:42 | 只看该作者
呵呵,你这个谁都看不懂,机器翻译的吧?反而不如直接看英文原文:
Anyway, this all revolves around the CUT_FILE system variable. The CUT_FILE system variable does exactly that, it cuts the output file. You would implement it by adding the following line to your post:

    CUT_FILE = TRUE_ ;

When the GPP2 posting engine sees that the value of this variable has been set to TRUE_, the following events occur:

The post jumps to the END OF TAPE: beforecut: block, and executes the code there. This is where you would add code to output any startup lines you'll need in the new file. You will most likely need to add this block to your post, as it is not included in the standard posts.
The post cuts the g-code file and starts a new file.
The post jumps to the BEGINNING OF TAPE: aftercut: block, and executes the code there. This is where you would add code to output any end of file lines you'll need in your new file. Once again, you will most likely need to add this block to your post, as it is not included in the standard posts.
The value of the CUT_FILE system variable is set back to FALSE_ .

So, where to add the CUT_FILE = TRUE_ code? Well, you want to cut at the toolpath, so you have two options.

The BEGINNING OF TLPATH: block
The END OF TOOLPATH: block

At first, you might think the END OF TOOLPATH: block would be best, as it would seem to make sense to cut the file at the end of every toolpath. Unfortunately, this would add a cut at the very end of your file, giving you an extra file with little, if any code in it. So we'll have to use the BEGINNING OF TLPATH: block. The same type of problem exists here though, as we don't want the post to cut the file at the beginning of the first toolpath, so we'll need to make a counter to count the toolpaths, and only start cutting at the second toolath. So the first thing you'll need to do is define a SEQUENCING variable called TPCOUNTER to count the toolpaths. You'll want to set the initial value of this variable to 1 in the BEGINNING OF TAPE: block. There is a section at the bottom of this block where a lot of variable are initialized, so just add it there.

Now go to your BEGINNING OF TLPATH: block (this block is standard in all the E8.5SP2P2 posts, but will need to be added to older posts), and add the following lines:

    IF( TPCOUNTER > 1 )
        CUT_FILE = TRUE_ ;
    END_IF ;
    TPCOUNTER = TPCOUNTER + 1 ;
Time to take your coding skills to a new level. But first, an explanation of the g-code file naming in Cimatron.

The default name for a posted file from Cimatron is

ncfilename.toolpathname.postname

now say you have splitting turned on, and it splits this one file into three files. You would now get these file names.

ncfilename.toolpathname.postname
ncfilename.toolpathname.postname._01
ncfilename.toolpathname.postname._02

The first filename format is different than the rest. Rememeber this, because we'll have to deal with it later on.

So lets say we're splitting our g-code at every toolpath, and that we want to name each file with the toolpath name. Easy enough to say, but harder to do. The problem is that toolpath names come and go, but all the file renaming has to be done at the end of the posting process. So what we need to do is use a programming method called an array. An array is different than a regular variable. a regular variable can hold a single value, but an array can hold any number of values, depending on how you define it. In our case, we're going to need an array that holds text strings, so first we need to declare it in the FORMAT section of the post, like this:

FORMAT (CHARACTER) TPNAME[50] ; //ARRAY TO HOLD 50 TOOLPATH NAMES

This array will hold up to 50 toolpath names. The next step is to populate the array with dummy data. In GPP2, arrays don't like to be empty, so best to fill them with some dummy data. This also gives us something to check against later. So add the following lines to the STARTUP: block.

//FILL THE TPNAME ARRAY WITH NULL DATA
    TPCOUNTER = 1 ;
    REPEAT
        TPNAME[TPCOUNTER] = "NULL" ;
        TPCOUNTER = TPCOUNTER + 1 ;
    UNTIL (TPCOUNTER == 51) ;

We're using the TPCOUNTER variable to count to 51 here, simply because I like to use as few variables as possible. The actual initial value for TPCOUNTER gets set at the end of the BEGINNING OF TAPE: block, so using it here won't hurt anything. The code is pretty simple. The REPEAT loop goes through the array, filling each spot with the word NULL. So now, we have array full of NULL. Now to fill it with real data.

Since we want to fill it with the toolpath names, we'll add the following line to the start of the BEGINNING OF TLPATH: block. Make sure you put it before the line of code that increments your counter.

    TPNAME[TPCOUNTER] = TP_NAME ;

This is assuming that you're using a variable called TPCOUNTER to count your toolpaths. So now, at the beginning of every toolpath, the name of the current toolpath gets stored inside the TPNAME array in a spot that corresponds with number held in the TPCOUNTER variable as the BEGINNING OF TLPATH: block is processed. So the first toolpath name gets stored in spot 1, the second gets stored in spot 2, and so on.

So, we're storing all our data, now what do we do with it? Time to move down to the POST SCRIPT: block. This is the block where we can create DOS scripting commands to manipulate things like file names. The GPP2 command SYSTEM_CALL will create these DOS commands. If you have any other code down here doing any file renaming, now's the time to comment it out, because all this code assumes that it is the only code working on file renaming right now.

First we'll add the code to deal with the first file. If you remember, this file is named differently (no extra numbering at the end of the file name). We can also assume that there will always be at least this one file. I'm also going to assume that your g-code file suffix is going to be .nc. Here is a list of what's going to happen in this code.

Use a SYSTEM_CALL to delete any file that might already exist that has the same name that we want to use for our first file.
Use a SYSTEM_CALL to rename the first g-code file to the name of the first toolpath.
GPP2 stores the default name of the first file in the system variable FILE_NAME. It uses this to tell the system which file to open in Notepad or whatever, when you're done posting. Well we just changed the name of that first file, but we still need to know the default name for renaming more files later on. So we're going to store the value held in the FILE_NAME variable in a variable of our own called FULLFILENAME. You will need to declare this in the FORMAT area of your post as a CHARACTER variable.
and finally, we'll set the value of the system variable FILE_NAME to the new name of our first file.

The code will look like this:

    SYSTEM_CALL "del " TPNAME[1] ".nc" ; // REMOVE ANY EXISTING FILES WITH THE SAME NAME AS THE NAME WE WANT TO USE
    SYSTEM_CALL "ren " FILE_NAME " " TPNAME[1] ".nc" ; //RENAME SYSTEM POSTED FILE TO DESIRED FILENAME
    FULLFILENAME = FILE_NAME ; //STORE THE DEFAULT FILE NAME FOR USE LATER ON
    FILE_NAME = TPNAME[1] + ".nc" ;// TELL THE SYSTEM WHAT THE NEW FILENAME IS

Now for the other files. We're going to need another counter here, because we're now on the file created from the second toolpath, but the default numbering scheme add a ._01 to the second file, so our toolpath count is one off from the numbering scheme count. To keep track of this, you will need to declare a specially formatted variable, using one of the USER formats. GPP2 has 10 custom formats (USER_1 thruUSER_10) that you can define, and we need to define one that always outputs two integers. So pick one that's not being used in your post already, and use the .df2 to set the min and max digits for the integer part to 2. We need this because of the format of the file numbering always using two digits. Once you have the USER format setup, go ahead and declare a variable called FILECOUNTER in the FORMAT section of your post. Once you've done that, now lets take a look at what will happen in this next section of code.

Check to see IF there is even a second file. We'll do this by checking the second spot in the array to see if it holds anything other than the word NULL.
Set the value of the FILECOUNTER variable to 1. We'll use this to track the default file increment number, and we're starting on the first file that uses the increment numbering.
Set the value of the TPCOUNTER variable to 2. We'll use this to track the toolpath number, and we're starting on the second toolpath.
Start a loop to process the filenames
Use a SYSTEM_CALL to delete any file that might already exist that has the same name that we want to use for the next file.
Use a SYSTEM_CALL to rename the current default named file determined by the FILECOUNTER value with the current toolpath name determined by the TPCOUNTER value.
Increment the FILECOUNTER variable.
Increment the TPCOUNTER variable
Do this until we find a spot in the array that the next spot in the array, still holds the word NULL.
END_IF the IF that started this process.

The code will look like this:

    IF (TPNAME[2] != "NULL") //ONLY PROCESS IF THERE IS A SECOND TOOLPATH
        FILECOUNTER = 1 ; //SET THE INITIAL VALUE
        TPCOUNTER = 2 ; //SET THE INITIAL VALUE
        REPEAT
            SYSTEM_CALL "del " TPNAME[TPCOUNTER] ".nc" ; // REMOVE ANY EXISTING FILES WITH THE SAME NAME
            SYSTEM_CALL "ren " FULLFILENAME "._" FILECOUNTER " " TPNAME[TPCOUNTER] ".nc" ; //RENAME THE FILE FROM THE DEFAULT NAME TO THE CURRENT TOOLPATH NAME
            FILECOUNTER = FILECOUNTER + 1 ; //INCREMENT THE COUNTER
            TPCOUNTER = TPCOUNTER + 1 ; //INCREMENT THE COUNTER
        UNTIL (TPNAME[TPCOUNTER] == "NULL") ; //STOP IF THE NEXT SPOT IN THE ARRAY DOES NOT HOLD A TOOLPATH NAME
    END_IF ;
5
发表于 2010-11-9 02:49:29 | 只看该作者
虽然不懂GPP2    但是知道是好东西  顶起...
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网 ( 粤ICP备2025491344号-1

GMT+8, 2025-11-18 16:16 , Processed in 0.065954 second(s), 12 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2025 www.iCAx.org

快速回复 返回顶部 返回列表