[UE5.3.2][Niagara]Niagara Parameter Collection の使い方

確認用のシステム、エミッター、モジュール、そしてNiagaraParameterCollectionのアセットを作ります。

名前は何でもいいので NiagaraParameterCollection 開いて、新しいパラメータfloatを一つ作ります。

最初のNiagaraParameterCollection設定は、これだけでOKです。

モジュール側の設定はこれで終了です。

次はエミッター側の設定です

ParticleSpawnに、先ほど作ったモジュールを追加します(自分でつけた名前で検索してください)

追加したモジュールに、MyFloat(設定した名前です)という部分に、数値が入るようになっていれば大丈夫です。

ここに入れた数字が、Lifetime(パーティクルの寿命)に設定されます。

設定しておくと、解りやすいと思います。

次に、NiagaraParameterCollectionを実際に入れていきます

まず、Parameterというウインドウを出します

ここから、追加したNiagaraParameterCollectionを登録します。

追加したら、この情報を、ドラッグして差し替えます。

このように登録されていればOKです。

ここまですれば、設定したNiagaraParameterCollectionファイルの数値を動かすと、このエミッターの寿命が延びたり縮んだりしていると思います。

実際に組み込んだ様子がこちら。

調整として使いやすいポイントとして、エミッター毎固定ではなく、システム毎に適用するデータを差し替える事が出来る点です。

エミッター自体の情報を差し替える必要がなく、システム側で変えることができるので、別のシステムで使うようのエミッターを流用していく事も可能です。

エミッター自体にNiagaraParameterCollectionデータを入れている場合でも、システム側でほかのデータに差し替える等も可能です。

HoudiniのHDAのような、いくつかのパラメータを変えるだけで簡単に調整出来る仕様というのも、段々出来ていくのかなと思います。

ということでした

参考URL

[UE5/3.2] PoseAssetの設定保存方法

UE5 PoseAssetの保存方法
ボーンの角度を編集したら。
PoseNameのところでAddPose >AddPoseFrom Currentで
PoseNameに名前を付けて元のポーズは削除する。
Valueを1にすると作ったポーズが見ることができる。

[maya][SkinWeight]スキンウェイトの部分コピー

Partial copy of skin weights

MAYAでのウェイト作業でしたら、部分コピーできます。

1,コピー元とコピー先のオブジェクトを選択

2,F9で頂点選択モード

3,コピー元ウェイト範囲を頂点選択

4,コピー先のウェイト範囲を頂点選択

5,スキンウェイトのコピー

の手順でスキンウェイトの部分コピーできます。

んーできない。

できないとおもっていたら。

んーできない。結局ベースはコピーしてそこからスキンウェイトペイントした。

[maya2022][Pyside2][python3]widget_galleryを動くように変更



# -*- coding: utf-8 -*-
import os
from functools import partial
import time
import imp

"""
PySide2モジュールを探し、ある場合はそちらをインポートします。
"""
try:
    imp.find_module('PySide2')
    from PySide2.QtWidgets import *
    from PySide2.QtGui import *
    from PySide2.QtCore import *

except ImportError:
    from PySide.QtGui import *
    from PySide.QtCore import *


LOGO_IMAGE = r"画像のパスをここに入れてください。"


def get_maya_pointer():
    """
    Mayaのメインウィンドウを取得する関数
    """
    try:
        import maya.cmds as cmds
        from maya import OpenMayaUI

    except ImportError:
        return None

    """
    実は2017ではshibokenも2になっているので、あればshiboken2をインポートします。
    """
    try:
        imp.find_module("shiboken2")
        import shiboken2
        return shiboken2.wrapInstance(int(OpenMayaUI.MQtUtil.mainWindow()), QWidget)

    except ImportError:
        import shiboken
        return shiboken.wrapInstance(int(OpenMayaUI.MQtUtil.mainWindow()), QWidget)



class MyDialog(QDialog):


    def __init__(self, parent = None, f = 0):
        super(MyDialog, self).__init__(parent, f)
        #-----------------------------------------------------------------------
        # Layout
        #-----------------------------------------------------------------------
        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)
        #-----------------------------------------------------------------------
        # Image
        #-----------------------------------------------------------------------
        imageWidget = QLabel()
        imageWidget.setPixmap(QPixmap(LOGO_IMAGE))
        mainLayout.addWidget(imageWidget)
        #-----------------------------------------------------------------------
        # Description
        #-----------------------------------------------------------------------
        description = QLabel("This is coustom dialog.")
        mainLayout.addWidget(description)
        #-----------------------------------------------------------------------
        # Text input
        #-----------------------------------------------------------------------
        self._inputWidget = QLineEdit()
        mainLayout.addWidget(self._inputWidget)
        #-----------------------------------------------------------------------
        # Buttons
        #-----------------------------------------------------------------------
        buttonArea = QHBoxLayout()
        mainLayout.addLayout(buttonArea)
        buttonArea.addStretch()
        okBtn = QPushButton("OK")
        buttonArea.addWidget(okBtn)
        okBtn.clicked.connect(self.accept)
        cancelBtn = QPushButton("Cancel")
        buttonArea.addWidget(cancelBtn)
        cancelBtn.clicked.connect(self.reject)


    def getInputText(self):
        return self._inputWidget.text()


