Community
PowerShape and PowerMill API Forum
Welcome to Autodesk’s PowerShape and PowerMill API Forums. Share your knowledge, ask questions, and explore popular API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How should I get the output of the PowerMILL echo command

1 REPLY 1
Reply
Message 1 of 2
danielyiphoi
257 Views, 1 Reply

How should I get the output of the PowerMILL echo command

I want to complete a function in my plug-in to determine whether to execute a macro command based on the user's specific behavior. In my plan, the user's completion of the measured behavior is the basis for activating the program to execute the macro command. For this purpose, I designed a Test button to try to capture the output from the echo command, for example [MEASURE SET_SCALAR 19.4346\n]

 

private void Test_Void(object sender, RoutedEventArgs e)
{
    // Use COMEX to retrieve the last measured scalar value
    string command = "print par 'MEASURE.SET_SCALAR'";
    object result = COMEX(command);

    // Check if any result was captured
    if (result != null)
    {
        string outputString = result.ToString();

        // Assuming that the outputString follows a format like "[MEASURE SET_SCALAR 19.4346\n]",
        Regex scalarRegex = new Regex(@"MEASURE SET_SCALAR (\d+\.\d+)");
        Match match = scalarRegex.Match(outputString);

        if (match.Success)
        {
            // If success, extract the scalar value
            string scalarValue = match.Groups[1].Value;
            MessageBox.Show($"Captured Scalar Value: {scalarValue}", "Scalar Value");
        }
        else
        {
            // Handle the condition if the expected pattern was not found in the output
            MessageBox.Show("Failed to match the expected scalar output format.", "Error");
        }
    }
    else
    {
        MessageBox.Show("No output was captured, or the output was empty.", "Error");
    }
}

But it seems that MEASURE SET_SCALAR in PowerMILL seems to correspond to another definition, similar to the requirements for plug-in monitoring events in the PowerMILL event list.

This is different from changing the input "ECHO ON DCPDEBUG UNTRACE COMMAND ACCEPT" based on "ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT" in the echo command

So I don't know what type of problem I am currently experiencing? Is there a dictionary name mismatch? Or is it similar to the difference in expression between manually running macro commands and plug-in running macro commands?

So where should I find relevant development documents for comparison? Or I want the plug-in to query user measurement results [MEASURE SET_SCALAR value\n], what should be the target of "Print"

1 REPLY 1
Message 2 of 2
danielyiphoi
in reply to: danielyiphoi

all right, I seem to have found a way

Right-click on the measurement panel and select Properties to see

So in this answer it should be
print FORMVALUE Calc.Shell.MeasureTab.MeasureScalarFrame.MeasureScalar

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums