XSI ログ削除ツール

C言語で自作してみた。

クラッシュした際に下記ディレクトリに書き出されるログファイル
を一括して削除してしまおうという試み。
たぶん、クラッシュするたびにログが溜まっていくので、
HDDスペースを開けたい場合などなど。
> C:\Users\(USER_NAME)\Softimage\XSI\7.01

削除対象ファイルは以下の2つ。
1. [****].ScriptLog.txt
2. [****].dmp

※ コンパイラはMinGWを使ってます。
適当に改変して使いやすいようにしください:p

ソース
// >gcc xsi_clean.c -o xsi_clean -std=gnu99

■ Githubに置いてみた
https://github.com/mikan56/delLog

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dirent.h>


int main(int argc, char **argv) {
char *base_dir;
DIR *dir;
struct dirent *dp;
char *c;

base_dir = "C:\\Users\\[xxxx]\\Softimage\\XSI_7.01";

if(NULL == (dir = opendir(base_dir))) {
printf("Can not open directory.\n->%s\n", base_dir);
scanf("%c", &c);
exit(1);
}
char tmp_str[256] = {0};
strcpy(tmp_str, base_dir);
char *d = "\\";
char *b_dir;
b_dir = strcat(tmp_str, d);
//printf("%s\n", b_dir);

char *r1;
char *r2;
for(int i = 0; NULL != (dp = readdir(dir)); ++i) {
r1 = strstr(dp->d_name, ".ScriptLog.txt");
if(r1 != NULL) {
char tmp[256] = {0};
strcpy(tmp, b_dir);
strcat(tmp, dp->d_name);
#ifdef DEVELOPMENT
if(tmp != 0) printf("remove success:%s\n", tmp);
else printf("remove failed:%s\n", i, tmp);
#else
if(remove(tmp) == 0) printf("remove success:%s\n", tmp);
else printf("remove failed:%s\n", i, tmp);
#endif
}
r2 = strstr(dp->d_name, ".dmp");
if(r2 != NULL) {
char tmp2[256] = {0};
strcpy(tmp2, b_dir);
strcat(tmp2, dp->d_name);
#ifdef DEVELOPMENT
if(tmp2 != 0) printf("remove success:%s\n", tmp2);
else printf("remove failed:%s\n", i, tmp2);
#else
if(remove(tmp2) == 0) printf("remove success:%s\n", tmp2);
else printf("remove failed:%s\n", i, tmp2);
#endif
}
}
closedir(dir);

scanf("%c", &c);
return 1;
}

Normal Map - memo

Zbrush

ZBrushでキューブを作成。
適当にコネる。
















サブディビジョンのレベルを上げる。
Normal Mapを作る前にサブディビジョンレベルを1にしておく。























ツールからNormal Map作成























ローモデルとハイモデルをobjに書き出し。

XSI

ZBrushから書き出した2つのモデルをインポート。
Ultimapperを実行する





















最終的なレンダーツリー












レンダリング結果

[XSI] PPGLayout UI Demo with Cpp

毎度コードを貼逃げ

これコマンドが実行されないのよね。。。

XSILoadPluginでコマンド、プロパティ、メニューを登録します。
(1) [PluginRegister].RegisterCommand(); // _Execute()
(2) [PluginRegister].RegisterProperty(); // _Define(), _DefineLayout(), _PPGEvent()
(3) [PluginRegister].RegisterMenu(); // _Menu_Init()

◆ソース(229行目は無視してください)
// UpdatedOpPlugin
// Initial code generated by XSI SDK Wizard
// Executed Tue Jan 3 21:53:38 UTC+0900 2012 by xxxx
// 
// Tip: You need to compile the generated code before you can load the plug-in.
// After you compile the plug-in, you can load it by clicking Update All in the Plugin Manager.
#include 
#include    // Factory
#include 
#include 
#include 
#include 
#include 
#include 
#include   // CustomProperty
#include    // Selection
#include    // Parameter
#include    // PPGLayout
#include  // PPGEventContext
using namespace XSI;

static Application app;
static Factory factory = app.GetFactory();
static CustomProperty prop(factory.CreateObject(L"CustomProperty"));