class DF_TalkUI(QMainWindow):


    def __init__(self, parent = None):
        super(DF_TalkUI, self).__init__(parent)
        self.setObjectName("DF_Talk_Window")
        self.setWindowTitle("DF Talk Window")
        #self._initUI()
        self.errorDialog = QErrorMessage(self) # QErrorMessageインスタンスの保持


    def myInit(self,qApp):
        self.qApp=qApp
        wrapper = QWidget()
        self.setCentralWidget(wrapper)

        mainLayout = QVBoxLayout()
        wrapper.setLayout(mainLayout)

        #-----------------------------------------------------------------------
        # First row
        #-----------------------------------------------------------------------
        firstHolizontalArea = QHBoxLayout()
        firstHolizontalArea.setSpacing(20)
        mainLayout.addLayout(firstHolizontalArea)

        labelArea = QVBoxLayout()
        firstHolizontalArea.addLayout(labelArea)

        labelWidget = QLabel("Text is shown like this.")
        labelArea.addWidget(labelWidget)

        imageWidget = QLabel()
        imageWidget.setPixmap(QPixmap(LOGO_IMAGE))
        labelArea.addWidget(imageWidget)
        labelArea.addStretch()

        textArea = QTextEdit()
        textArea.setPlainText("Text are\ncan be set\nmultiple lines and HTML.")
        firstHolizontalArea.addWidget(textArea)

        mainLayout.addWidget(self._makeHorizontalLine())

        #-----------------------------------------------------------------------
        # Second row
        #-----------------------------------------------------------------------
        secondHolizontalArea = QHBoxLayout()
        secondHolizontalArea.setSpacing(20)
        mainLayout.addLayout(secondHolizontalArea)

        lineEdit = QLineEdit()
        lineEdit.setMaximumWidth(200)
        lineEdit.setText("This widget is useful for inputting text")
        secondHolizontalArea.addWidget(lineEdit)

        comboBox = QComboBox()
        comboBox.addItems(["This", "is", "combobox", "it's", "useful"])
        comboBox.setEditable(True)
        comboBox.setInsertPolicy(QComboBox.NoInsert)
        comboBox.completer().setCompletionMode(QCompleter.PopupCompletion)
        secondHolizontalArea.addWidget(comboBox)

        spinBox = QSpinBox()
        spinBox.setMinimum(0)
        spinBox.setMaximum(10)
        spinBox.setSuffix("min")
        secondHolizontalArea.addWidget(spinBox)

        mainLayout.addWidget(self._makeHorizontalLine())

        #-----------------------------------------------------------------------
        # Third row
        #-----------------------------------------------------------------------
        thirdHorizontalArea = QHBoxLayout()
        thirdHorizontalArea.setSpacing(20)
        mainLayout.addLayout(thirdHorizontalArea)

        checkBox = QCheckBox("Check box")
        thirdHorizontalArea.addWidget(checkBox)
        checkBox.setChecked(True)

        radioArea = QVBoxLayout()
        thirdHorizontalArea.addLayout(radioArea)

        radioGroup = QButtonGroup(self)
        radioBtn1 = QRadioButton("Option 1")
        radioArea.addWidget(radioBtn1)
        radioGroup.addButton(radioBtn1)
        radioBtn2 = QRadioButton("Option 2")
        radioArea.addWidget(radioBtn2)
        radioGroup.addButton(radioBtn2)
        radioBtn3 = QRadioButton("Option 3")
        radioArea.addWidget(radioBtn3)
        radioGroup.addButton(radioBtn3)
        radioBtn1.setChecked(True)

        mainLayout.addWidget(self._makeHorizontalLine())

        #-----------------------------------------------------------------------
        # Fourth row
        #-----------------------------------------------------------------------
        fourthHorizontalArea = QHBoxLayout()
        fourthHorizontalArea.setSpacing(20)
        mainLayout.addLayout(fourthHorizontalArea)

        calender = QCalendarWidget()
        fourthHorizontalArea.addWidget(calender)
        calender.setMaximumWidth(300)

        lcdNumber = QLCDNumber()
        fourthHorizontalArea.addWidget(lcdNumber)
        lcdNumber.display(1234)

        sliderArea = QVBoxLayout()
        fourthHorizontalArea.addLayout(sliderArea)

        sliderDisplay = QLabel("0")
        sliderArea.addWidget(sliderDisplay)
        slider = QSlider(Qt.Horizontal)
        sliderArea.addWidget(slider)
        slider.setRange(0, 100)
        slider.setTickPosition(QSlider.TicksBothSides)
        slider.setSingleStep(5)
        slider.setPageStep(10)
        slider.setTickInterval(10)
        slider.valueChanged.connect(lambda val: sliderDisplay.setText(str(val)))
        slider.setValue(0)

        dialDisplay = QLabel("0")
        sliderArea.addWidget(dialDisplay)
        dial = QDial()
        sliderArea.addWidget(dial)
        dial.setRange(0, 100)
        dial.setSingleStep(5)
        dial.setPageStep(10)
        dial.setNotchesVisible(True)
        dial.setWrapping(True)
        dial.setNotchTarget(5)
        dial.valueChanged.connect(lambda val: dialDisplay.setText(str(val)))
        dial.setValue(0)

        mainLayout.addWidget(self._makeHorizontalLine())

        #-----------------------------------------------------------------------
        # fifth row
        #-----------------------------------------------------------------------
        fifthHorizontalArea = QHBoxLayout()
        fifthHorizontalArea.setSpacing(20)
        mainLayout.addLayout(fifthHorizontalArea)

        fifthHorizontalArea.addWidget(self._makeListWidget())
        fifthHorizontalArea.addWidget(self._makeTableWidget())
        fifthHorizontalArea.addWidget(self._makeTreeWidget())

        mainLayout.addWidget(self._makeHorizontalLine())

        #-----------------------------------------------------------------------
        # sixth row
        #-----------------------------------------------------------------------
        sixthHorizontalArea = QHBoxLayout()
        sixthHorizontalArea.setSpacing(20)
        mainLayout.addLayout(sixthHorizontalArea)

        msgBoxBtn = QPushButton("Message Dialog")
        sixthHorizontalArea.addWidget(msgBoxBtn)
        msgBoxBtn.clicked.connect(partial(QMessageBox().information, self, "Message", "This is normal information message."))

        colorDialogBtn = QPushButton("Color Dialog")
        sixthHorizontalArea.addWidget(colorDialogBtn)
        colorDialogBtn.clicked.connect(self._showColorDialog)

        progressDialogBtn = QPushButton("Progress Dialog")
        sixthHorizontalArea.addWidget(progressDialogBtn)
        progressDialogBtn.clicked.connect(self._showProgressDialog)

        fileDialogBtn = QPushButton("File Dialog")
        sixthHorizontalArea.addWidget(fileDialogBtn)
        fileDialogBtn.clicked.connect(partial(QFileDialog.getOpenFileName, self, "File Select", options = QFileDialog.DontUseNativeDialog))

        #-----------------------------------------------------------------------
        # seventh row
        #-----------------------------------------------------------------------
        seventhHorizontalArea = QHBoxLayout()
        seventhHorizontalArea.setSpacing(20)
        mainLayout.addLayout(seventhHorizontalArea)

        errorMsgBtn = QPushButton("Error Dialog")
        seventhHorizontalArea.addWidget(errorMsgBtn)
        errorMsgBtn.clicked.connect(self._showErrorDialog)

        inputDialogTextBtn = QPushButton("Input (text)")
        seventhHorizontalArea.addWidget(inputDialogTextBtn)
        inputDialogTextBtn.clicked.connect(self._showInputTextDialog)

        inputDialogComboBtn = QPushButton("Input (combo)")
        seventhHorizontalArea.addWidget(inputDialogComboBtn)
        inputDialogComboBtn.clicked.connect(self._showInputComboDialog)

        dialogBtn = QPushButton("Custom Dialog")
        seventhHorizontalArea.addWidget(dialogBtn)
        dialogBtn.clicked.connect(self._showCustomDialog)

        #-----------------------------------------------------------------------
        # dock widget
        #-----------------------------------------------------------------------
        dockWidget = QDockWidget("Dock Window", self)
        dockWrapper = QWidget()
        dockWidget.setWidget(dockWrapper)
        dockWidget.setAllowedAreas(Qt.RightDockWidgetArea | Qt.BottomDockWidgetArea)
        dockLayout = QVBoxLayout()
        dockWrapper.setLayout(dockLayout)
        dockDescription = QLabel("This is dock widget contents.")
        dockLayout.addWidget(dockDescription)
        dockButton = QPushButton("OK")
        dockLayout.addWidget(dockButton)
        self.addDockWidget(Qt.BottomDockWidgetArea, dockWidget)


    def _makeHorizontalLine(self):
        hline = QFrame()
        hline.setFrameShape(QFrame.HLine)
        hline.setFrameShadow(QFrame.Sunken)
        return hline


    def _makeListWidget(self):
        """
        QListWidgetを作成する関数
        """
        listWidget = QListWidget()
        listWidget.setMaximumWidth(100)
        listWidget.addItems(["this", "is", "list", "widget"])
        return listWidget


    def _makeTableWidget(self):
        """
        QTableWidgetを作成する関数
        """
        tableWidget = QTableWidget()
        headerLabels = ["Name", "Age", "Sex"]
        tableWidget.setColumnCount(len(headerLabels))
        tableWidget.setHorizontalHeaderLabels(headerLabels)
        tableWidget.verticalHeader().setVisible(False)

        try:
            tableWidget.horizontalHeader().setSectionResizeMode(QHeaderView.Interactive)

        except:
            tableWidget.horizontalHeader().setResizeMode(QHeaderView.Interactive)

        tableWidget.setAlternatingRowColors(True)
        tableWidget.horizontalHeader().setStretchLastSection(True)
        dataList = [
            ["Taro",    "25", "Male"],
            ["Hanako",  "30", "Female"],
            ["Ichiro",  "50", "Male"],
            ["Jiro",    "40", "Male"]
        ]
        tableWidget.setRowCount(len(dataList))

        for row, colData in enumerate(dataList):

            for col, value in enumerate(colData):
                item = QTableWidgetItem(value)
                tableWidget.setItem(row, col, item)

        return tableWidget


    def _makeTreeWidget(self):
        """
        QTreeWidgetを作成する関数
        """
        treeWidget = QTreeWidget()
        headerLabels = ["Name", "Age"]
        treeWidget.setColumnCount(len(headerLabels))
        treeWidget.setHeaderLabels(headerLabels)
        treeWidget.setAlternatingRowColors(True)
        treeData = {
            "Male":[
                {"name":"Taro",     "age":"25"},
                {"name":"Ichiro",   "age":"50"},
                {"name":"Jiro",     "age":"40"}
            ],
            "Female":[
                {"name":"Hanako",   "age":"30"}
            ]
        }

        for sex, profiles in treeData.items():
            topItem = QTreeWidgetItem([sex])
            treeWidget.addTopLevelItem(topItem)

            for profile in profiles:
                childItem = QTreeWidgetItem(topItem, [profile.get("name"), profile.get("age")])

        treeWidget.expandAll()
        return treeWidget


    def _showColorDialog(self):
        """
        QColorDialog表示スロット
        """
        colorDialog = QColorDialog(self)
        response = colorDialog.exec_()

        if response != QDialog.Accepted:
            return

        chosen = colorDialog.currentColor()
        print("Selected color >> (%d, %d, %d)" % (chosen.red(), chosen.green(), chosen.blue()))


    def _showProgressDialog(self):
        """
        QProgressDialog表示スロット
        """
        max = 100
        progressDialog = QProgressDialog("Progress...", "Cancel", 0, max, self)
        progressDialog.setWindowTitle("Progress Dialog")

        for count in range(max+1):
            self.qApp.processEvents()

            if progressDialog.wasCanceled():
                break

            progressDialog.setValue(count)
            progressDialog.setLabelText("Progress... %d %%" % count)
            time.sleep(0.1)


    def _showErrorDialog(self):
        """
        QErrorMessage表示スロット
        """
        self.errorDialog.showMessage("This is error message.")


    def _showInputTextDialog(self):
        """
        QInputDialog表示スロット(文字列入力型)
        """
        response = QInputDialog.getText(self,
                                    "Input Text",
                                    "Input text here.")
        print(response)


    def _showInputComboDialog(self):
        """
        QInputDialog表示スロット(アイテム選択型)
        """
        response = QInputDialog.getItem(self,
                                    "Select Item",
                                    "Select item from the combo box.",
                                    ["item1", "item2", "item3", "item4"],
                                    editable=False)
        print(response)


    def _showCustomDialog(self):
        """
        MyDialog表示スロット
        """
        dialog = MyDialog()
        response = dialog.exec_()

        if response == QDialog.Accepted:
            print(dialog.getInputText())


