In one of my macros I am pulling info about a user selected NCprogram. For some reason I can run the macro over and over again and get different results on the same NCprogram that has been unchanged when calling parameters for the option file and the run time info. Here are the parameters I am referencing...
WIDGET('NCToolpath.OptionFile').VALUE
WIDGET('Statistics.Time').VALUE
Is there a better way to get this information into a variable in my macro? Sometimes it runs and the information is filled in and other times when the macro runs the information does not get inputted into the variable. Anyone know why this happens? Any insight is greatly appreciated.
Solved! Go to Solution.
Solved by Daniel.Reister. Go to Solution.
Ok so I was messing around a little more (and actually read in the reference file for PowerMill commands) and found the commands...
NCprogram.OptionFile.Path
and
NCprogram.Statistics.TotalTime
These seem to work better. I am still wondering why the other commands don't give consistent results as when they work I prefer the format that it displays the data in. I can make these new commands I found display as I want it just takes more code.
//GET THE POSTPROCESSOR (POST NAME ONLY NOT PATH)
STRING POST_PROCESSOR = $NCPROGRAM.OptionFile.Path
//HAVE TO GET JUST THE POSTPROCESSER AND NOT THE PATH TOOLPATH
INT LOOP = 1
INT POSITION = 0
INT LENGTH = LENGTH($POST_PROCESSOR)
WHILE $LOOP == 1 {
INT TEMP = POSITION($POST_PROCESSOR, "\", $POSITION)
IF $TEMP != -1 {
$POSITION = $TEMP + 1
} ELSE {
$LOOP = 0
}
}
$LENGTH = $LENGTH - $POSITION
$POST_PROCESSOR = SUBSTRING($POST_PROCESSOR, $POSITION, $LENGTH)
$POST_PROCESSOR = REPLACE($POST_PROCESSOR, ".pmoptz", "")
//GET THE TOTAL RUNTIME OF THE NCPROGRAM
REAL RUNTIME_RAW = $NCPROGRAM.Statistics.TotalTime
REAL RUNTIME_HOURS = $RUNTIME_RAW / 60
REAL RUNTIME_MINUTES = $RUNTIME_HOURS
INT ROUND = $RUNTIME_HOURS
$RUNTIME_HOURS = $ROUND
$RUNTIME_MINUTES = ($RUNTIME_MINUTES - $RUNTIME_HOURS) * 60
REAL RUNTIME_SECONDS = $RUNTIME_MINUTES
$ROUND = $RUNTIME_MINUTES
$RUNTIME_MINUTES = $ROUND
$RUNTIME_SECONDS = ($RUNTIME_SECONDS - $RUNTIME_MINUTES) * 60
$ROUND = $RUNTIME_SECONDS
$RUNTIME_SECONDS = $ROUND
//FORMAT THE HOURS
STRING REPLACE = REPLACE($RUNTIME_HOURS, ".0", "")
IF LENGTH($REPLACE) < 2 {
$REPLACE = "0" + $REPLACE
}
STRING RUN_TIME = $REPLACE + ":"
//FORMAT THE MINUTES
$REPLACE = REPLACE($RUNTIME_MINUTES, ".0", "")
IF LENGTH($REPLACE) < 2 {
$REPLACE = "0" + $REPLACE
}
$RUN_TIME = $RUN_TIME + $REPLACE + ":"
//FORMAT THE SECONDS
$REPLACE = REPLACE($RUNTIME_SECONDS, ".0", "")
IF LENGTH($REPLACE) < 2 {
$REPLACE = "0" + $REPLACE
}
$RUN_TIME = $RUN_TIME + $REPLACE
So it looks like for some reason when I run the macro in real time it does not collect the parameter correctly from the NCprogram. The code above is the solution I found that consistently capture the NCprogram information and converts it to the format that you would get if you could grab the parameter directly. Thought someone else might find it handy if they run into the same problem as me.
Can't find what you're looking for? Ask the community or share your knowledge.