PowerMillのプロジェクトの情報部分をエクスポートする、地味なヤツです。
エクスポートするのは、こちらの[顧客名] ['パーツ名] [注文番号] の3つだけ。
PMill2017までは、この辺が見つけ難かったのですが
リボンインターフェイスに変わってから、これだけは見やすくなりましたね。
ここをセットアップシートに書き出すので、毎回入力するのが面倒なんです。
//pm2018 macro //ProjInfoExp.mac ver0.0.1 //PMillプロジェクト情報部のエクスポート //-------------------------------------------------------------------- //ver0.0.1-完成 //-------------------------------------------------------------------- function main() { //コメント収集 string cust = project.Customer string pname = project.PartName string odrnum = project.OrderNumber //確認 string msg = '' $msg = $msg + '顧客名 : ' + $cust + crlf $msg = $msg + 'パーツ名 : ' + $pname + crlf $msg = $msg + '注文番号 : ' + $odrnum + crlf $msg = $msg + 'をエクスポートしますか?' bool yn = 0 $yn = QUERY $msg if not $yn { macro abort } //出力先 string path = '' call SelFile($path) //拡張子チェック int extpos = position($path, '.') if extpos < 0 { $path = $path + '.PmCmt' } else { $path = substring($path, 0, $extpos) + '.PmCmt' } //重複チェック if file_exists($path) { $msg = '上書き保存しますか?' $yn = QUERY $msg if not $yn { macro abort } } //書き込み string list cmts = ($cust, $pname, $odrnum) call WriteFile($path, join($cmts, ',')) message info 'Done' } /////////////// //ファイルの選択 function SelFile(output string out) { string title = 'PMillプロジェクトコメント' string filter = 'PMillプロジェクトコメント(.PmCmt)|*.PmCmt|' string defpath = '' call GetParentDir($defpath) $out = fileselect $title $filter $defpath if length($out) < 1 { macro abort } } //プロジェクトの一個上のパス取得 何か方法あるのかな? function GetParentDir(output string out) { string s = project_pathname(0) int p1 = -1 int p2 = 0 while ($p2 > -1) { $p1 = position($s, '/', $p2) if $p1 < 0 { break } $p2 = $p1 + 1 } $out= substring($s, 0, $p2 -1) } //ファイル書き込み function WriteFile(string path, string txt) { file open $path for write as f file write $txt to f file close f }
ほぼ無チェック状態ですが、ここ最近これがかなり欲しかったので
動くものを作成する事が優先です。
こんな感じに書き出すだけです。
インポート用のマクロは、まだ作っていないので・・・