def start(app):
    maya_win = get_maya_pointer()
    ui = DF_TalkUI(parent = maya_win)
    ui.myInit(app)
    ui.show()
    return ui


if __name__ == '__main__':

    app = QApplication.instance()
    if app is None:
        app = QApplication([])
    ui = start(app)
    app.exec_()

[maya]スキンウェイトを部分的に頂点を選択してコピーしたい。

スキンウェイトを部分的に頂点を選択してコピーしたい。

1 つの頂点からウェイトをコピーする
1 つの頂点を選択し、そのウェイト値を選択したその他の頂点にコピーすることができます。ウェイト値をペーストする頂点は、同じメッシュ上にあっても別のメッシュ上にあっても構いません。

スキン ポイントのウェイト値をコピーしてペーストするには

スキン ウェイト ペイント ツール(Paint Skin Weights Tool)で、選択(Select)またはペイント選択(Paint Select)モードに切り替えます。

ウェイト値をコピーする頂点を選択し、コピー ツール アイコン をクリックします。ウェイト

値をペーストする頂点を選択し、ペースト ツール アイコン をクリックします。コピーしたウェイト値が選択したすべての頂点にペーストされます。

注:
メッシュから別のメッシュにウェイト値をペーストする場合、ソースの頂点に対応するウェイト値のインフルエンスがターゲット メッシュに見つからない場合はエラーが表示されます。

