Main API
Patchwork 3D scripting
See also
- class CurrentP3DSession(fallback_port=None)
Bases:
p3dsdk._p3d_session.P3DSession
Class that connects to the running Patchwork 3D instance.
If the script is not executed from Patchwork 3D,
fallback_port
lets you specify a port to connect to. In this case it is equivalent toP3DSession("localhost", fallback_port)
.- Parameters
fallback_port (int, optional) -- Port to use to connect to Patchwork 3D on localhost when the script is not run from Patchwork 3D.
- Raises
P3DError -- If no
fallback_port
is given and the script is not executed in the Patchwork 3D Python console.
- property app
Access to the current Patchwork 3D.
- Type
Application, read-only
- close()
Close the session.
- class P3DSession(host, port)
Class that manages a scripting session with Patchwork 3D.
Note
If possible use IP address directly for
host
. This way, it will avoid a hostname lookup and queries will be quicker. For example, instead of connecting tolocalhost
, prefer using127.0.0.1
.- Parameters
- property app
Access to the current Patchwork 3D.
- Type
Application, read-only
- close()
Close the session.
Direct access to .p3d file
See also
Direct access to .kev file
- class KEVFile
- classmethod open(filename)
Open an existing .kev file.
- Parameters
filename (str) -- The KEV file to open.
- Returns
The environment contained in the KEV file.
- Return type
- Raises
FileNotFoundError -- If
filename
can't be opened.
Direct access to .kmt file
- class KMTFile
- classmethod open(filename)
Open an existing .kmt file.
- Parameters
filename (str) -- The KMT file to open.
- Returns
The material contained in the KMT file.
- Return type
- Raises
FileNotFoundError -- If
filename
can't be opened.