private static ElementId CategorySetup(Document doc) { string name = "View Outline"; var parent = Category.GetCategory(doc, BuiltInCategory.OST_CLines); CategoryNameMap map = parent.SubCategories; var subcat = !map.Contains(name) ? doc.Settings.Categories.NewSubcategory(parent, name) : map.get_Item(name); subcat.SetLineWeight(1, GraphicsStyleType.Projection); subcat.LineColor = new Color(255, 128, 0); subcat.SetLinePatternId(doc.GetDash(), GraphicsStyleType.Projection); return(subcat.Id); }
private void CategorySetup(CC_Category cat) { if (cat.BuiltInCategory > 0) { Category bic = GetBuiltInCategory(currentDoc, cat.BuiltInCategory); setCategoryStyles(bic, cat); } else { CC_Category parentcat = CategoryCalls.getCategory(cat.Name); Category parent = GetBuiltInCategory(currentDoc, parentcat.BuiltInCategory); CategoryNameMap map = parent.SubCategories; if (!map.Contains(cat.Name)) { Category subcat = currentDoc.Settings.Categories.NewSubcategory(parent, cat.Name); setCategoryStyles(subcat, cat); } else { Category subcat = map.get_Item(cat.Name); setCategoryStyles(subcat, cat); } } }
/// <summary> /// The method is used to collect template information, specifying the New Window Parameters /// </summary> private void CollectTemplateInfo() { List <Wall> walls = Utility.GetElements <Wall>(m_application, m_document); m_wallThickness = walls[0].Width; ParameterMap paraMap = walls[0].ParametersMap; Parameter wallheightPara = paraMap.get_Item("Unconnected Height"); if (wallheightPara != null) { m_wallHeight = wallheightPara.AsDouble(); } Parameter wallwidthPara = paraMap.get_Item("Length"); if (wallwidthPara != null) { m_wallWidth = wallwidthPara.AsDouble(); } m_windowInset = m_wallThickness / 10; FamilyType type = m_familyManager.CurrentType; FamilyParameter heightPara = m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT); FamilyParameter widthPara = m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH); FamilyParameter sillHeightPara = m_familyManager.get_Parameter("Default Sill Height"); if (type.HasValue(heightPara)) { switch (heightPara.StorageType) { case StorageType.Double: m_height = type.AsDouble(heightPara).Value; break; case StorageType.Integer: m_height = type.AsInteger(heightPara).Value; break; } } if (type.HasValue(widthPara)) { switch (widthPara.StorageType) { case StorageType.Double: m_width = type.AsDouble(widthPara).Value; break; case StorageType.Integer: m_width = type.AsDouble(widthPara).Value; break; } } if (type.HasValue(sillHeightPara)) { switch (sillHeightPara.StorageType) { case StorageType.Double: m_sillHeight = type.AsDouble(sillHeightPara).Value; break; case StorageType.Integer: m_sillHeight = type.AsDouble(sillHeightPara).Value; break; } } //set the height,width and sillheight parameter of the opening m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_HEIGHT), m_height); m_familyManager.Set(m_familyManager.get_Parameter(BuiltInParameter.WINDOW_WIDTH), m_width); m_familyManager.Set(m_familyManager.get_Parameter("Default Sill Height"), m_sillHeight); //get materials FilteredElementCollector elementCollector = new FilteredElementCollector(m_document); elementCollector.WherePasses(new ElementClassFilter(typeof(Material))); IList <Element> materials = elementCollector.ToElements(); foreach (Element materialElement in materials) { Material material = materialElement as Material; m_para.GlassMaterials.Add(material.Name); m_para.FrameMaterials.Add(material.Name); } //get categories Categories categories = m_document.Settings.Categories; Category category = categories.get_Item(BuiltInCategory.OST_Windows); CategoryNameMap cnm = category.SubCategories; if (cnm.Contains("Frame/Mullion")) { m_frameCat = cnm.get_Item("Frame/Mullion"); } if (cnm.Contains("Glass")) { m_glassCat = cnm.get_Item("Glass"); } //get referenceplanes List <ReferencePlane> planes = Utility.GetElements <ReferencePlane>(m_application, m_document); foreach (ReferencePlane p in planes) { if (p.Name.Equals("Sash")) { m_sashPlane = p; } if (p.Name.Equals("Exterior")) { m_exteriorPlane = p; } if (p.Name.Equals("Center (Front/Back)")) { m_centerPlane = p; } if (p.Name.Equals("Top") || p.Name.Equals("Head")) { m_topPlane = p; } if (p.Name.Equals("Sill") || p.Name.Equals("Bottom")) { m_sillPlane = p; } } }