214 lines
6.4 KiB
C#
214 lines
6.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using Autodesk.Revit.UI;
|
|
using Autodesk.Revit.UI.Selection;
|
|
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.Creation;
|
|
using Autodesk.Revit.DB.Structure;
|
|
using System.Drawing.Imaging;
|
|
using System.Windows;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using KDCS.Utils;
|
|
|
|
|
|
namespace KMBIM
|
|
{
|
|
public partial class FormExtend2Level : System.Windows.Forms.Form
|
|
{
|
|
public int RTcode;
|
|
public Autodesk.Revit.UI.ExternalCommandData revit;
|
|
private System.Windows.Forms.Label normalLabel;
|
|
private System.Windows.Forms.Label originLabel;
|
|
|
|
private System.Windows.Forms.GroupBox creationGroupBox;
|
|
private System.Windows.Forms.Button okButton;
|
|
private System.Windows.Forms.Button cancelButton;
|
|
|
|
Autodesk.Revit.Creation.Application creApp;
|
|
Autodesk.Revit.Creation.Document creDoc;
|
|
|
|
public Level level;
|
|
List<Level> levelList;
|
|
|
|
public FormExtend2Level()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public int m_Extend;
|
|
public string m_LvlExtend, m_LvlCurrent;
|
|
private double m_offset;
|
|
|
|
public double Offset
|
|
{
|
|
get { return m_offset; }
|
|
set { m_offset = value; }
|
|
}
|
|
|
|
|
|
private List<Element> getLevel()
|
|
{
|
|
this.Hide();
|
|
UIApplication uiapp = revit.Application;
|
|
UIDocument uidoc = uiapp.ActiveUIDocument;
|
|
Autodesk.Revit.DB.Document doc = uidoc.Document;
|
|
|
|
Autodesk.Revit.DB.View view = doc.ActiveView;
|
|
ElementId levelId = null;
|
|
List<Element> ElemList = new List<Element>();
|
|
|
|
Parameter level = view.LookupParameter("Associated Level");
|
|
|
|
FilteredElementCollector lvlCollector = new FilteredElementCollector(doc);
|
|
ICollection<Element> lvlCollection = lvlCollector.OfClass(typeof(Level)).ToElements();
|
|
|
|
foreach(Element l in lvlCollection)
|
|
{
|
|
Level lvl = l as Level;
|
|
ElemList.Add(lvl);
|
|
//MessageBox.Show("" + lvl.Name);
|
|
}
|
|
return ElemList;
|
|
}
|
|
|
|
|
|
private void FormExtend2Level_Load(object sender, EventArgs e)
|
|
{
|
|
this.KeyPreview = true;
|
|
UIApplication uiapp = revit.Application;
|
|
UIDocument uidoc = uiapp.ActiveUIDocument;
|
|
Autodesk.Revit.DB.Document doc = uidoc.Document;
|
|
Level level = doc.ActiveView.GenLevel;
|
|
List<Element> levelList = null;
|
|
|
|
if(level != null)
|
|
{
|
|
txt_CurrentLevel.Text = level.Name;
|
|
m_LvlCurrent = level.Name;
|
|
}
|
|
else
|
|
{
|
|
txt_CurrentLevel.Text = "Unknown";
|
|
m_LvlCurrent = "Unknown";
|
|
}
|
|
|
|
|
|
//레벨 가져오기
|
|
levelList = getLevel();
|
|
//레벨 리스트 목록 콤보박스 추가
|
|
foreach (Element l in levelList)
|
|
{
|
|
Level lvl = l as Level;
|
|
combo_ExtendLevel.Items.Add(lvl.Name);
|
|
}
|
|
|
|
|
|
//연장할레벨 저장
|
|
if (Reg.getReg("ExtLev_Lvl") == "")
|
|
{
|
|
combo_ExtendLevel.SelectedIndex = 0;
|
|
}
|
|
else
|
|
{
|
|
string Lvl_Str = Reg.getReg("ExtLev_Lvl");
|
|
combo_ExtendLevel.SelectedItem = Lvl_Str;
|
|
}
|
|
|
|
|
|
//오프셋 0으로 지정
|
|
if (Reg.getReg("ExtLev_offset") == "")
|
|
{
|
|
Reg.setReg("ExtLev_offset", "0");
|
|
txt_Offset.Text = "0";
|
|
}
|
|
else
|
|
{
|
|
string Offset_Str = Reg.getReg("ExtLev_offset");
|
|
txt_Offset.Text = Offset_Str;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
//간격 띄우기
|
|
private void txt_Offset_TextChanged(object sender, EventArgs e)
|
|
{
|
|
if (txt_Offset.Text == "") return;
|
|
if (txt_Offset.Text != "-")
|
|
{
|
|
m_offset = double.Parse(txt_Offset.Text);
|
|
Reg.setReg("ExtLev_offset", m_offset.ToString());
|
|
}
|
|
|
|
}
|
|
|
|
private void FormExtend2Level_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_Offset_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 == 45)
|
|
{
|
|
if (txt_Offset.Text.Contains("-") == true) e.Handled = true;
|
|
}
|
|
|
|
if (keyCode == 46)
|
|
{
|
|
if (string.IsNullOrEmpty(txt_Offset.Text) || txt_Offset.Text.Contains('.') == true)
|
|
e.Handled = true;
|
|
}
|
|
}
|
|
|
|
|
|
private void combo_ExtendLevel_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
m_Extend = combo_ExtendLevel.SelectedIndex;
|
|
m_LvlExtend = combo_ExtendLevel.SelectedItem as string;
|
|
|
|
Reg.setReg("ExtLev_Lvl", m_LvlExtend);
|
|
}
|
|
|
|
private void combo_ExtendLevel_DrawItem(object sender, DrawItemEventArgs e)
|
|
{
|
|
System.Windows.Forms.ComboBox cbx = sender as System.Windows.Forms.ComboBox;
|
|
if(cbx != null)
|
|
{
|
|
e.DrawBackground();
|
|
if(e.Index >= 0)
|
|
{
|
|
StringFormat sf = new StringFormat();
|
|
sf.LineAlignment = StringAlignment.Center;
|
|
sf.Alignment = StringAlignment.Far;
|
|
Brush brush = new SolidBrush(cbx.ForeColor);
|
|
if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
|
|
brush = SystemBrushes.HighlightText;
|
|
e.Graphics.DrawString(cbx.Items[e.Index].ToString(), cbx.Font, brush, e.Bounds, sf);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|