スクリプトを入れるフォルダ 拡張子は「CSX」
赤枠クリックすれば、エクスプローラーが開きます。
作ったスクリプトを「xxx.csx」で保存します。
スクリプトを書いたら、リロードしないとだめ
スクリプトのフォルダーに書き込んだら、RootPro を一度閉じ再起動しないとスクリプト使えるようにならない。
messageboxの表示
// RootPro CAD 以外のアセンブリを参照する場合は「#r "アセンブリ名"」と記述します。 #r "System.Windows.Forms" using System.Windows.Forms; MessageBox.Show("SAM");
System.Windows.Forms が必要, その時「#r」がいる
今描いた図の「コマンド名」(ユニーク)を取得するには
#r "System.Windows.Forms" using System.Windows.Forms; // 実行したコマンドを取得する var currentCommand = Application.CommandManager.CurrentCommand; //MessageBox.Show(currentCommand); エラー 文字列でないので //MessageBox.Show(currentCommand.Name); エラー Nameはない MessageBox.Show(currentCommand.UniqueName);
「currentCommand.UniqueName」でコマンドの名前・文字列を取得
大文字・小文字間違えたら動きません
ステータスバーに文字を表示
StatusBar.SetInformation("Sam 日本へ戻ろう", 6000);
””文字列”, 秒数
四角形コマンドを実行する=CommandManager
//Command.Execute("RootPro.Shape.Rectangle"); これは違う //(1,9): error CS1501: No overload for method 'Execute' takes 1 arguments CommandManager.ExecuteCommand("RootPro.Shape.Rectangle");
四角形の入力画面になります。
図形を全選択する
ActiveDocument.SelectionManager.SelectAll();
エラー:いろいろ
(2,1) は行数、左から何語目か 表しているようです。
図面の名前を取得します
#r "System.Windows.Forms" System.Windows.Forms.MessageBox.Show(ActiveDocument.Name);
#r “System.Windows.Forms” がないと「MessageBox」使えない。
エラー:One or more errors occured. 何で?
var point=new Point2d(160,100); for(int i=0;i<3;i++){ ActiveDocument.CurrentDrawing.Shapes.AddCircle(point,i*10); }
いろいろ悩みましたが、理由がわかりました。i=0が悪さしています。
大きさ0の図形は無いということです。i=1にすればOKです。
i=1 ;1<5
コメント