First two simple things:
Can you please add TextOut and Prompt soon?
It is not possible to copy text from the textbox and print is great for a lot of things but not for everything.
The other thing is that I cant figure out how to access stuff like this:
On Error Resume Next
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_VideoController")
On Error GoTo 0
Which I need to get system data like graphiccard, RAM, CPU, speeds and cores etc.
Here ya go. I just typed up some functions that do what youâre asking for so you donât have to wait around for the functions to get added to rhinoscriptsyntax.
import Rhino
import clr
clr.AddReference("System.Management")
import System.Management
def video_information():
select = "SELECT * FROM Win32_DisplayConfiguration"
searcher = System.Management.ManagementObjectSearcher(select)
lines = []
for mgmtobj in searcher.Get():
for prop in mgmtobj.Properties:
lines.append("{0}: {1}".format(prop.Name,prop.Value))
return "\n".join(lines)
def TextOut(text, title=None):
Rhino.UI.Dialogs.ShowTextDialog(text, title)
def Prompt(prompt):
Rhino.RhinoApp.CommandPrompt = prompt
info = video_information()
Prompt("video info")
TextOut(info, "Video Information")
And how can I find info on all this? It is difficult to figure out what modules to import, and what they contain. I feel that when ever I need something you just pull another rabbit out of a magic hat. Could you point me in the right direction for that?
In reality, a lot of this just comes from experience of using these frameworks and knowing âwhatâ Iâm looking for. I usually use C# as part of my search since it is unique and tends to help me get at .NET specific information that I can parse and convert to python syntax. For the lines of script that you posted, I had no idea what they did but it did give me an idea to try a google search for
C# Win32_DisplayConfiguration
which pointed me in the direction of the ManagementObjectSearcher class in .NET.
I havenât dug into this beyond what Jorgen asked for. I was figuring he had some other code to parse what is returned in his old holomark since those are going to be the same values he gets back in RhinoScript.
I changed it to search in Win32_VideoController, multiple times for detailed information. And this is what the code now looks like:
import Rhino
import clr
clr.AddReference("System.Management")
import System.Management
def video_information():
select = "SELECT * FROM Win32_VideoController"
arrInfo = System.Management.ManagementObjectSearcher(select)
lines = []
for strInfo in arrInfo.Get():
lines.append("\nYour Graphic Card Data:\n-----------------------\n")
for prop in strInfo.Properties:
if prop.Name=="AdapterCompatibility":
lines.append("{0}: {1}".format(prop.Name,prop.Value))
for prop in strInfo.Properties:
if prop.Name=="VideoProcessor":
lines.append("{0}: {1}".format(prop.Name,prop.Value))
for prop in strInfo.Properties:
if prop.Name=="AdapterRAM":
lines.append("{0}: {1}".format(prop.Name,(prop.Value)/1048576))
for prop in strInfo.Properties:
if prop.Name=="DriverVersion":
lines.append("{0}: {1}".format(prop.Name,prop.Value))
return "\n".join(lines)
def TextOut(text, title=None):
Rhino.UI.Dialogs.ShowTextDialog(text, title)
def Prompt(prompt):
Rhino.RhinoApp.CommandPrompt = prompt
info = video_information()
Prompt("video info")
TextOut(info, "Video Information")
Edit: I just removed a few â----â from the code so it would avoid the line break.
This Discourse should support wider text fields, as we need to cut and paste code in here, and not all code is as short as the width of this post.
Edit 2: @pascal can you test this code on your system please?
Thanks, but how did you edit the post to show the script propperly?
I used the < / > feature?
EDIT: Oh⌠I see⌠I could just click the edit button my self and have a look
You added (three backticks)python before the script, and (three backticks) after.
I got similar info as Pascal, but that was with your script that searched in Win32_DisplayConfiguration instead of Win32_VideoController.
I like the short version, but the list is alphabetical, so to be able to get my preferred order I had to break it down. I could use fewer searches, but it looked tidier if I used one search for each⌠In the final version I will give the values to strings and then assemble the strings in the right order after. So this was just a hack.
You probably donât need these now that Mitch showed you the RhinoCommon calls, but Iâll make sure these get added for a future service release. As far as ExePlatform, that would be implemented as
import System
def ExePlatform():
"Returns the platform of the Rhino executable"
if System.Environment.Is64BitProcess: return 1
return 0