XSIPLUGINCALLBACK CStatus XSILoadPlugin( PluginRegistrar& in_reg )
{
 in_reg.PutAuthor(L"xxxx");
 in_reg.PutName(L"UpdatedOpPlugin");
 in_reg.PutEmail(L"");
 in_reg.PutURL(L"");
 in_reg.PutVersion(1,0);
 in_reg.RegisterCommand(L"UpdatedOp",L"UpdatedOp");
 in_reg.RegisterProperty(L"UpdatedOpProp");
 in_reg.RegisterMenu(siMenuTbGetPropertyID,L"UpdatedOp_Menu",false,false);
 //RegistrationInsertionPoint - do not remove this line

 return CStatus::OK;
}

XSIPLUGINCALLBACK CStatus XSIUnloadPlugin( const PluginRegistrar& in_reg )
{
 CString strPluginName;
 strPluginName = in_reg.GetName();
 Application().LogMessage(strPluginName + L" has been unloaded.",siVerboseMsg);
 return CStatus::OK;
}

XSIPLUGINCALLBACK CStatus UpdatedOp_Init( CRef& in_ctxt )
{
 app.LogMessage(L"on called for UpdatedOp_Init");
 Context ctxt( in_ctxt );
 Command oCmd;
 oCmd = ctxt.GetSource();
 oCmd.PutDescription(L"");
 oCmd.EnableReturnValue(true);

 return CStatus::OK;
}

XSIPLUGINCALLBACK CStatus UpdatedOpProp_Define(const CRef &in_ctxt) {
 Context ctxt( in_ctxt );
 //CustomProperty prop;
 Parameter oParam;
 prop = ctxt.GetSource();
 prop.AddParameter(L"numCount", CValue::siInt2, siPersistable | siAnimatable, L"", L"", 0, oParam);
 return CStatus::OK;
}

XSIPLUGINCALLBACK CStatus UpdatedOpProp_DefineLayout(const CRef &in_ctxt) {
 Context ctxt( in_ctxt );
 PPGLayout oLayout;
 PPGItem item;

 oLayout = ctxt.GetSource();
 oLayout.Clear();
 oLayout.AddGroup(L"General");
 item = oLayout.AddItem(L"numCount", L"Count", siControlNumber);
 oLayout.EndGroup();

 oLayout.AddButton(L"btn_OK", L"Done");
 return CStatus::OK;
}

XSIPLUGINCALLBACK CStatus UpdatedOp_Execute( CRef& in_ctxt )
{
 Context ctxt( in_ctxt );
 CValueArray args = ctxt.GetAttribute(L"Arguments");

 Application().LogMessage(L"UpdatedOp_Execute called",siVerboseMsg);
 // 
 // TODO: Put your command implementation here.
 prop.PutName(L"Update Op");
 Selection oSel = app.GetSelection().GetItem(0);
 app.LogMessage(oSel.GetAsText(), XSI::siInfoMsg);

 Parameter oParam;
 Parameter txtParam;
 Parameter btnParam;
 prop.AddParameter(L"Instance", CValue::siString, siReadOnly | siPersistable, L"", L"", L"Instance Here", txtParam);
 prop.AddParameter(L"Count", CValue::siInt2, siAnimatable | siPersistable | siKeyable, L"", L"", 0, oParam);
 prop.AddParameter(L"Position", CValue::siInt1, siPersistable, L"", L"", 0, btnParam);
 
 PPGLayout oLayout = prop.GetPPGLayout();
 oLayout.Clear();
 oLayout.AddGroup(L"Update Content");
 oLayout.AddItem(L"Instance", L"Target");
 oLayout.AddItem(L"Count", 0);
 oLayout.EndGroup();

 CValueArray radio(6);
 radio[0] = L"Left"; radio[1] = 0;
 radio[2] = L"Center"; radio[3] = 1;
 radio[4] = L"Right"; radio[5] = 2;
 oLayout.AddGroup(L"Position");
 oLayout.AddEnumControl(L"Position", radio, L"Change", siControlRadio);
 oLayout.EndGroup();

 oLayout.AddButton(L"done", L"");

 CValueArray wParam(5);
 wParam[0] = prop;
 wParam[1] = L"Update Op";
 wParam[2] = (LONG)siModal;
 wParam[3] = false;
 CValue ret;
 app.ExecuteCommand(L"InspectObj", wParam, ret);

 // 
 // Return a value by setting this attribute:
 ctxt.PutAttribute( L"ReturnValue", true );

 // Return CStatus::Fail if you want to raise a script error
 return CStatus::OK;
}


