Set Selection Resolution

Set Selection Resolution

xaotix
Contributor Contributor
735 Views
6 Replies
Message 1 of 7

Set Selection Resolution

xaotix
Contributor
Contributor

Is there a way to alter the resolution programmatically?

  • File, Layer, First Object, Last Object, Last Unique, Geometry.
0 Likes
Accepted solutions (1)
736 Views
6 Replies
Replies (6)
Message 2 of 7

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @xaotix ,

 

Please try using the below code

 

 using (LcUOptionLock optionLock = new LcUOptionLock())
 {
     // Get the root options using the lock
     LcUOptionSet rootOptions = LcUOption.GetRoot(optionLock);

     // Retrieve the pointer to the specific option by name
     LcUNameRefPtr optionPointer = rootOptions.GetName("interface.selection.resolution");

     // Check if the pointer exists before attempting to set the value
     if (optionPointer != null)
     {
         /*
          * Selection Resolution Options:
          *  0 = File
          *  1 = Layer
          *  2 = First Object
          *  3 = Last Unique
          *  4 = Last Object
          *  5 = Geometry
          */

         // Update the selection resolution option to "Geometry" (value 5)
         string resolutionValue = "RoamerGUI_PickResolution:5";
         rootOptions.SetName("interface.selection.resolution", new NamedConstant(resolutionValue));
         LcOpRegistry.SaveGlobalOptions();
     }
 }

 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 7

ulski1
Collaborator
Collaborator
For Navisworks Simulate 2024 you can write some code which modifies this registry key:
HKEY_CURRENT_USER\SOFTWARE\Autodesk\Navisworks Simulate\21.0\GlobalOptions\interface\selection

the default value is:
Name: Resolution
Data: 8 26:RoamerGUI_PickResolution:4Last Object

Note that for Navisworks 2024 you alter version 210.0 since Navisworks 2024 is Navisworks version 21


Br
Ulrik
0 Likes
Message 4 of 7

alexisDVJML
Collaborator
Collaborator

An old post of mine, with all Navisworks Global Settings at the time (Navisworks 2020) and how to read/change them:
Accessing & Modifying Navisworks Global Settings 

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
Message 5 of 7

xaotix
Contributor
Contributor

thank you guys!

0 Likes
Message 6 of 7

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @imustafa_adel,

You asked me how to read the value of 'Selection Resolution' (by contacting me via chat message).
Here is the answer.

 using (LcUOptionLock optionLock = new LcUOptionLock())
 {
     // Get the root options using the lock
     LcUOptionSet rootOptions = LcUOption.GetRoot(optionLock);
     LcUNameRefPtr s=rootOptions.GetName("interface.selection.resolution");
     MessageBox.Show(s.GetPtr().ToString());            
 }


I'm posting it here so that others with similar questions can also refer to this thread and find the answer.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 7 of 7

imustafa_adel
Explorer
Explorer

Thank you I've also refined the method a little bit as shown below:

 

public static void SetSelectionResolution(SelectionResolution selectionResolution)
{
          var commandstr = "interface.selection.resolution";
          using (LcUOptionLock optionLock = new LcUOptionLock())
          {
                  LcUOptionSet rootOptions = LcUOption.GetRoot(optionLock);

                  LcUNameRefPtr optionPointer = rootOptions.GetName(commandstr);

                  if (optionPointer != null)
                  {
                          string resolutionValue = "RoamerGUI_PickResolution:2";
                          switch (selectionResolution)
                          {
                                  case SelectionResolution.File:
                                          resolutionValue = "RoamerGUI_PickResolution:0";
                                          break;
                                  case SelectionResolution.Layer:
                                          resolutionValue = "RoamerGUI_PickResolution:1";
                                          break;
                                  case SelectionResolution.FirstObject:
                                          resolutionValue = "RoamerGUI_PickResolution:2";
                                          break;
                                  case SelectionResolution.LastUnique:
                                          resolutionValue = "RoamerGUI_PickResolution:3";
                                          break;
                                  case SelectionResolution.LastObject:
                                          resolutionValue = "RoamerGUI_PickResolution:4";
                                          break;
                                  case SelectionResolution.Geometry:
                                          resolutionValue = "RoamerGUI_PickResolution:5";
                                          break;
                          }
                          rootOptions.SetName(commandstr, new NamedConstant(resolutionValue));
                          LcOpRegistry.SaveGlobalOptions();
                  }
          }
}

 


public static SelectionResolution GetSelectionResolution()
{
          var res = string.Empty;
          using (LcUOptionLock optionLock = new LcUOptionLock())
          {
                  var commandstr = "interface.selection.resolution";
                  LcUOptionSet rootOptions = LcUOption.GetRoot(optionLock);
                  LcUNameRefPtr optionPointer = rootOptions.GetName(commandstr);
                  var data = new VariantData();
                  var result = rootOptions.GetDataValue(commandstr, data);
                  if (result) res = data.ToNamedConstant().Name;
          }
          switch (res)
          {
                  case "RoamerGUI_PickResolution:0":
                          return SelectionResolution.File;
                  case "RoamerGUI_PickResolution:1":
                          return SelectionResolution.Layer;
                  case "RoamerGUI_PickResolution:2":
                          return SelectionResolution.FirstObject;
                  case "RoamerGUI_PickResolution:3":
                          return SelectionResolution.LastUnique;
                  case "RoamerGUI_PickResolution:4":
                          return SelectionResolution.LastObject;
                  case "RoamerGUI_PickResolution:5":
                          return SelectionResolution.Geometry;
                  default:
                          return SelectionResolution.FirstObject;
          }
}

public enum SelectionResolution
{
          File,
          Layer,
          FirstObject,
          LastUnique,
          LastObject,
          Geometry
}

0 Likes