次のホットキーを使用して、頂点から頂点にウェイト値をコピーしてペーストすることもできます。

(Windows) [Alt]+[Ctrl]+[C]、[Alt]+[Ctrl]+[V]
(Mac OS X) [Option]+[Control]+[C]、[Option]+[Control]+[V]


スキンウェイトを部分的に頂点を選択してコピーしたい。がうまくいかない。

// エラー: file: C:/Program Files/Autodesk/Maya2022/scripts/others/artAttrSkinWeightCopy.mel line 22: 選択した項目が多すぎます。ウェイトをコピーする頂点を 1 つだけ選択してください。 //

C:/Program Files/Autodesk/Maya2022/scripts/others/artAttrSkinWeightPaste.mel

1回コピーさせてペーストするのをループさせればできる?

と思って作ったが、いらなくなったコードサンプル 参考にしかならないけど乗せておく。

global proc artAttrSkinWeightCopy_One()
{
    global string $gSkinWeightCopyInfluences[];
    global float $gSkinWeightCopyWeights[];
    
    string $sel[] = `ls -sl -flatten`;
    if(size($sel) < 1) {
        error("選択した項目がありません。ウェイトをコピーする頂点を 1 つだけ選択してください。");		
		return;
    }
    
    if(size($sel) > 1) {
        error("選択した項目が多すぎます。ウェイトをコピーする頂点を 1 つだけ選択してください。");
		return;
    }
    
    string $skinCluster = findSkinClusterFromSelectedComponent($sel[0]);
    if($skinCluster == "")
        return;
    $gSkinWeightCopyInfluences = `skinCluster -q -influence $skinCluster`;
    $gSkinWeightCopyWeights = `skinPercent -q -v $skinCluster`;
            
    
}
global proc artAttrSkinWeightCopy_multiSelect_test()
{
    global string $gSkinWeightCopyInfluences[];
    global float $gSkinWeightCopyWeights[];
    
    string $sel[] = `ls -sl -flatten`;
    if(size($sel) < 1) {
        error("選択した項目がありません。ウェイトをコピーする頂点を 1 つ以上だけ選択してください。");		
		return;
    }
    
    if(size($sel) > 1) {
        error("選択した項目が多すぎます。ウェイトをコピーする頂点を 1 つだけ選択してください。");
		return;
    }
    
    string $skinCluster = findSkinClusterFromSelectedComponent($sel[0]);
    if($skinCluster == "")
        return;
    $gSkinWeightCopyInfluences = `skinCluster -q -influence $skinCluster`;
    print("$gSkinWeightCopyInfluences--------------\n");
    print($gSkinWeightCopyInfluences);
    print("\n--------------\n");
    $gSkinWeightCopyWeights = `skinPercent -q -v $skinCluster`;
    print("$gSkinWeightCopyWeights--------------\n");
    $gSkinWeightCopyWeights_Str=floatArrayToString($gSkinWeightCopyWeights, ",");
    print("$gSkinWeightCopyWeights_Str= "+$gSkinWeightCopyWeights_Str);
    print("\n--------------\n");
}
global proc artAttrSkinWeightCopy_multiSelect2()
{
    $OldSelectVtx = `ls -sl`;
    print("$OldSelectVtx");
    $OldSelectVtx_Str = stringArrayToString($OldSelectVtx, ",");
    print("$OldSelectVtx_Str= "+$OldSelectVtx_Str+"\n");
    
    //UIで選択しておく
    $BaseMesh = "|Mesh|Arm_Only5";
    $PastMesh = "|Mesh|Jacket_For_ShortSkirtUV";
    select($BaseMesh);
    string $selectBaseVtx[] = `polyInfo -nonManifoldVertices`; 
    //string $selectBaseVtx[] = `ls -sl -flatten`; 
    select($PastMesh);
    string $selectPastVtx[] = `polyInfo -nonManifoldVertices`; 
    //string $selectPastVtx[] = `ls -sl -flatten`; 
    
    //選択した頂点を再選択
    select($OldSelectVtx);
    
    $selectBaseVtx_len = `size($selectBaseVtx)`;
    $selectBaseVtx_Str = stringArrayToString($selectBaseVtx, ",");
    print("$selectBaseVtx_Str= "+$selectBaseVtx_Str+"\n");
    print("$selectBaseVtx_len= "+$selectBaseVtx_len+"\n");
    
    for($i = 0; $i < $selectBaseVtx_len; $i++)
    {
	    select($selectBaseVtx[$i]);
	    print("$selectBaseVtx["+$i+"] \n");
	    //artAttrSkinWeightCopy;
	    select($selectPastVtx[$i]);
	    print("$selectPastVtx["+$i+"] \n");
	    //artAttrSkinWeightPaste;
    }
    
    select($OldSelectVtx);
}
artAttrSkinWeightCopy_multiSelect2();

参考URL
https://help.autodesk.com/view/MAYACRE/JPN/?guid=GUID-7D895BB0-1522-4388-96E0-4245127F90AB

[php] [chat]シンプルなIPアドレスファイル名ルームでのチャットを作った。

お客様のチャット

<!-- chat.php -->

<?php
function trace($txt){
    //print($txt);
    $a="a";
}
class RoomLog
{
    
