Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Is there a way to alter the resolution programmatically?
- File, Layer, First Object, Last Object, Last Unique, Geometry.
Solved! Go to Solution.
Is there a way to alter the resolution programmatically?
Solved! Go to 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();
}
}
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
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.
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
}