XSIPLUGINCALLBACK CStatus UpdatedOpProp_PPGEvent(const CRef &in_ctxt) {
 PPGEventContext ctxt(in_ctxt);
 PPGEventContext::PPGEvent eventID = ctxt.GetEventID();

 switch(eventID) {
 case (PPGEventContext::siOnInit):
  {
   //CustomProperty prop = ctxt.GetSource();
   app.LogMessage(L"OnInit called for " + prop.GetFullName());
  }
  break;
 case (PPGEventContext::siButtonClicked):
  {
   CValue btnPressed = ctxt.GetAttribute(L"Button");
   app.LogMessage(L"Button Pressed: " + btnPressed.GetAsText());
  }
  break;
 case (PPGEventContext::siTabChange):
  break;
 case (PPGEventContext::siParameterChange):
  {
   Parameter param = ctxt.GetSource();
   //CustomProperty prop = param.GetParent();
   CString name = param.GetScriptName();
   app.LogMessage(L"Parameter Changed: " + name);
  }
  break;
 case (PPGEventContext::siOnClosed):
  {
   //CustomProperty prop = ctxt.GetSource();
   app.LogMessage(L"OnClosed called for " + prop.GetFullName());
  }
  break;
 }


 return CStatus::OK;
}

XSIPLUGINCALLBACK CStatus UpdatedOp_Menu_Init( CRef& in_ctxt )
{
 Context ctxt( in_ctxt );
 Menu oMenu;
 oMenu = ctxt.GetSource();
 MenuItem oNewItem;
 //oMenu.AddCommandItem(L"UpdatedOp",L"UpdatedOp",oNewItem);
 CStatus st = oMenu.AddCallbackItem(L"UpdatedOp Sample", L"OnUpdatedOpPropClicked", oNewItem);
 return st;
}



XSIPLUGINCALLBACK CStatus OnUpdatedOpPropClicked(const CRef &) {
 // We use the AddProp command rather than the C++ API
 // because it logs in the script history and it
 // automatically takes care of different selection possibilities.
 
 Application app;
 //CustomProperty prop;

 CValueArray addpropArgs(5) ;
 addpropArgs[0] = L"UpdatedOpProp"; // Type of Property
 addpropArgs[3] = L"UpdatedOpProp"; // Name for the Property

 // At this point you might want to validate what objects
 // are selected to make sure they make sense for your
 // property

 if ( app.GetSelection().GetCount() == 0 )
 {  
  // No selection so create the object at the scene root
  addpropArgs[1] = L"Scene_Root";
 }

 CValue retVal ;
 CStatus st = app.ExecuteCommand( L"SIAddProp", addpropArgs, retVal ) ;

 if ( st.Succeeded() )
 {
  // Inspect newly created Property or Properties
  //(there could be more than one if the selection
  // contains multiple items)
  CValueArray resultArray( (CValueArray&)addpropArgs[4] );
  CValueArray inspectobjArgs(5) ;
  inspectobjArgs[0] = resultArray[0] ;
        
  app.ExecuteCommand( L"InspectObj", inspectobjArgs, retVal ) ;
 }

 return st ;
}

[XSI] Add null an object to parent from selected an object. [JScript]

選択されたオブジェクトの親にnullオブジェクトを追加します。
nullオブジェクトは選択されたオブジェクトのローカル座標と同じ座標へ配置されます。

try {
 var oRoot = ActiveProject.ActiveScene.Root;
 var oObj = Selection(0);
 var oNull = oRoot.AddNull(oObj.Name + "_null");
 var oObjLcl = oObj.Kinematics.Local;
 var x = oObjLcl.Parameters("posx").Value;
 var y = oObjLcl.Parameters("posy").Value;
 var z = oObjLcl.Parameters("posz").Value;
 var oLocalTrans = XSIMath.CreateTransform();
 oLocalTrans.SetTranslationFromValues(x, y, z);
 oNull.Kinematics.Local.Transform = oLocalTrans;
 CopyPaste(oObj, null, oNull, 1);
 SelectObj(oNull, null, null);
 ToggleVisibility(null, null, null);
 SelectObj(oObj, null, null);
} catch(err) {
 logmessage(err.message);
}