    public $LOG_FILE_NAME;
    public $name;
    public $SPLIT_Str;
    public $message;
    public function get_ip_file_name(){
        global $_SERVER;
        $ip_Address=$_SERVER['REMOTE_ADDR'];
        print("ip_Address= " . $ip_Address . "<br>");
        if($ip_Address=="::1"){
            $ip_Address="192.168.1.29";
            print("テストのためip変数上書きしました。ip_Address= " . $ip_Address . "<br>");
        }
        $ip_Address_Arr = explode(".", $ip_Address);
        $ip_file_name = join('_', $ip_Address_Arr);
        $ip_file_name = "log/ip_" . $ip_file_name . "_chatlog.txt";
        print("ip_file_name= " . $ip_file_name . "<br>");
        return $ip_file_name;
    }
    public function initLog(){
        trace("■ initLog()<br>");
        global $LOG_FILE_NAME;
        global $name;
        global $SPLIT_Str;
        global $message;
        
        $ip_file_name=$this->get_ip_file_name();
        
        // データを書き込むファイルの名前
        //$LOG_FILE_NAME = "chat_class_txt_log.txt";
        $LOG_FILE_NAME = $ip_file_name;
     
        // 区切りのための文字列
        $SPLIT_Str = "|-|";
     
        // 名前を格納する変数
        $name = "お客様";
        // メッセージを格納する変数
        $message = "";
        
        $this->LOG_FILE_NAME=$LOG_FILE_NAME;
        $this->name=$name;
        $this->SPLIT_Str=$SPLIT_Str;
        $this->message=$message;
        /*
        trace("<br>");
        trace("this->LOG_FILE_NAME= " . $this->LOG_FILE_NAME . "<br>");
        trace("this->name= " . $this->name . "<br>");
        trace("this->SPLIT_Str= " . $this->SPLIT_Str . "<br>");
        trace("this->message= " . $this->message . "<br>");
        */
    }
    
    public function startMain(){
        trace("■ startMain()<br>");
        $this->initLog();
        $this->CheckFormPostData();
        $this->LogShow();
    }
    

    public function CheckFormPostData(){
        trace("■ CheckFormPostData()<br>");
        global $_POST;
        
        $name = $this->name;
        $SPLIT_Str = $this->SPLIT_Str;
        $message = $this->message;
        
        
        // 送信されたデータ
        $_POST_string = join(', ', $_POST);
        trace("_POST_string2= " . $_POST_string . "<br>");
        
        if (empty($_POST)) {
            trace("The form is empty.");
        } else {
            trace("Form data is present.");
        }
        
        // 送信された名前とメッセージを変数に代入
        if (isset($_POST['name'])) {
          $name = $_POST['name'];
     
          if (strpos($name, $SPLIT_Str) !== false) {
            // 名前に区切り文字が含まれている場合の処理
            echo "使用できない文字列「|-|」が含まれています。";
            return;
          }
     
          if ($name == "") {
            $name = "お客様";
          }
        }
        if (isset($_POST['message'])) {
          $message = $_POST['message'];
     
          if (strpos($message, $SPLIT_Str) !== false) {
            // メッセージに区切り文字が含まれている場合の処理
            echo "使用できない文字列「|-|」が含まれています。";
            return;
          }
     
          //$this->LOG_FILE_NAME=$LOG_FILE_NAME;
          $this->name=$name;
          //$this->SPLIT_Str=$SPLIT_Str;
          $this->message=$message;
          $this->LogWrite();
        }
    }
   
    
    public function LogWrite(){
      trace("■ LogWrite()<br>");
      $LOG_FILE_NAME = $this->LOG_FILE_NAME;
      $name = $this->name;
      $SPLIT_Str = $this->SPLIT_Str;
      $message = $this->message;
        
      //書き込みモードでファイルを開く
      $fp = fopen($LOG_FILE_NAME, "a") or exit($LOG_FILE_NAME . "が開けません");
 
      // | を区切り文字として2つのデータを繋げて書き込む
      fwrite($fp, $name . $SPLIT_Str . $message . "\n");
      
      
      // リダイレクトのためのHTTPヘッダーを送信
      //header("Location: " . $_SERVER['PHP_SELF'], true, 303);
      
      fclose($fp);
    }

    function LogShow(){
        trace("■ LogShow()<br>");
        //global $LOG_FILE_NAME;
        global $linesNum;
        global $lines;
        $LOG_FILE_NAME = $this->LOG_FILE_NAME;
        //$name = $this->name;
        //$SPLIT_Str = $this->SPLIT_Str;
        //$message = $this->message;
        
        if (!file_exists($LOG_FILE_NAME)) {
          // ファイルがない場合
          echo "書き込みはありません。";
     
          $linesNum = 0;
        } else {
     
          // ファイルの全行を読み取る
          $lines = file($LOG_FILE_NAME);
     
          // 読み込んだ行数
          $linesNum = count($lines);
        }
    }
    
}

$RoomLog_ins = new RoomLog();
$RoomLog_ins->startMain();

?>
 
<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="utf-8">
  <title>1行メッセージ</title>
</head>
 
<body>
 
<h1>お問い合わせ内容</h1>
 
  <section>
    <?php
 
      // 一行ずつ表示する処理
      for ($i = 0; $i < $linesNum; $i++) {
 
         // 区切り文字でデータを区切って配列に格納
         $array = explode($SPLIT_Str, $lines[$i]);
 
         // 区切り文字の前の部分は名前
         $name = htmlspecialchars($array[0]);
         
         
         // 区切り文字の後の部分はメッセージ
         
         $array_length = count($array);
         if ($array_length == 2) {
           $message = htmlspecialchars($array[1]);
         }
         // 名前とメッセージを表示
         echo '<p>' . $name . "「" . str_replace(PHP_EOL, "", $message) . '」</p>';
      }
    ?>
  </section>


  
 
  <form method="post" action="chat_class_txt.php">
    <div>
      <!--<b>おなまえ</b>-->
      <!--<input name="name" type="text" size="20" maxlength="10">-->
      <input name="name" type="hidden" size="20" maxlength="10">
    </div>
    <div>
      <!--<b>ご入力</b>-->
      <input name="message" type="text" size="50" maxlength="50" required>
      <button name="submit" type="submit">送信</button>
    </div>
    
  </form>
  
</body>
</html>

担当者のチャット画面

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="utf-8">
  <title>1行メッセージ</title>
</head>
 
<body>
<!-- chat.php -->

