GH C#Component tips_入力したBooleanToggleの初期値を設定する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void RunScript(bool x, ref object A) | |
{ | |
} | |
// <Custom additional code> | |
GH_ComponentParamServer ghCPS; | |
public override void AfterRunScript() | |
{ | |
ghCPS = this.Component.Params; | |
for(int i = 0; i < ghCPS.Input.Count; i++) | |
{ | |
if(ghCPS.Input[i].SourceCount != 0) | |
{ | |
switch(i) | |
{ | |
case 0: | |
SetBooleanToggle(i, "Super Riser", false); | |
break; | |
} | |
} | |
} | |
} | |
//AfterRunScript内でBooleanToggleを操作するためのメソッド | |
public void SetBooleanToggle( | |
int rowNumber, string name, bool defaultParam) | |
{ | |
//サンプルデータとして入力が想定されるコンポーネントを | |
//BooleanToggleと決めつけた書き方(他のタイプだとエラーになる) | |
ghCPS = this.Component.Params; | |
var boolToggle = (Grasshopper.Kernel.Special.GH_BooleanToggle) | |
ghCPS.Input[rowNumber].Sources[0]; | |
//BooleanToggleがデフォルトの名前を持っている場合に書き換えを実行する | |
//ユーザーが変更できるNickNameを判定には使わない | |
if(boolToggle.Name != name) | |
{ | |
boolToggle.Name = name; | |
boolToggle.NickName = name; | |
boolToggle.ExpireSolution(true); | |
} | |
} | |
// </Custom additional code> | |
} |
Author
saitohiroaki1122
commented
Jan 17, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment