get MAC adress by maxscript

hello
i found a function get mac adress but now it not work , i dont know why , can you fix it or have another way to get mac adress ?, thank you for your help

NWIF = dotnetClass "System.Net.NetworkInformation.NetworkInterface"
the_Mac_array = NWIF.GetAllNetworkInterfaces() -- this is an array of all the Networks
the_PhysicalAddress_Array = #()
for net in the_Mac_array where (net.NetworkInterfaceType.toString()) == "Ethernet" do append the_PhysicalAddress_Array ((net.GetPhysicalAddress()).toString())
print the_PhysicalAddress_Array

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
alexnguyen's picture

.

i can do it , thank you very much :)

pixamoon's picture

`

or even in one line:

print ((((dotNetClass "System.Net.NetworkInformation.NetworkInterface").GetAllNetworkInterfaces())[1].getPhysicalAddress()).tostring())
pixamoon's picture

`

Hi,

Try this one:

str = ""
ani = (dotNetClass "System.Net.NetworkInformation.NetworkInterface").GetAllNetworkInterfaces()
 
for a in ani do str += (a.getPhysicalAddress()).toString()
 
print (subString str 1 12)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.