<style>
.base {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 90vh;
}
.class1 {
  width: 10%;
}
 
.class2 {
  display: flex;
  flex-direction: column;
  width: 90%;
}

</style>
<style>
  div {
    text-align: center;
    /* background-color: #aaaaaa; 16進数のカラーコードを使用する例 */
  }
  button{
      font-size: 200%;
      width:100px;
      height:100px;
  }
</style>
  <div class="base">
    <div class="class1">

<?php
//$dir = "log";
//$files = scandir($dir);
$files = glob("log/*");
$counter=0;
foreach ($files as $file) {
    //echo("<h2>" . $file . "</h2><br>");
    $url='log_frame.php';
    //echo('<a href="'.$url.'"><h1><div >' . $counter . '</div></h1></a><br>');
    
    $htmlStr='';
    $htmlStr=$htmlStr.'<form method="post" action="chat_class_txt_admin.php">';
    $htmlStr=$htmlStr.'<input type="hidden" name="LOG_FILE_NAME" value="' . $file . '">';
    $htmlStr=$htmlStr.'<button name="submit" type="submit">' . $counter . '</button>';
    $htmlStr=$htmlStr.'</form>';
    echo($htmlStr);

    $counter=$counter+1;
}

?>
      
</div>
<div class="class2">
<?php
function trace($txt){
    //print($txt);
    $a="a";
}
class RoomLog
{
    
    public $LOG_FILE_NAME;
    public $LOG_FILE_NAME_Opened;
    public $name;
    public $SPLIT_Str;
    public $message;
    public function get_ip_file_name(){
        global $_SERVER;
        $ip_Address=$_SERVER['REMOTE_ADDR'];
        trace("ip_Address= " . $ip_Address . "<br>");
        if($ip_Address=="::1"){
            $ip_Address="192.168.1.29";
            trace("テストのためip変数上書きしました。ip_Address= " . $ip_Address . "<br>");
        }
        $ip_Address_Arr = explode(".", $ip_Address);
        $ip_file_name = join('_', $ip_Address_Arr);
        $ip_file_name = "log/ip_" . $ip_file_name . "_chatlog.txt";
        trace("ip_file_name= " . $ip_file_name . "<br>");
        return $ip_file_name;
    }
    
    public function CheckFormPostData_Admin(){
        trace("■ CheckFormPostData_Admin()<br>");
        global $_POST;
        
        // 送信されたデータ
        $_POST_string = join(', ', $_POST);
        trace("_POST_string1= " . $_POST_string . "<br>");
        
        if (empty($_POST)) {
            trace("The form is empty.<br>");
        } else {
            trace("Form data is OK present.<br>");
        }
        if (isset($_POST['LOG_FILE_NAME'])) {
          $LOG_FILE_NAME = $_POST['LOG_FILE_NAME'];
          $this->LOG_FILE_NAME=$LOG_FILE_NAME;
          print("LOG_FILE_NAME= " . $LOG_FILE_NAME . "<br>");
        }
        /*
        // 送信された名前とメッセージを変数に代入
        if (isset($_POST['name'])) {
          $name = $_POST['name'];
     
          if (strpos($name, $SPLIT_Str) !== false) {
            // 名前に区切り文字が含まれている場合の処理
            echo "使用できない文字列「|-|」が含まれています。";
            return;
          }
     
          if ($name == "") {
            $name = "お客様";
          }
        }
        if (isset($_POST['message'])) {
          $message = $_POST['message'];
     
          if (strpos($message, $SPLIT_Str) !== false) {
            // メッセージに区切り文字が含まれている場合の処理
            echo "使用できない文字列「|-|」が含まれています。";
            return;
          }
     
          //$this->LOG_FILE_NAME=$LOG_FILE_NAME;
          $this->name=$name;
          //$this->SPLIT_Str=$SPLIT_Str;
          $this->message=$message;
          $this->LogWrite();
        }
        */
        return $LOG_FILE_NAME;
    }

    public function initLog(){
        trace("■ initLog()<br>");
        global $LOG_FILE_NAME;
        global $name;
        global $SPLIT_Str;
        global $message;
        
        $ip_file_name=$this->CheckFormPostData_Admin();
        
        // データを書き込むファイルの名前
        //$LOG_FILE_NAME = "chat_class_txt_log.txt";
        $LOG_FILE_NAME = $ip_file_name;
     
        // 区切りのための文字列
        $SPLIT_Str = "|-|";
     
        // 名前を格納する変数
        $name = "担当者";
        // メッセージを格納する変数
        $message = "";
        
        $this->LOG_FILE_NAME=$LOG_FILE_NAME;
        $this->name=$name;
        $this->SPLIT_Str=$SPLIT_Str;
        $this->message=$message;
        /*
        trace("<br>");
        trace("this->LOG_FILE_NAME= " . $this->LOG_FILE_NAME . "<br>");
        trace("this->name= " . $this->name . "<br>");
        trace("this->SPLIT_Str= " . $this->SPLIT_Str . "<br>");
        trace("this->message= " . $this->message . "<br>");
        */
    }
    
    public function startMain(){
        trace("■ startMain()<br>");
        $this->initLog();
        $this->CheckFormPostData();
        $this->LogShow();
    }
    

