Author Topic: EnumerationElements() = Low-level API function error  (Read 2555 times)

Offline cameronleger

  • PTeam Member
  • Member
  • *
  • Posts: 51
    • Blog
EnumerationElements() = Low-level API function error
« on: 2017 October 24 20:21:34 »
I've started a Module with the PCL and in an effort to depend on working tools instead of writing my own, I'm looking into using some existing Modules for functionality. First, it seems I've stumbled into an area that's lacking documentation and examples, so it may be me who's done something wrong here.

I'm trying to set some parameters on the StarAlignment Module and execute it on an Image. However, the 'best practice' is giving me an exception. First, I tried setting the 'mode' parameter to 'DrawStars', but it's expecting an integer for the enumeration. Then, I looked into checking the enumeration for the right value, and that's where I've hit an exception that I don't think is my fault. I've resorted to passing the correct integer for this enumeration based on the Property Explorer, but I'd rather not hardcode this. Here's a sample of the code I'm running to get the exception:

Code: [Select]
      Console().WriteLn( "Looking for process" );
      Process starAlignmentProcess( IsoString( "StarAlignment" ) );
      Console().WriteLn( "Creating instance" );
      ProcessInstance starAlignment( starAlignmentProcess );
      if ( starAlignment.IsNull() )
         throw Error( "Couldn't instantiate the StarAlignment process: null" );

      Console().WriteLn( "Looking for mode" );
      ProcessParameter mode( starAlignmentProcess, "mode" );
      if ( mode.IsEnumeration() )
      {
         Console().WriteLn( "Checking mode default" );
         mode.DefaultValue();
         Console().WriteLn( "Checking mode options" );
         ProcessParameter::enumeration_element_list enums = mode.EnumerationElements();
         Console().WriteLn( "Printing mode options" );
         for ( int i = 0; i < enums.Length(); ++i ) {
            ProcessParameter::EnumerationElement modeEnum = enums[i];
            Console().WriteLn( String().Format( "Mode Id = '%s' Value = '%i'", modeEnum.id, modeEnum.value ) );
         }
      }

      Console().WriteLn( "Setting mode" );
      starAlignment.SetParameterValue( 5, IsoString("mode"), 0 );

All log outputs work until the 'mode.EnumerationElements()' call, which gives me the following information:

Code: [Select]
Looking for process
Creating instance
Looking for mode
Checking mode default
Checking mode options
*** PixInsight API Error: GetParameterElementIdentifier(): Low-level API function error
« Last Edit: 2017 October 30 07:54:34 by cameronleger »