ScriptSpot

Forum topic · General Scripting

get MAC adress by maxscript

By alexnguyen · 2016-09-19

Description

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 (3)

.

alexnguyen · 2016-09-20

i can do it , thank you very much :)

`

pixamoon · 2016-09-30

or even in one line:


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

`

pixamoon · 2016-09-20

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)