    public function CheckFormPostData(){
        trace("■ CheckFormPostData()<br>");
        global $_POST;
        
        $name = $this->name;
        $SPLIT_Str = $this->SPLIT_Str;
        $message = $this->message;
        
        
        // 送信されたデータ
        $_POST_string = join(', ', $_POST);
        //trace("_POST_string2= " . $_POST_string . "<br>");
        
        if (empty($_POST)) {
            trace("The form is empty.<br>");
        } else {
            trace("Form data is present.<br>");
        }
        
        // 送信された名前とメッセージを変数に代入
        if (isset($_POST['name'])) {
          $name = $_POST['name'];
     
          if (strpos($name, $SPLIT_Str) !== false) {
            // 名前に区切り文字が含まれている場合の処理
            echo "使用できない文字列「|-|」が含まれています。<br>";
            return;
          }
     
          if ($name == "") {
            $name = "担当者";
          }
        }
        if (isset($_POST['message'])) {
          $message = $_POST['message'];
     
          if (strpos($message, $SPLIT_Str) !== false) {
            // メッセージに区切り文字が含まれている場合の処理
            echo "使用できない文字列「|-|」が含まれています。<br>";
            return;
          }
     
          //$this->LOG_FILE_NAME=$LOG_FILE_NAME;
          $this->name=$name;
          //$this->SPLIT_Str=$SPLIT_Str;
          $this->message=$message;
          $this->LogWrite();
        }
    }
   
    
    public function LogWrite(){
      trace("■ LogWrite()<br>");
      $LOG_FILE_NAME = $this->LOG_FILE_NAME;
      $name = $this->name;
      $SPLIT_Str = $this->SPLIT_Str;
      $message = $this->message;
        
      //書き込みモードでファイルを開く
      $fp = fopen($LOG_FILE_NAME, "a") or exit($LOG_FILE_NAME . "が開けません<br>");
 
      // | を区切り文字として2つのデータを繋げて書き込む
      fwrite($fp, $name . $SPLIT_Str . $message . "\n");
      
      
      // リダイレクトのためのHTTPヘッダーを送信
      //header("Location: " . $_SERVER['PHP_SELF'], true, 303);
      
      fclose($fp);
    }

    function LogShow(){
        trace("■ LogShow()<br>");
        //global $LOG_FILE_NAME;
        global $linesNum;
        global $lines;
        $LOG_FILE_NAME = $this->LOG_FILE_NAME;
        //$name = $this->name;
        //$SPLIT_Str = $this->SPLIT_Str;
        //$message = $this->message;
        
        if (!file_exists($LOG_FILE_NAME)) {
          // ファイルがない場合
          echo "書き込みはありません。<br>";
     
          $linesNum = 0;
        } else {
     
          // ファイルの全行を読み取る
          $lines = file($LOG_FILE_NAME);
     
          // 読み込んだ行数
          $linesNum = count($lines);
        }
    }
    
}

$RoomLog_ins = new RoomLog();
$RoomLog_ins->startMain();

?>
 

 
<h1>お問い合わせ内容</h1>
 
  <section>
    <?php
 
      // 一行ずつ表示する処理
      for ($i = 0; $i < $linesNum; $i++) {
 
         // 区切り文字でデータを区切って配列に格納
         $array = explode($SPLIT_Str, $lines[$i]);
 
         // 区切り文字の前の部分は名前
         $name = htmlspecialchars($array[0]);
         
         
         // 区切り文字の後の部分はメッセージ
         
         $array_length = count($array);
         if ($array_length == 2) {
           $message = htmlspecialchars($array[1]);
         }
         // 名前とメッセージを表示
         echo '<p>' . $name . "「" . str_replace(PHP_EOL, "", $message) . '」</p>';
      }
    ?>
  </section>


  
 
  <form method="post" action="chat_class_txt_admin.php">
    <div>
      <!--<b>おなまえ</b>-->
      <!--<input name="name" type="text" size="20" maxlength="10">-->
      <input name="name" type="hidden" size="20" maxlength="10">
    </div>
    <div>
      <!--<b>ご入力</b>-->
      <?php
      echo('<input type="hidden" name="LOG_FILE_NAME" value="' . $LOG_FILE_NAME . '">');
      ?>
      <input name="message" type="text" size="50" maxlength="50" required>
      <button name="submit" type="submit">送信</button>
    </div>
    
  </form>
  
  
    </div><!--div class="class2"-->
  </div><!--div class="base"-->
</body>
</html>

こちらのサイトを参考にしました。
PHPで作るチャット(7) クロスサイトスクリプティング(XSS)の修正

このPHPをクラスベースで書き直しました。

[maya][python]scriptEditorInfoでスクリプトエディタの内容のログの最後の行を取る

Take the last line of the log in the contents of the script editor

#!/usr/bin/env python
# -*- coding: utf-8 -*-
workSpaceDir=cmds.workspace( q=True, rootDirectory=True )
print("workSpaceDir= "+workSpaceDir)
historyFilename=workSpaceDir+'scriptEditorInfo_tempHistoryLog7.txt'
print("historyFilename= "+historyFilename)
cmds.scriptEditorInfo(input="")
cmds.scriptEditorInfo( historyFilename=historyFilename, writeHistory=True )

print("----startLog00700---")
#-----この間にUSD prim を選択させてみたい。 ----------
#------難しいかな??
#-----この間にUSD prim を選択させてみたい。 ----------
import codecs
fin  = codecs.open(historyFilename, 'r', 'shift_jis')
lineCount=0
lineArr=[]
for line in fin:
    #print("lineNum:"+str(lineCount)+" lineStr:"+line)
    lineCount=lineCount+1
    lineArr.append(line)
#fout = codecs.open('sjis.txt', 'w', 'shift_jis')
#fin_str=str(fin)
lineArr_len=len(lineArr)
print("lineArr_len= "+str(lineArr_len))
LastLine_Str=lineArr[lineArr_len-1]
print("LastLine_Str= "+LastLine_Str)

cmds.scriptEditorInfo(input="")
cmds.scriptEditorInfo( historyFilename=historyFilename, writeHistory=False )

print("----NotLoged----")

[maya]maya_usdでシーンにある選択したステージをmaya_usd apiのstageとして取得するには?

How to get the selected stage in the scene in maya_usd as the stage in maya_usd api?

import maya.cmds as cmds

def get_stage(stagePath):
    import mayaUsd.ufe
    #stagePath="|stage1|stageShape1"
    #stage = mayaUsd.ufe.getStage("|stage1|stageShape1")
    stage = mayaUsd.ufe.getStage(stagePath)
    print("stage= "+str(stage))
    # レイヤーを取得
    layer = stage.GetRootLayer()
    print("layer= "+str(layer))

def get_selected_maya_usd_stage():
    selectedlist=cmds.ls(sl=True,long=1)
    print("selectedlist= "+str(selectedlist))
    selectedZero=selectedlist[0]
    selectedZeroType=cmds.objectType( selectedZero )
    print("selectedZeroType= "+str(selectedZeroType))
    
    stagePath=""
    if(str(selectedZeroType)=="mayaUsdProxyShape"):
        stagePath=selectedZero
        get_stage(stagePath)
    elif(str(selectedZeroType)=="transform"):
        stagePath="|stage"+stageNumStr+"|stageShape"+stageNumStr
        get_stage(stagePath)
    else:
        print("not stage!!!!")
        
