Skip to main content
deleted 398 characters in body
Source Link
import bpy
from bpy.app.handlers import persistent

bl_info = {
  "name": "Startup",
  "author": "",
  "version": (1, 2, 4),
  "blender": (3, 6, 0),
  "location": "",
  "description": "startup scrips"scripts",
  "warning": "",
  "doc_url": "",
  "category": "startup",
  "addon_id": "startup"
}

console_toggle_countconsole_opened = 0False
def ensure_console():
  global console_toggle_count
  console_toggle_count += 1console_opened
  if console_toggle_count % 2 != 1console_opened:
  return
  bpy.ops.wm.console_toggle()
  bpy.ops.wm.console_toggle()console_opened = True

@persistent
def load_handler(a, b):
  ensure_console()
  
def register():
  bpy.app.handlers.load_post.append(load_handler)

if __name__ == "__main__":
  register()

this is relatively easy way to do it. If there are no other factors involved when running the script (-con as exe arg for example). this will just ensure that the toggle state is always uneven. Meaning on startup it will exec the script with the default blender file. toggle_state == 1 then it will load ur file toggle_state == 2

when its even (2) itThis will just execute the toggle againconsole open just once.

 
So no need for external stuff.

import bpy
from bpy.app.handlers import persistent

bl_info = {
  "name": "Startup",
  "author": "",
  "version": (1, 2, 4),
  "blender": (3, 6, 0),
  "location": "",
  "description": "startup scrips",
  "warning": "",
  "doc_url": "",
  "category": "startup",
  "addon_id": "startup"
}

console_toggle_count = 0
def ensure_console():
  global console_toggle_count
  console_toggle_count += 1
  if console_toggle_count % 2 != 1:
    bpy.ops.wm.console_toggle()
  bpy.ops.wm.console_toggle()

@persistent
def load_handler(a, b):
  ensure_console()
  
def register():
  bpy.app.handlers.load_post.append(load_handler)

if __name__ == "__main__":
  register()

this is relatively easy way to do it. If there are no other factors involved when running the script (-con as exe arg for example). this will just ensure that the toggle state is always uneven. Meaning on startup it will exec the script with the default blender file. toggle_state == 1 then it will load ur file toggle_state == 2

when its even (2) it will just execute the toggle again.

  no need for external stuff.

import bpy
from bpy.app.handlers import persistent

bl_info = {
  "name": "Startup",
  "author": "",
  "version": (1, 2, 4),
  "blender": (3, 6, 0),
  "location": "",
  "description": "startup scripts",
  "warning": "",
  "doc_url": "",
  "category": "startup",
  "addon_id": "startup"
}

console_opened = False
def ensure_console():
  global console_opened
  if console_opened: return
  bpy.ops.wm.console_toggle()
  console_opened = True

@persistent
def load_handler(a, b):
  ensure_console()
  
def register():
  bpy.app.handlers.load_post.append(load_handler)

if __name__ == "__main__":
  register()

This will execute the console open just once.
So no need for external stuff.

Source Link

import bpy
from bpy.app.handlers import persistent

bl_info = {
  "name": "Startup",
  "author": "",
  "version": (1, 2, 4),
  "blender": (3, 6, 0),
  "location": "",
  "description": "startup scrips",
  "warning": "",
  "doc_url": "",
  "category": "startup",
  "addon_id": "startup"
}

console_toggle_count = 0
def ensure_console():
  global console_toggle_count
  console_toggle_count += 1
  if console_toggle_count % 2 != 1:
    bpy.ops.wm.console_toggle()
  bpy.ops.wm.console_toggle()

@persistent
def load_handler(a, b):
  ensure_console()
  
def register():
  bpy.app.handlers.load_post.append(load_handler)

if __name__ == "__main__":
  register()

this is relatively easy way to do it. If there are no other factors involved when running the script (-con as exe arg for example). this will just ensure that the toggle state is always uneven. Meaning on startup it will exec the script with the default blender file. toggle_state == 1 then it will load ur file toggle_state == 2

when its even (2) it will just execute the toggle again.

no need for external stuff.