ToneOperatorParameters for Viewport

ToneOperatorParameters for Viewport

AVCPlugins
Advisor Advisor
517 Views
5 Replies
Message 1 of 6

ToneOperatorParameters for Viewport

AVCPlugins
Advisor
Advisor

AutoCAD Viewports have color and brightness settings for texture rendering. The user configures them in the _RenderExposure palette. I found in the .Net API that viewports have a ToneOperatorParameters property. This object already has the properties I need, including Exposure. But here's the problem: AutoCAD ignores changes to these properties. Although all the setters are available, you can assign properties to the ToneOperatorParameters object, and you can change the viewport's ToneOperatorParameters itself. No errors occur. But the new values ​​aren't saved! If anyone has worked with these settings, please let me know. I have a feeling this is a bug in the API. I'm testing on AutoCAD 2025 and 2026.


Plugins for AutoCAD
A>V>C>
AppStore | Facebook | Twitter | YouTube | Blog
0 Likes
518 Views
5 Replies
Replies (5)
Message 2 of 6

ActivistInvestor
Mentor
Mentor

I think you need to assign/re-assign the ToneOperatorParameters instance to the Viewport's ToneOperatorParameters property. You may also need to call UpdateDisplay(). 

0 Likes
Message 3 of 6

AVCPlugins
Advisor
Advisor

I tried reassigning the ToneOperatorParameters object. Immediately afterward, all its values ​​revert to their original values. I see this in step-by-step debugging.  And my command calls Regen at the end – this has no effect.

 

public static void
SetExposure(this Viewport ts, double value)
{
if (ts is null || ts.IsErased || ts.ObjectId.IsNull || double.IsNaN(value)) return;
try
{
if (value < -6) value = -6;
if (value > 21) value = 21;
using Autodesk.AutoCAD.GraphicsInterface.ToneOperatorParameters tp = ts.ToneOperatorParameters;
if (tp.ExistsProp("Exposure") && value != (double)tp.GetProp("Exposure"))
{
tp.SetProp("Exposure", value);
ts.ToneOperatorParameters = tp;
}
}
catch { Debug.Print("Viewport.Exposure error"); }
}


Plugins for AutoCAD
A>V>C>
AppStore | Facebook | Twitter | YouTube | Blog
0 Likes
Message 4 of 6

ActivistInvestor
Mentor
Mentor

After you assign a value to the property, try issuing the REGEN3 command. 

0 Likes
Message 5 of 6

essam-salah
Advisor
Advisor

hi


@AVCPlugins wrote:

I tried reassigning the ToneOperatorParameters object. Immediately afterward, all its values ​​revert to their original values. I see this in step-by-step debugging.  And my command calls Regen at the end – this has no effect.

 

public static void
SetExposure(this Viewport ts, double value)
{
if (ts is null || ts.IsErased || ts.ObjectId.IsNull || double.IsNaN(value)) return;
try
{
if (value < -6) value = -6;
if (value > 21) value = 21;
using Autodesk.AutoCAD.GraphicsInterface.ToneOperatorParameters tp = ts.ToneOperatorParameters;
if (tp.ExistsProp("Exposure") && value != (double)tp.GetProp("Exposure"))
{
tp.SetProp("Exposure", value);
ts.ToneOperatorParameters = tp;
}
}
catch { Debug.Print("Viewport.Exposure error"); }
}


have you checked to commit the outer or any open transction?

also have tried to call viewport.UpdateDisplay(); after setting viewportToneOperatorParameters ?

0 Likes
Message 6 of 6

ActivistInvestor
Mentor
Mentor

If the Viewport you're modifying is not the active viewport, Regen will not work. the REGENALL command might.