get_selected_maya_usd_stage()

OUTPUT

selectedlist= ['|stage5']
selectedZeroType= transform
stage= Usd.Stage.Open(rootLayer=Sdf.Find('anon:000002B5C8EA5570:anonymousLayer1'), sessionLayer=Sdf.Find('anon:000002B5C8EA5870:anonymousLayer1-session.usda'), pathResolverContext=Ar.DefaultResolverContext())
layer= Sdf.Find('anon:000002B5C8EA5570:anonymousLayer1')

ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー

selectedlist= ['|stage5|stageShape5']
selectedZeroType= mayaUsdProxyShape
stage= Usd.Stage.Open(rootLayer=Sdf.Find('anon:000002B5C84B1070:anonymousLayer1'), sessionLayer=Sdf.Find('anon:000002B5C84B1670:anonymousLayer1-session.usda'), pathResolverContext=Ar.DefaultResolverContext())
layer= Sdf.Find('anon:000002B5C84B1070:anonymousLayer1')

参考URL
https://github.com/Autodesk/maya-usd/issues/1046

[unrealenghine,photoshop]HDRは32bitなので16bitに変換しないとPNGに保存できない、8bitに変換しないと TGA に保存できない

Can Not HDR Traslate To TGA even if CopySave

 function step_8bit(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(cTID('Dpth'), 8);
    var desc2 = new ActionDescriptor();
    desc2.putInteger(cTID('Vrsn'), 6);
    desc2.putEnumerated(cTID('Mthd'), sTID("hdrToningMethodType"), sTID("hdrtype4"));
    desc2.putDouble(cTID('Rds '), 7.68);
    desc2.putDouble(cTID('Thsh'), 0.52959457138863);
    desc2.putDouble(cTID('Cntr'), 1);
    desc2.putDouble(cTID('Strt'), 20);
    desc2.putDouble(cTID('Dtl '), 30);
    desc2.putBoolean(cTID('Smoo'), false);
    var desc3 = new ActionDescriptor();
    desc3.putString(cTID('Nm  '), "初期設定");
    var list1 = new ActionList();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(cTID('Hrzn'), 0);
    desc4.putDouble(cTID('Vrtc'), 0);
    list1.putObject(cTID('CrPt'), desc4);
    var desc5 = new ActionDescriptor();
    desc5.putDouble(cTID('Hrzn'), 255);
    desc5.putDouble(cTID('Vrtc'), 255);
    list1.putObject(cTID('CrPt'), desc5);
    desc3.putList(cTID('Crv '), list1);
    desc2.putObject(sTID("classFXShapeCurve"), cTID('ShpC'), desc3);
    desc2.putBoolean(sTID("deghosting"), false);
    desc1.putObject(cTID('With'), sTID("hdrOptions"), desc2);
    executeAction(sTID('convertMode'), desc1, dialogMode);
  };  

  //save TGA  (Can Not  HDR Traslate To TGA even if CopySave)
  function step4_save_tga(savePath){
  step_8bit();
  SaveOptions = new TargaSaveOptions();     
  TargaSaveOptions.alphaChannels = true; //include alpha channels, change to false for none    
  TargaSaveOptions.resolution = TargaBitsPerPixels.TWENTYFOUR; //options of SIXTEEN or THIRTYTWO 
  TargaSaveOptions.rleCompression = true; //false for no compression
  var saveFile = File(savePath); 
  app.activeDocument.saveAs(saveFile, TargaSaveOptions, true,Extension.LOWERCASE);      
  }; 

//---------------------------------------------------------------------------------
function step1_16bit(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(cTID('Dpth'), 16);
    var desc2 = new ActionDescriptor();
    desc2.putInteger(cTID('Vrsn'), 6);
    desc2.putEnumerated(cTID('Mthd'), sTID("hdrToningMethodType"), sTID("hdrtype4"));
    desc2.putDouble(cTID('Rds '), 7.68);
    desc2.putDouble(cTID('Thsh'), 0.52959457138863);
    desc2.putDouble(cTID('Cntr'), 1);
    desc2.putDouble(cTID('Strt'), 20);
    desc2.putDouble(cTID('Dtl '), 30);
    desc2.putBoolean(cTID('Smoo'), false);
    var desc3 = new ActionDescriptor();
    desc3.putString(cTID('Nm  '), "初期設定");
    var list1 = new ActionList();
    var desc4 = new ActionDescriptor();
    desc4.putDouble(cTID('Hrzn'), 0);
    desc4.putDouble(cTID('Vrtc'), 0);
    list1.putObject(cTID('CrPt'), desc4);
    var desc5 = new ActionDescriptor();
    desc5.putDouble(cTID('Hrzn'), 255);
    desc5.putDouble(cTID('Vrtc'), 255);
    list1.putObject(cTID('CrPt'), desc5);
    desc3.putList(cTID('Crv '), list1);
    desc2.putObject(sTID("classFXShapeCurve"), cTID('ShpC'), desc3);
    desc2.putBoolean(sTID("deghosting"), false);
    desc1.putObject(cTID('With'), sTID("hdrOptions"), desc2);
    executeAction(sTID('convertMode'), desc1, dialogMode);
  };

  //save Png 
  function step4_save(savePath,enabled, withDialog) {
  step1_16bit();
  var file_obj = new File(savePath);
  var png_opt = new PNGSaveOptions();
  png_opt.interlaced = false;
  var savedDisplayDialogs = app.displayDialogs;
  app.displayDialogs = DialogModes.NO;
  activeDoc=app.activeDocument;
  app.activeDocument.saveAs(file_obj, png_opt, true, Extension.LOWERCASE);
  
  }
//---------------------------------------------------------------------------------


  // save HDR (HDR to HDR)
  function step4_save(savePath,enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putString(cTID('As  '), "Radiance");
    desc1.putPath(cTID('In  '), new File(savePath));
    desc1.putInteger(cTID('DocI'), 70);
    desc1.putBoolean(cTID('LwCs'), true);
    executeAction(sTID('save'), desc1, dialogMode);
  };

参考

Targa形式で保存する

http://www.openspc2.org/book/PhotoshopCC2014/easy/save/010/index.html