/// <summary> /// the method is used to create new family type /// </summary> /// <param name="para">WindowParameter</param> /// <returns>indicate whether the NewType is successful</returns> private bool newFamilyType(WindowParameter para)//string typeName, double height, double width, double sillHeight) { DoubleHungWinPara dbhungPara = para as DoubleHungWinPara; string typeName = dbhungPara.Type; double height = dbhungPara.Height; double width = dbhungPara.Width; double sillHeight = dbhungPara.SillHeight; double windowInset = dbhungPara.Inset; switch (m_document.DisplayUnitSystem) { case Autodesk.Revit.DB.DisplayUnit.METRIC: height = Utility.MetricToImperial(height); width = Utility.MetricToImperial(width); sillHeight = Utility.MetricToImperial(sillHeight); windowInset = Utility.MetricToImperial(windowInset); break; } try { FamilyType type = m_familyManager.NewType(typeName); m_familyManager.CurrentType = type; m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT), height); m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH), width); m_familyManager.Set(m_familyManager.get_Parameter("Default Sill Height"), sillHeight); m_familyManager.Set(m_familyManager.get_Parameter("Window Inset"), windowInset); return(true); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.Message); return(false); } }
/// <summary> /// construcion of WindowParameter /// </summary> /// <param name="para">the WindowParameter</param> public WindowParameter(WindowParameter para) { if (String.IsNullOrEmpty(para.m_type)) { m_type = "NewType"; } m_type = para.Type + "1"; m_height = para.Height; m_width = para.Width; }
/// <summary> /// The implementation of CombineAndBuild() ,defining New Window Types /// </summary> public override void CombineAndBuild() { SubTransaction subTransaction = new SubTransaction(m_document); subTransaction.Start(); foreach (String type in m_para.WinParaTab.Keys) { WindowParameter para = m_para.WinParaTab[type] as WindowParameter; newFamilyType(para); } subTransaction.Commit(); }