Get video hardware & driver information

Hello.
At the beginning of my code, I would like to know if there is a video card installed in the system or if tasselation is on, something that confirms me that i can run ViewCaptureToFile to save my viewports.

Thanks

Andrea

You should always be able to run ViewCaptureToFile, regardless of whether a video card (assuming you mean a discrete GPU, i.e. a GPU on a card, as opposed to an integrated GPU) is installed or not.

When does it not work for you?

I would like the script to be able to run on server machines, even without video card.
I need to know if there is a video card because in that case I want to trigger a different method (render)

You could try something like the code below. I use it to detect specific GPUs in the machine for when to skip OpenCL initialization. But you could probably use it to detect whether certain brands of GPU exist in the machine or not, and make your decision based on that.


			ManagementObjectSearcher objvide = new ManagementObjectSearcher("select * from Win32_VideoController");

			bool shouldskip = false;

			foreach (ManagementObject obj in objvide.Get())
			{
				string name = $"{obj["Name"]}";
				int avail = Convert.ToInt16(obj["Availability"]);
				string driverversion = $"{obj["DriverVersion"]}";

				if (avail != 3) continue;

				RhinoApp.OutputDebugString($"Name: {name}\n");
				RhinoApp.OutputDebugString($"Availability: {avail}\n");
				RhinoApp.OutputDebugString($"DriverVersion: {driverversion}\n");

				shouldskip |= skipList.Hit(name); // name.Contains("Intel") && name.Contains("530");

			}
1 Like

thanks,! but wait, is it usable via python? :slight_smile:
which library should iImport…

You’ll have to do some conversion of the code, but you can import .NET libraries in Python in Rhino. The class ManagementObjectSearcher is in the System.Management namespace, so you should import System.Management

1 Like