Skip to main content

gxw3call

Drive Mitsubishi Electric GX Works3 from Python through its Open Interface (GXW3Call.dll): create projects, import hardware parameters and PLCopen XML, rebuild, export, run the simulator and read or write devices, without the GX Works3 window.

The interface is not documented by the vendor. Every one of its 302 methods can be called here, and what is known about each one comes from real calls, recorded in docs/API.md.

Not affiliated with or endorsed by Mitsubishi Electric. GX Works3 and MELSEC are trademarks of Mitsubishi Electric Corporation.

Requirements

  • Windows with GX Works3 installed (tested with 1.123D). GXW3Call.dll comes with the standard installation.

  • Python 3.10 or later, any bitness.

  • A 32-bit Python 3.10+ for the worker process. The DLL is a 32-bit in-process COM server, so the package starts a 32-bit worker and talks to it over a local socket. The easiest way to get one:

    uv python install cpython-3.12-windows-x86
    

    It is found automatically; set GXW3CALL_PYTHON32 to use another interpreter.

Install

pip install gxw3call

or uv add gxw3call.

Usage

Build a project from parts

from gxw3call.client import Gx

with Gx() as gx:
    project = gx.create_project(r'C:\work\new.gx3', 'R16')
    try:
        project.import_plc_files(r'C:\work\prm')  # $MELPRJ$\SYSTEM/CPU/UNIT.PRM
        project.import_xml(r'C:\work\ladder.xml')  # PLCopen XML
        errors, warnings = project.rebuild()
        print(project.hardware(), project.pou_names())
        project.save()
    finally:
        project.close()
  • Order matters: create, PRM files, XML, rebuild. An XML imported before the PRM files arrives only in part.
  • import_plc_files takes PRM bytes as stored inside a .gx3.
  • CPU names are the ones GX uses (R16, R32EN, FX5U, L04H); gx.plc_types() lists them.
  • examples/build_from_parts.py runs this flow and compares the instruction list with the source project.

Any method

from gxw3call.api import Api
from gxw3call.client import Gx

with Gx() as gx:
    api = Api(gx)
    out = api.project.open_project(r'C:\work\a.gx3', 180, 2, 0)
    call_id = out['call_id']
    try:
        print(api.project.get_plc_type_string(call_id)['plc_type_string'])
        print(api.project.get_pou_names(call_id, 0)['names']['value'])
    finally:
        api.project.close_project(call_id, 0)

Method and argument names are snake_case with the Hungarian prefix dropped (bstrProjectPath becomes project_path, lplReturnCode becomes return_code); every docstring lists the original names. A docstring that starts with "Measured" records what real calls showed; "Not measured" means only the signature is known. Struct arguments take a dict (decoded from a previous call or built by hand) or a hex string.

Things to know

  • A return code of 0 does not prove success, and some calls work with a non-zero code. Read results back.
  • lUserInterfaceMode 2 runs GX hidden. 0 and 1 show a window that stays open after the project is closed.
  • Each opened project starts its own GX process (5 to 9 seconds). Close projects in finally; an open project keeps the process and the file lock.
  • Struct sizes in the type library are not reliable: the native side uses pack 1, and some methods write more than the declared size.
  • Paths must use backslashes; arguments ending in Path or Folder are normalised.

Repository layout

Path Contents
src/gxw3call/client.py Gx (worker connection) and Project (measured calls)
src/gxw3call/api.py all 302 methods, generated by tools/gen_api.py
src/gxw3call/worker.py 32-bit worker: loads the DLL, calls through the vtable
src/gxw3call/typelib.py signatures, pack 1 struct encode and decode
src/gxw3call/data/ type library dump of GX Works3 1.123D
docs/API.md reference: every method and struct with measured results
notes/ measured results (source of the docstrings and the reference)
tools/ probes, catalog dump, generators, type library dump script

Contributing measurements

Add what a call showed to notes/measured.json ({"Method": {"status": "works" | "fails" | "unclear", "note": "..."}}), then regenerate:

python tools/gen_api.py
python tools/gen_doc.py

tools/probe_readonly.py calls the read-only methods with default arguments; tools/probe_changes.py calls methods on copies of a project and reports which parts of the saved file changed. Run them only on copies. For another GX Works3 version, dump the type library first:

powershell -File tools\tlb_dump.ps1 "C:\Program Files (x86)\MELSOFT\GPPW3\GXW3Call.dll" | Out-File -Encoding utf8 src\gxw3call\data\GXW3Call_tlb.txt

License

MIT

Metadata

Release files for gxw3call 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gxw3call 0.1.1
File Size Uploaded Provenance Actions
gxw3call-0.1.1.tar.gz 87.5 kB Without provenance Details for gxw3call-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gxw3call 0.1.1
File Interpreter ABI Platform Actions
gxw3call-0.1.1-py3-none-any.whl Python 3 none any Details for gxw3call-0.1.1-py3-none-any.whl

Total release size: 140.2 kB

Release files / gxw3call-0.1.1.tar.gz

Download URL gxw3call-0.1.1.tar.gz
Size 87.5 kB
Tags Source
SHA-256 checksum
How to use checksums
edc6b1453587f340a9c4015487d006206ae13028c4e7be4428aa4663aba17a14
BLAKE2b-256 checksum
How to use checksums
9c5f4941b7fcc9e0810a75e9eae6cee66ee8c2e156c1d6ceb93fd648b3b016ca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Release files / gxw3call-0.1.1-py3-none-any.whl

Download URL gxw3call-0.1.1-py3-none-any.whl
Size 52.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f72ad665b0f50ca8f4f13c23bb4672c36aac9a0c683d16f195e9e307e9f390d7
BLAKE2b-256 checksum
How to use checksums
169753dfd1329f80102fb680f5441aef10564ce01fa9193064eed27ae7f70745
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.14

Security for gxw3call 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page