Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
If I wanted to get the IP address of my Windows PC in Python, I would use the following code
import socket
host = socket.gethostname()
ipaddress = socket.gethostbyname(host)
I want to do this in Max Script, so I wrote the following code, but it did not work.
socket = python.import "socket"
host = socket.gethostname
ipaddress = socket.gethostbyname host
Error message is this
-- Error occurred in anonymous codeblock; filename: ; position: 14; line: 1
-- Type error: Call needs function or class, got: undefined
-- MAXScript callstack:
-- thread data: threadID:24508
-- ------------------------------------------------------
-- [stack level: 0]
-- In top-level
-- Error occurred in anonymous codeblock; filename: ; position: 43; line: 2
-- Unknown property: "gethostname" in undefined
-- MAXScript callstack:
-- thread data: threadID:24508
-- ------------------------------------------------------
-- [stack level: 0]
-- In top-level
-- Error occurred in anonymous codeblock; filename: ; position: 75; line: 3
-- Unknown property: "gethostbyname" in undefined
-- MAXScript callstack:
-- thread data: threadID:24508
-- ------------------------------------------------------
-- [stack level: 0]
-- In top-level
How can I use gethostbyname?
Solved! Go to Solution.