Skip to content

Instantly share code, notes, and snippets.

View 44hero's full-sized avatar

44hero 44hero

View GitHub Profile
@44hero
44hero / ---pattern02-- not writing inside __iinit__.py
Last active May 8, 2023 02:07
## class と MVCモデルの関係を理解しよう -ファイル分割 編- #### `__init__.py`の取り扱い・中身の記述と、モジュール(ファイル)其々の記述の仕方が、超重要 目的: class記述における、運用・管理のし易さの観点から、class を分け、かつファイルを分けたい まとめ: __init__.py が空の場合は インポートする際に、モジュール内にパッケージ名を明示的に記述する必要があり、
## パターン2 `__init__.py`に書き込まないパターン
---
結論2:
e.g.):
packageForda(testMVC)
├── view.py
class<View(object)>
@44hero
44hero / -sample-
Last active April 10, 2023 08:49
目的: maya で動作するUI操作時に、script editorへ状況をprint outしたい 実現したい内容の詳細: 1. 意図した関数が、内部で実行されているかを表示させたい 2. 開発用と本番用で、出力の仕方を変化させたい 3. 今後も使い続けるにあたり、汎用性も考慮したい 結果: 以下の2パターンが実現できそうだ 1. 関数のコードの先頭にデコレーターを付与し、デコレーターを利用した、ログ表示 Dec
# ロギング用モジュール ###################################################
import YO_logger
from imp import reload
reload(YO_logger)
# YO_logger.getLineNo() : 行番号を指し示す出力、として利用しています
from YO_logger import Decorator # ログデコレーター用クラス
# #############################
# 開発用(development)と、本番用(product) を共存させています
# 本コード内にある、
@44hero
44hero / getUIValue.py
Last active July 7, 2022 03:52 — forked from fereria/getUIValue.py
UIからの値取得方法
**partial**
```python
# -*- coding: utf-8 -*-
import pymel.core as pm
import maya.cmds as cmds
from functools import partial
def buttonSakusei():
@44hero
44hero / adjustable_columns.py
Last active July 3, 2022 08:53 — forked from JFlynnXYZ/Maya GUI Gists
Maya GUI Gists
'''This piece of code creates three buttons along the bottom of a window
equally seperated and adjustable by the changing of the window size.
To change where they are positioned in the form layout, swap out the
values in the attachForm with the attachNone values. For example, if
I wanted to place the buttons along the top I would swap out the
attachForm values for each "bottom" value with the attachNone values
for "top".
'''
window = cmds.window()
import shiboken2
from maya import cmds
from maya import OpenMayaUI
from PySide2 import QtWidgets
panels = cmds.getPanel(scriptType="scriptEditorPanel")
# Get all script editor panel names.
if panels: # Make sure one actually exists!
@44hero
44hero / NG
Last active November 30, 2023 03:52
# OK: メインウィンドウparent 実現
# NG: Windowの重複回避 実現できていない
# MayaのWindowを重複させない方法というのを書いたのですが、これだと一部問題がある
# MayaのScriptEditor上で実行した場合や.pyでImportしている場合でreloadをした場合
# クラスのIDが変わってしまうらしく、同じクラス名でも別クラス扱いになってしまい
# findChildren関数が動かないという問題がありました。
## -*- coding: utf-8 -*-
# *----------------------------------------------*#
@44hero
44hero / basic
Last active December 8, 2023 04:42
import json
def getDirectroy(self):
# フォルダ作成
directory = os.path.join(pm.internalVar(userAppDir = True), 'lightManager')
# print (directory)
if not os.path.exists(directory):
os.mkdir(directory) # create a new directory
return directory
# -*- coding: utf-8 -*-
import maya.cmds as cmds
from functools import partial
win = 'testWin'
def defaultButtonPush(*args):
print(args)
print(args[0], args[1])
import maya.cmds as cmds
from functools import partial
def Cmd1( *args):
print(args)
if cmds.window(win, exists=True):
cmds.deleteUI(win, window=True)
We couldn’t find that file to show.