public bool IsCommandAvailable(UIApplication applicationData, Autodesk.Revit.DB.CategorySet selectedCategories) { System.Collections.IEnumerator iterCategory = selectedCategories.GetEnumerator(); iterCategory.Reset(); while (iterCategory.MoveNext()) { Autodesk.Revit.DB.Category category = (Autodesk.Revit.DB.Category)(iterCategory.Current); if (category.Name == "Walls") { return false; } } return true; }
/// <summary> /// Draw geometry of element. /// </summary> /// <param name="elementGeom"></param> /// <remarks></remarks> private void SendElement(Autodesk.Revit.DB.GeometryElement elementGeom, Autodesk.Revit.DB.Element elem) { if (elementGeom == null) { return; } try { if (elem.IsHidden(View3D)) { return; } if (!elem.Category.get_Visible(View3D as Autodesk.Revit.DB.View)) { return; } } catch { } int num = 0; IEnumerator<Autodesk.Revit.DB.GeometryObject> Objects = elementGeom.GetEnumerator(); while (Objects.MoveNext()) { Autodesk.Revit.DB.GeometryObject geomObject = Objects.Current; if (geomObject.Visibility == Autodesk.Revit.DB.Visibility.Visible) { if ((geomObject is Autodesk.Revit.DB.Curve)) { //mb.add((int)ObjectTypes.Curve); //SendCurve(geomObject); } else if ((elem is Autodesk.Revit.DB.SpatialElement)) { // don't show room volumes } else if ((geomObject is Autodesk.Revit.DB.GeometryInstance)) { /*if (elem.Category.Name != "{3}") { if (!elem.Category.get_Visible(View3D as Autodesk.Revit.DB.View)) { return; } }*/ SendInstance(geomObject as Autodesk.Revit.DB.GeometryInstance, elem); } else if ((geomObject is Autodesk.Revit.DB.Mesh)) { MessageBuffer mb = new MessageBuffer(); mb.add(elem.Id.IntegerValue); mb.add(elem.Name + "_m_" + num.ToString()); mb.add((int)ObjectTypes.Mesh); Autodesk.Revit.DB.Mesh meshObj = geomObject as Autodesk.Revit.DB.Mesh; SendMesh(meshObj, ref mb, true);// TODO get information on whether a mesh is twosided or not Autodesk.Revit.DB.ElementId materialID; materialID = meshObj.MaterialElementId; Autodesk.Revit.DB.Material materialElement = elem.Document.GetElement(materialID) as Autodesk.Revit.DB.Material; if (materialElement != null) { mb.add(materialElement.Color); mb.add((byte)(((100 - (materialElement.Transparency)) / 100.0) * 255)); mb.add(materialID.IntegerValue); // material ID } else { mb.add((byte)250); // color mb.add((byte)250); mb.add((byte)250); mb.add((byte)255); mb.add(-1); // material ID } sendMessage(mb.buf, MessageTypes.NewObject); if (num == 0) sendParameters(elem); } else if ((geomObject is Autodesk.Revit.DB.Solid)) { MessageBuffer mb = new MessageBuffer(); mb.add(elem.Id.IntegerValue); mb.add(elem.Name + "_s_" + num.ToString()); sendMessage(mb.buf, MessageTypes.NewGroup); SendSolid((Autodesk.Revit.DB.Solid)geomObject, elem); mb = new MessageBuffer(); sendMessage(mb.buf, MessageTypes.EndGroup); if(num == 0) sendParameters(elem); } num++; } } }