A quick one to end the week, as I really need to start packing for AU. :-)
Thanks to Augusto Gonçalves, from DevTech Americas, for pointing out this DevNote on the ADN site in a recent email to an ADN member.
The below code shows the steps to set the current visual style to “realistic” in AutoCAD. As with many AutoCAD features, you can also set the current visual style by sending commands to the command-line, but then why do something in 3 lines of code when you can do it in 40? ;-) Seriously, there are some advantages to this approach – such as not polluting the command history, for instance – but that’s really a decision for individual developers to make.
Here’s the C# code defining the SVS command:
public class Commands
static public void SetRealisticVisualStyle()
Document doc =
Editor ed = doc.Editor;
Database db = doc.Database;
Transaction tr =
ViewportTable vt =
ViewportTableRecord vtr =
DBDictionary dict =
vtr.VisualStyleId = dict.GetAt("Realistic");
Here’s a simple indication of the SVS command working. The Visual Styles ribbon panel before…
… and after execution of the SVS command:
That’s it, for now: I’ll hopefully post a few updates next week from AU 2011.