[So...] Posted March 28, 2023 Share Posted March 28, 2023 I am really New to PCM. I spend a couple days to fingure out how to save the data to a file. What i want is to save the "Actual, Nominal, UpperTol..." to a file so that i can process the file with an external program. i am be able to save the data of a diameter, a profile and position. However, i keep getting the out put of Position twice while only one for the others. at this point,i don't know why and how to prevent. I only want one per characteristic, Can any one please give me some direction. Link to comment Share on other sites More sharing options...
[Ch...] Posted March 28, 2023 Share Posted March 28, 2023 Have you tried excel output? Sounds like it has everything you're after. Link to comment Share on other sites More sharing options...
[No...] Posted March 29, 2023 Share Posted March 29, 2023 Please sign in to view this quote. May we see your PCM code? Without it it's hard to judge what went wrong. Link to comment Share on other sites More sharing options...
[So...] Posted March 29, 2023 Author Share Posted March 29, 2023 I prefer .txt file than excel because it is easy for me to use javascript to process it. I can filter the duplicate line with javascript but if i can do it with PCM it is better. BTW Here is the code for the Position characteristic Char = getNominal().identifier Nor = 0 ActualY = getActual().actual.y ActualX = getActual().actual.x NominalY = getNominal(Char).nominal.y NominalX = getNominal(Char).nominal.x Actual = 2 * sqrt(squared(ActualX + NominalX) +squared(ActualY + NominalY)) UpperTol = formatL(getNominal(Char).tolerance.upperTolerance, 4, 4) LowerTol = formatL(getNominal(Char).tolerance.lowerTolerance, 4, 4) Comment = getNominal(Char).comment Deviation = formatL(Actual - Nor, 4, 4) JobNum = getRecordHead("order") IncPart = getRecordHead("partnbinc") Time = time() Date = date() MiniPlan = getRunID() AbsMin = Nor + getNominal(Char).tolerance.lowerTolerance AbsMax = Nor + getNominal(Char).tolerance.upperTolerance if ((Actual >= AbsMin) and (Actual <= AbsMax)) then PassFail = "Pass" else PassFail = "Fail" endif if (Comment == "") then Comment = "--No Comment--" endif Result = formatL(Actual, 4, 4) + Delimiter + formatL(Nor, 4, 4) + Delimiter + UpperTol + Delimiter + LowerTol + Delimiter + Deviation + Delimiter + Comment + Delimiter+ Char + Delimiter + JobNum + Delimiter + IncPart + Delimiter + Date + Delimiter + Time + Delimiter + MiniPlan + Delimiter+ PassFail addToFile(File_Path, Result) Link to comment Share on other sites More sharing options...
[No...] Posted March 29, 2023 Share Posted March 29, 2023 Do you have "additional report" (characteristic editor) active for the position or a loop anywhere? To me it looks like the parameter section is evaluated twice for some reason. It has nothing to do with the PCM code. To test that theory you could place a line "counter=0" in the CNC/Advanced/Parameter window, then add "counter=counter+1" at the beginning of your PCM code and add the counter variable to the end of your file output. Then if the second position line has Counter=1 instead of 0, the code has been run twice. Link to comment Share on other sites More sharing options...
[So...] Posted March 29, 2023 Author Share Posted March 29, 2023 i put the counter at the end of the file and it indeed runing twice. I go to charateristic editor settting to check if addition report is on, it was on then i set to off. it still doesn't work even it was set to off. i also check if there is any loop of the position, i see nothing. i don't know if i miss something.Screenshot 2023-03-29 140911.jpg Link to comment Share on other sites More sharing options...
[Fl...] Posted March 30, 2023 Share Posted March 30, 2023 Hi, i don't know if you already thought of that but: you coud also use that counter Norbert suggested to use it in a condition in the code for your position to prevent it from running twice. Link to comment Share on other sites More sharing options...
[No...] Posted March 30, 2023 Share Posted March 30, 2023 Please sign in to view this quote. That would have been my next suggestion 😃 Link to comment Share on other sites More sharing options...
[So...] Posted March 30, 2023 Author Share Posted March 30, 2023 Thank Florian. I did not think of this condition. it works for me in this case since i only have one position. it won't work if there are more than one because the counter has been changed and it won't satify the condition of the next position. unless i create one counter per position. Also thank Norbert for pointing out the root cause. Link to comment Share on other sites More sharing options...
[He...] Posted March 30, 2023 Share Posted March 30, 2023 I would suggest you look into table files which is tab-separated ascii-files that will give print all the characteristics in the program in a neat format. You will find it under resources -> results to file However they are not very flexible so if you want your result files with a particular format the PCM-way you have done is probably the best way even if it means more work for each characteristic. To solve the double row problem I would do something like this. The idea is to check if the current characteristic is the same as the previous one and just skip it if it is. The easiest way is to predefine the Char-parameter in the presettings of the inspection plan. Otherwise it would fail on the first characteristics since the parameter would be undefined. There are other ways of doing it by using isParameterDefined() but i think just to predefine it is more simple. Presettings of the inspection plan: Char = "" The in the postsettings for each characteristic where you have your code change it to: The bold one is the lines I have added PreviousChar = Char Char = getNominal().identifier if PreviousChar <> Char Nor = 0 ActualY = getActual().actual.y ActualX = getActual().actual.x NominalY = getNominal(Char).nominal.y NominalX = getNominal(Char).nominal.x //Actual = 2 * sqrt(squared(ActualX + NominalX) +squared(ActualY + NominalY)) Actual = getActual().deviation //This is to not have to compute the actual result by yourself. It doesn't matter but save 0.3 pikoseconds in math UpperTol = formatL(getNominal(Char).tolerance.upperTolerance, 4, 4) LowerTol = formatL(getNominal(Char).tolerance.lowerTolerance, 4, 4) Comment = getNominal(Char).comment Deviation = formatL(Actual - Nor, 4, 4) JobNum = getRecordHead("order") IncPart = getRecordHead("partnbinc") Time = time() Date = date() MiniPlan = getRunID() AbsMin = Nor + getNominal(Char).tolerance.lowerTolerance AbsMax = Nor + getNominal(Char).tolerance.upperTolerance //if ((Actual >= AbsMin) and (Actual <= AbsMax)) then if getActual().inTolerance == true //A cleaner way of finding pass/fail. PassFail = "Pass" else PassFail = "Fail" endif if (Comment == "") then Comment = "--No Comment--" endif Result = formatL(Actual, 4, 4) + Delimiter + formatL(Nor, 4, 4) + Delimiter + UpperTol + Delimiter + LowerTol + Delimiter + Deviation + Delimiter + Comment + Delimiter+ Char + Delimiter + JobNum + Delimiter + IncPart + Delimiter + Date + Delimiter + Time + Delimiter + MiniPlan + Delimiter+ PassFail addToFile(File_Path, Result) endif Link to comment Share on other sites More sharing options...
[So...] Posted March 31, 2023 Author Share Posted March 31, 2023 your solution is what i am looking for. it works and simple to prevent the double rows. i would go with getActual().deviation that you mention. one line of code vs fiv long lines of code that do the same thing. the getActual().inTolerance is really clean and easy way. 🙂 . I learn something new today. Thank you Henrik. Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in