565 lines
19 KiB
C#
565 lines
19 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using System.IO;
|
|
using System.Collections;
|
|
using System.Text.RegularExpressions;
|
|
using KDCS.Utils;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.DB.Plumbing;
|
|
|
|
|
|
namespace KMBIM
|
|
{
|
|
|
|
public partial class Form_Steam : System.Windows.Forms.Form
|
|
{
|
|
public List<HeValue> m_ArrValue = new List<HeValue>();
|
|
public List<HdValue> m_ArrHdValue = new List<HdValue>();
|
|
public double[] dlst; // 관경의 목록을 저장
|
|
public int listboxcnt = -1;
|
|
public double mainHeaderDia;
|
|
public List<string> m_ArrDia = new List<string>();
|
|
string m_strpath = string.Empty;
|
|
public int m_nMode = -1;
|
|
public double m_HeadHgt = 0;
|
|
public string m_Globepath = null, m_Safepath = null;
|
|
public double m_ValHgt = 0;
|
|
public List<string> HeaderSysTypeLst = new List<string>();
|
|
public PipingSystemType HeaderSysType = null;
|
|
public List<PipingSystemType> SelectedSysTypeNameLst = new List<PipingSystemType>();
|
|
public Document doc = null;
|
|
|
|
//메인 헤더 높이
|
|
public double HeadHeight
|
|
{
|
|
get { return m_HeadHgt; }
|
|
set { m_HeadHgt = value; }
|
|
}
|
|
//글로브 밸브 경로
|
|
public string GlobevalvePath
|
|
{
|
|
get { return m_Globepath; }
|
|
set { m_Globepath = value; }
|
|
}
|
|
//안전 밸브 경로
|
|
public string SafevalvePath
|
|
{
|
|
get { return m_Safepath; }
|
|
set { m_Safepath = value; }
|
|
}
|
|
|
|
public Form_Steam()
|
|
{
|
|
InitializeComponent();
|
|
//string Tmp = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
//
|
|
//m_strpath = Tmp.Replace("\\KMBIM2019.dll", "");
|
|
m_strpath = Util.GetKMBIMLibraryFolder("Libraries\\Header");
|
|
}
|
|
private void init()
|
|
{
|
|
string s, sql;
|
|
//m_strPath.Format(_T("%s"),m_pDraw->m_strPath);
|
|
|
|
//////////yong//////////////////
|
|
///////////////0311파일 존재 유무 체크
|
|
//if(!IsExistFile(m_strPath)){
|
|
// AfxMessageBox(_T("파일이 존재 하지 않습니다"));
|
|
// SelData();
|
|
// return;
|
|
//}
|
|
///////////////////////////
|
|
|
|
|
|
m_ArrValue.Clear();
|
|
m_ArrHdValue.Clear();
|
|
|
|
GetDia("STEAM.csv");
|
|
|
|
for (int i = 0; i < m_ArrDia.Count; i++)
|
|
{
|
|
s = m_ArrDia[i];
|
|
s = s.Replace("D", "");
|
|
cmb_pipedia.Items.Add(s);
|
|
}
|
|
s = m_ArrDia[0];
|
|
s = s.Replace("D", "");
|
|
|
|
cmb_pipedia.Text = s;
|
|
////////
|
|
|
|
//헤더 지름별 사양...입력 부분....
|
|
|
|
GetHDValue("HDDIA.csv");
|
|
|
|
// m_hd = m_HdFirst;//"200";
|
|
//if (m_hd = _T("")) m_hd = _T("200");
|
|
|
|
|
|
/* buttonDisable();
|
|
UpdateData(FALSE);
|
|
m_PipeDia.SetCurSel(0);*/
|
|
}
|
|
private void GetDia(string filename)
|
|
{
|
|
|
|
try
|
|
{
|
|
long id;
|
|
FileStream fs = null;
|
|
string csFileName, csRecord;
|
|
string strPath;
|
|
bool res = false;
|
|
|
|
//m_strpath = m_strpath.Replace("\\KMBIM2019.dll", "");
|
|
//csFileName = m_strpath + "\\data\\Header\\" + filename;
|
|
csFileName = Path.Combine(Util.GetKMBIMLibraryFolder("Libraries\\Header\\"), filename);
|
|
FileInfo _finfo = new FileInfo(csFileName);
|
|
|
|
bool sw = _finfo.Exists;
|
|
|
|
|
|
if (sw == false)
|
|
{ // 파일 존재 유무 조사
|
|
string strMsg;
|
|
strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName);
|
|
MessageBox.Show(strMsg);
|
|
return;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read);
|
|
StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
|
|
|
|
if (fs == null)
|
|
{
|
|
string strMsg;
|
|
strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName);
|
|
MessageBox.Show(strMsg);
|
|
return;
|
|
}
|
|
int ic = 0;
|
|
HeValue val;
|
|
double zero, one;
|
|
zero = 0.0f;
|
|
|
|
|
|
ArrayList csaFieldNames = new ArrayList();
|
|
int iInside = 0, iPipeName = 0;
|
|
while (sr.Peek() > -1)
|
|
{
|
|
//ArxUtils::SeparateString(csRecord, csaFields, _T(",\t\n"));
|
|
string str = sr.ReadLine();
|
|
string[] arr = Regex.Split(str, ",\t");
|
|
|
|
if (arr.Length <= 0) break; // 이 문 없으면 죽는다.
|
|
if (ic == 0)
|
|
{ // 필드레코드
|
|
ic++;
|
|
for (int j = 0; j < arr.Length; j++)
|
|
{
|
|
csaFieldNames.Add(arr[j]);
|
|
|
|
}
|
|
continue;
|
|
}
|
|
ic++;
|
|
|
|
m_ArrDia.Add(arr[0]);
|
|
for (int j = 1; j < arr.Length; j++)
|
|
{
|
|
val.val = arr[j].ToString();
|
|
one = Convert.ToDouble(val.val);
|
|
if ((val.val != string.Empty) && ((one > 0.0f)))
|
|
{
|
|
val.he = csaFieldNames[j].ToString();
|
|
val.we = arr[0].ToString();
|
|
val.he = val.he.Replace("D", "");
|
|
val.we = val.we.Replace("D", "");
|
|
|
|
m_ArrValue.Add(val);
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}//end-while
|
|
fs.Close();
|
|
|
|
}
|
|
catch (FieldAccessException ex)
|
|
{
|
|
//pEx->ReportError();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void GetHDValue(string lpszCSV)
|
|
{
|
|
// Clear the contents of the Array
|
|
m_ArrDia.Clear();
|
|
list_Sup.Items.Clear();
|
|
|
|
try
|
|
{
|
|
long id;
|
|
FileStream fs = null;
|
|
string csFileName, csRecord;
|
|
string strPath;
|
|
bool res = false;
|
|
|
|
//m_strpath = m_strpath.Replace("\\KMBIM2019.dll", "");
|
|
// MessageBox.Show(m_strpath);
|
|
csFileName = Path.Combine(Util.GetKMBIMLibraryFolder("Libraries\\Header\\"), lpszCSV);
|
|
//MessageBox.Show(csFileName);
|
|
FileInfo _finfo = new FileInfo(csFileName);
|
|
|
|
bool sw = _finfo.Exists;
|
|
|
|
|
|
if (sw == false)
|
|
{ // 파일 존재 유무 조사
|
|
string strMsg;
|
|
strMsg = System.String.Format("파일{0}을 찾을 수 없습니다.", csFileName);
|
|
MessageBox.Show(strMsg);
|
|
return;
|
|
}
|
|
fs = new FileStream(csFileName, FileMode.Open, FileAccess.Read);
|
|
StreamReader sr = new StreamReader(fs, System.Text.Encoding.Default);
|
|
|
|
if (fs == null)
|
|
{
|
|
string strMsg;
|
|
strMsg = System.String.Format("파일({0})을 열 수 없습니다.", csFileName);
|
|
MessageBox.Show(strMsg);
|
|
return;
|
|
}
|
|
int ic = 0;
|
|
HdValue val;
|
|
double zero, one;
|
|
zero = 0.0f;
|
|
|
|
ArrayList csaFieldNames = new ArrayList();
|
|
int iInside = 0, iPipeName = 0;
|
|
while (sr.Peek() > -1)
|
|
{
|
|
//ArxUtils::SeparateString(csRecord, csaFields, _T(",\t\n"));
|
|
string str = sr.ReadLine();
|
|
string[] arr = Regex.Split(str, ",\t");
|
|
|
|
if (arr.Length <= 0) break; // 이 문 없으면 죽는다.
|
|
if (ic == 0)
|
|
{ // 필드레코드
|
|
ic++;
|
|
for (int j = 0; j < arr.Length; j++)
|
|
{
|
|
csaFieldNames.Add(arr[j]);
|
|
|
|
}
|
|
continue;
|
|
}
|
|
ic++;
|
|
|
|
string sHDDIA, sBLTSIZE, sBLTBORE, sBLTNO, sFLGID, sBLTCENDST, sFLGOD;
|
|
sHDDIA = arr[0];
|
|
sBLTSIZE = arr[1];
|
|
sBLTBORE = arr[2];
|
|
sBLTNO = arr[3];
|
|
sFLGID = arr[4];
|
|
sBLTCENDST = arr[5];
|
|
sFLGOD = arr[6];
|
|
|
|
if ((sHDDIA != string.Empty) && (sBLTSIZE != string.Empty) && (sBLTBORE != string.Empty) && (sBLTNO != string.Empty) &&
|
|
(sFLGID != string.Empty) && (sBLTCENDST != string.Empty) && (sFLGOD != string.Empty))
|
|
{
|
|
//int n=sHDDIA.get.GetLength();
|
|
cmb_headdia.Items.Add(sHDDIA);
|
|
val.HDDIA = sHDDIA;
|
|
val.FLGOD = sFLGOD;
|
|
val.FLGID = sFLGID;
|
|
sBLTSIZE = sBLTSIZE.Replace("M", "");
|
|
val.BLTSIZE = sBLTSIZE;
|
|
val.BLTNO = sBLTNO;
|
|
val.BLTCENDST = sBLTCENDST;
|
|
val.BLTBORE = sBLTBORE;
|
|
|
|
m_ArrHdValue.Add(val);
|
|
}
|
|
}//end-while
|
|
cmb_headdia.SelectedIndex = 0;
|
|
fs.Close();
|
|
}
|
|
catch (FieldAccessException ex)
|
|
{
|
|
}
|
|
}
|
|
private void Form_Steam_Load(object sender, EventArgs e)
|
|
{
|
|
this.KeyPreview = true;
|
|
init();
|
|
string versionNumber = doc.Application.VersionNumber.ToString();
|
|
//txt_headhgt.Text = "1000";
|
|
|
|
//패밀리 기본값.
|
|
//string Tmp = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
//Tmp = Tmp.Replace("\\KMBIM2019.dll", "");
|
|
string Tmp = Util.GetKMBIMLibraryFolder("Libraries\\Header");
|
|
m_Globepath = Tmp + "\\family\\"+versionNumber+"\\PV_Globe Valve - 40-200mm-Flanged.rfa";
|
|
m_Safepath = Tmp + "\\family\\"+versionNumber+"\\YSF-3(25-50).rfa";
|
|
txt_path1.Text = Path.GetFileName(m_Globepath);
|
|
txt_path2.Text = Path.GetFileName(m_Safepath);
|
|
|
|
//메인 헤더 높이
|
|
if (Reg.getReg("steam_headHgt") == "")
|
|
{
|
|
m_HeadHgt = Math.Round(m_HeadHgt, 3);
|
|
txt_headhgt.Text = m_HeadHgt.ToString();
|
|
Reg.setReg("steam_headHgt", m_HeadHgt.ToString());
|
|
}
|
|
else
|
|
{
|
|
string str_headHgt = Reg.getReg("steam_headHgt");
|
|
txt_headhgt.Text = str_headHgt;
|
|
}
|
|
|
|
//조작밸브 높이
|
|
if (Reg.getReg("steam_valveHgt") == "")
|
|
{
|
|
m_ValHgt = Math.Round(m_ValHgt, 3);
|
|
txt_valveHgt.Text = m_ValHgt.ToString();
|
|
Reg.setReg("steam_valveHgt", m_ValHgt.ToString());
|
|
}
|
|
else
|
|
{
|
|
string str_ValHgt = Reg.getReg("steam_valveHgt");
|
|
txt_valveHgt.Text = str_ValHgt;
|
|
}
|
|
|
|
//코일 시스템 유형
|
|
foreach (string str in HeaderSysTypeLst)
|
|
{
|
|
combo_SteamSysType.Items.Add(str);
|
|
}
|
|
//코일 시스템유형 없으면 기본값 지정 X
|
|
if (combo_SteamSysType.Items.Count != 0)
|
|
{
|
|
if (Reg.getReg("combo_SteamSysType_Idx") == "")
|
|
{
|
|
combo_SteamSysType.SelectedIndex = 0;
|
|
Reg.setReg("combo_SteamSysType_Idx", "0");
|
|
}
|
|
else
|
|
{
|
|
string Str_combo_SupSysType = Reg.getReg("combo_SteamSysType_Idx");
|
|
//만약 저장된 레지스트리 인덱스값이 없으면 디폴트값으로
|
|
if (combo_SteamSysType.Items.Count - 1 >= Convert.ToInt32(Str_combo_SupSysType))
|
|
{
|
|
combo_SteamSysType.SelectedIndex = Convert.ToInt32(Str_combo_SupSysType);
|
|
}
|
|
else
|
|
{
|
|
combo_SteamSysType.SelectedIndex = 0;
|
|
Reg.setReg("combo_SteamSysType_Idx", "0");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void btn_add_Click(object sender, EventArgs e)
|
|
{
|
|
if (cmb_pipedia.Text != "")
|
|
list_Sup.Items.Add(cmb_pipedia.Text);
|
|
|
|
SelectedSysTypeNameLst.Add(HeaderSysType);
|
|
}
|
|
|
|
private void btn_itemedit_Click(object sender, EventArgs e)
|
|
{
|
|
int index = list_Sup.SelectedIndex;
|
|
|
|
list_Sup.Items[index] = cmb_pipedia.Text;
|
|
}
|
|
|
|
private void btn_itemadd_Click(object sender, EventArgs e)
|
|
{
|
|
if (cmb_pipedia.Text != "")
|
|
list_Sup.Items.Add(cmb_pipedia.Text);
|
|
|
|
SelectedSysTypeNameLst.Add(HeaderSysType);
|
|
}
|
|
|
|
private void btn_itemdel_Click(object sender, EventArgs e)
|
|
{
|
|
int index = list_Sup.SelectedIndex;
|
|
list_Sup.Items.RemoveAt(index);
|
|
|
|
SelectedSysTypeNameLst.RemoveAt(index);
|
|
}
|
|
|
|
private void button5_Click(object sender, EventArgs e)
|
|
{
|
|
int count = list_Sup.Items.Count;
|
|
listboxcnt = count;
|
|
dlst = new double[count];
|
|
if (count > 0)
|
|
{
|
|
for (int i = 0; i < count; i++)
|
|
{
|
|
object Tmp = list_Sup.Items[i];
|
|
dlst[i] = Convert.ToDouble(Tmp.ToString());
|
|
}
|
|
|
|
}
|
|
mainHeaderDia = Convert.ToDouble(cmb_headdia.Text);
|
|
}
|
|
|
|
private void Form_Steam_KeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
if (e.KeyCode == Keys.Escape)
|
|
{
|
|
//this.Close();
|
|
this.DialogResult = DialogResult.Cancel;
|
|
}
|
|
else if (e.KeyCode == Keys.Enter)
|
|
{
|
|
this.DialogResult = DialogResult.OK;
|
|
}
|
|
}
|
|
|
|
//메인 헤더 높이
|
|
private void txt_headhgt_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (txt_headhgt.Text == "") return;
|
|
if (txt_headhgt.Text != "-")
|
|
{
|
|
m_HeadHgt = double.Parse(txt_headhgt.Text);
|
|
Reg.setReg("steam_headHgt", txt_headhgt.Text);
|
|
}
|
|
|
|
}
|
|
|
|
//조작 밸브 높이
|
|
private void txt_valveHgt_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (txt_valveHgt.Text == "") return;
|
|
if (txt_valveHgt.Text != "-")
|
|
{
|
|
m_ValHgt = double.Parse(txt_valveHgt.Text);
|
|
Reg.setReg("steam_valveHgt", txt_valveHgt.Text);
|
|
}
|
|
|
|
}
|
|
|
|
private void txt_headhgt_KeyPress(object sender, KeyPressEventArgs e)
|
|
{
|
|
int keyCode = (int)e.KeyChar;
|
|
if ((keyCode < 48 || keyCode > 57) && keyCode != 8 && keyCode != 46 && keyCode != 45)
|
|
e.Handled = true;
|
|
|
|
if (keyCode == 46)
|
|
{
|
|
if (string.IsNullOrEmpty(txt_headhgt.Text) || txt_headhgt.Text.Contains('.') == true)
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
//글로브 밸브 대화상자 버튼
|
|
private void btn_path1_Click(object sender, EventArgs e)
|
|
{
|
|
string versionNumber = doc.Application.VersionNumber.ToString();
|
|
|
|
m_Globepath = GetFamilyPath();
|
|
|
|
if (m_Globepath != null)
|
|
txt_path1.Text = Path.GetFileName(m_Globepath);
|
|
else
|
|
{
|
|
//string Tmp = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
//Tmp = Tmp.Replace("\\KMBIM2019.dll", "");
|
|
string Tmp = Util.GetKMBIMLibraryFolder("Libraries\\Header");
|
|
m_Globepath = Tmp + "\\family\\" + versionNumber + "\\PV_Globe Valve - 40-200mm-Flanged.rfa";
|
|
txt_path1.Text = Path.GetFileName(m_Globepath);
|
|
}
|
|
}
|
|
|
|
//안전 밸브 대화상자 버튼
|
|
private void btn_path2_Click(object sender, EventArgs e)
|
|
{
|
|
string versionNumber = doc.Application.VersionNumber.ToString();
|
|
|
|
m_Safepath = GetFamilyPath();
|
|
|
|
if (m_Safepath != null)
|
|
txt_path2.Text = Path.GetFileName(m_Safepath);
|
|
else
|
|
{
|
|
//string Tmp = System.Reflection.Assembly.GetExecutingAssembly().Location;
|
|
//Tmp = Tmp.Replace("\\KMBIM2019.dll", "");
|
|
string Tmp = Util.GetKMBIMLibraryFolder("Libraries\\Header");
|
|
m_Safepath = Tmp + "\\family\\"+versionNumber+"\\YSF-3(25-50).rfa";
|
|
txt_path2.Text = Path.GetFileName(m_Safepath);
|
|
}
|
|
}
|
|
|
|
private void combo_SteamSysType_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
ICollection<Element> pipeSysTypes = new FilteredElementCollector(doc).OfClass(typeof(PipingSystemType)).ToElements();
|
|
foreach (Element elem in pipeSysTypes)
|
|
{
|
|
if (elem is PipingSystemType)
|
|
{
|
|
PipingSystemType pipeSysType = elem as PipingSystemType;
|
|
|
|
//파이프 유형이름이 다르면 loop
|
|
if (pipeSysType.Name != combo_SteamSysType.SelectedItem.ToString()) continue;
|
|
|
|
//작도에 쓰일 pipetype Element
|
|
HeaderSysType = pipeSysType;
|
|
if (HeaderSysType != null)
|
|
break;
|
|
}
|
|
}
|
|
|
|
Reg.setReg("combo_SteamSysType_Idx", combo_SteamSysType.SelectedIndex.ToString());
|
|
}
|
|
|
|
|
|
|
|
public string GetFamilyPath()
|
|
{
|
|
string versionNumber = doc.Application.VersionNumber.ToString();
|
|
|
|
string path = null;
|
|
OpenFileDialog FileDlg = new OpenFileDialog();
|
|
FileDlg.InitialDirectory = "C:\\ProgramData\\DCS.CO.KR\\KMBIM\\Libraries\\Header\family\\"+versionNumber+"\\";
|
|
FileDlg.Filter = "rfa Files(*.rfa)|*.rfa|All Files(*.*)|*.*";
|
|
FileDlg.FilterIndex = 2;
|
|
FileDlg.RestoreDirectory = true;
|
|
|
|
if (FileDlg.ShowDialog() == DialogResult.OK)
|
|
{
|
|
if (FileDlg.FileName != null)
|
|
{
|
|
//확장자가 rfa가 아닐 경우
|
|
if (Path.GetExtension(FileDlg.FileName) != ".rfa")
|
|
{
|
|
MessageBox.Show("rfa 파일이 아닙니다.");
|
|
}
|
|
else
|
|
{
|
|
path = FileDlg.FileName;
|
|
}
|
|
}
|
|
}
|
|
return path;
|
|
}
|
|
}
|
|
}
|