public RenderNodeAction OnElementBegin( ElementId elementId) { Element e = _doc.GetElement(elementId); string uid = e.UniqueId; Debug.WriteLine(string.Format( "OnElementBegin: id {0} category {1} name {2}", elementId.IntegerValue, e.Category.Name, e.Name)); if (_objects.ContainsKey(uid)) { Debug.WriteLine("\r\n*** Duplicate element!\r\n"); return(RenderNodeAction.Skip); } if (null == e.Category) { Debug.WriteLine("\r\n*** Non-category element!\r\n"); return(RenderNodeAction.Skip); } _elementStack.Push(elementId); if ("相机" == e.Category.Name) { Debug.WriteLine("\r\n*** Camera element!\r\n"); return(RenderNodeAction.Skip); } ICollection <ElementId> idsMaterialGeometry = e.GetMaterialIds(false); ICollection <ElementId> idsMaterialPaint = e.GetMaterialIds(true); int n = idsMaterialGeometry.Count; if (1 < n) { Debug.Print("{0} has {1} materials: {2}", Util.ElementDescription(e), n, string.Join(", ", idsMaterialGeometry.Select( id => _doc.GetElement(id).Name))); } // We handle a current element, which may either // be identical to the current object and have // one single current geometry or have // multiple current child objects each with a // separate current geometry. _currentElement = new Va3cContainer.Va3cObject(); _currentElement.name = Util.ElementDescription(e); _currentElement.material = _currentMaterialUid; _currentElement.matrix = new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; _currentElement.type = "RevitElement"; _currentElement.uuid = uid; _currentObject = new Dictionary <string, Va3cContainer.Va3cObject>(); _currentGeometry = new Dictionary <string, Va3cContainer.Va3cGeometry>(); _vertices = new Dictionary <string, VertexLookupInt>(); if (null != e.Category && null != e.Category.Material) { SetCurrentMaterial(e.Category.Material.UniqueId); } return(RenderNodeAction.Proceed); }
public RenderNodeAction OnElementBegin( ElementId elementId) { Element e = _doc.GetElement(elementId); string uid = e.UniqueId; Debug.WriteLine(string.Format( "OnElementBegin: id {0} category {1} name {2}", elementId.IntegerValue, e.Category.Name, e.Name)); FamilyInstance fi = e as FamilyInstance; //test isOld = false; isNew = false; if (null != fi) { Debug.WriteLine(string.Format("OnElementEnd: symid {0}", fi.Symbol.Id)); //fi.geo var geoList = e.get_Geometry(GetGeometryOption()); if (null != geoList) { var go = geoList.OfType <GeometryInstance>(); foreach (GeometryInstance i in go) { if (_insDict.ContainsKey(fi.Symbol.Id.ToString())) { if (_insDict[fi.Symbol.Id.ToString()].ContainsKey(i.Symbol.Id.ToString())) { //记录参照物 isOld = true; oldInd1 = fi.Symbol.Id.ToString(); oldInd2 = i.Symbol.Id.ToString(); } else { // _insDict[fi.Symbol.Id.ToString()].Add(i.Symbol.Id.ToString(), new List <XYZ>()); oldInd1 = fi.Symbol.Id.ToString(); oldInd2 = i.Symbol.Id.ToString(); isNew = true; } } else { _insDict.Add(fi.Symbol.Id.ToString(), new Dictionary <string, IList <XYZ> >()); _insDict[fi.Symbol.Id.ToString()].Add(i.Symbol.Id.ToString(), new List <XYZ>()); oldInd1 = fi.Symbol.Id.ToString(); oldInd2 = i.Symbol.Id.ToString(); isNew = true; } Debug.WriteLine(string.Format("OnElementEnd: symid {0}", i.Symbol.Id)); } } } if (_objects.ContainsKey(uid)) { Debug.WriteLine("\r\n*** Duplicate element!\r\n"); return(RenderNodeAction.Skip); } if (null == e.Category) { Debug.WriteLine("\r\n*** Non-category element!\r\n"); return(RenderNodeAction.Skip); } _elementStack.Push(elementId); ICollection <ElementId> idsMaterialGeometry = e.GetMaterialIds(false); ICollection <ElementId> idsMaterialPaint = e.GetMaterialIds(true); int n = idsMaterialGeometry.Count; if (1 < n) { Debug.Print("{0} has {1} materials: {2}", Util.ElementDescription(e), n, string.Join(", ", idsMaterialGeometry.Select( id => _doc.GetElement(id).Name))); } // We handle a current element, which may either // be identical to the current object and have // one single current geometry or have // multiple current child objects each with a // separate current geometry. _currentElement = new Va3cContainer.Va3cObject(); _currentElement.name = Util.ElementDescription(e); _currentElement.material = _currentMaterialUid; _currentElement.matrix = new double[] { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; _currentElement.type = "RevitElement"; _currentElement.uuid = uid; _currentObject = new Dictionary <string, Va3cContainer.Va3cObject>(); _currentGeometry = new Dictionary <string, Va3cContainer.Va3cGeometry>(); _vertices = new Dictionary <string, VertexLookupInt>(); if (null != e.Category && null != e.Category.Material) { SetCurrentMaterial(e.Category.Material.UniqueId); } return(RenderNodeAction.Proceed); }