본문 바로가기
Home Cockpit/DIY

[MSFS-DIY] pyton simconnect 연결 예

by 비니미니파 2023. 4. 4.

먼저 simconnect 설치가 필요하다.

 

https://pypi.org/project/SimConnect/

 

SimConnect

Adds a pythonic wrapper for SimConnect SDK.

pypi.org

 

pip install SimConnect

 

설치가 완료되면 아래 예제를 실행 해 보자.

 

 

import simconnect
import time

# Connect to SimConnect
sm = simconnect.SimConnect()

# Define the aircraft object
aircraft = sm.add_aircraft_object("Aircraft")

# Set the current heading of the aircraft to 270 degrees
heading = 270
aircraft.HEADING_INDICATOR = heading
sm.set_data_on_sim_object(aircraft)

# Wait for 1 second
time.sleep(1)

# Set the current heading of the aircraft to 180 degrees
heading = 180
aircraft.HEADING_INDICATOR = heading
sm.set_data_on_sim_object(aircraft)

# Close the SimConnect connection
sm.close()

댓글