/// <summary> /// Exports mullion. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="mullion"> /// The mullion object. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="localPlacement"> /// The local placement handle. /// </param> /// <param name="extraParams"> /// The extrusion creation data. /// </param> /// <param name="setter"> /// The IFCPlacementSetter. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement, IFCAnyHandle localPlacement, IFCExtrusionCreationData extraParams, IFCPlacementSetter setter, IFCProductWrapper productWrapper) { IFCFile file = exporterIFC.GetFile(); ElementId catId = CategoryUtil.GetSafeCategoryId(mullion); BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true); IFCAnyHandle repHnd = RepresentationUtil.CreateBRepProductDefinitionShape(mullion.Document.Application, exporterIFC, mullion, catId, geometryElement, bodyExporterOptions, null, extraParams); if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd)) { extraParams.ClearOpenings(); return; } string elemGUID = ExporterIFCUtils.CreateGUID(mullion); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion); string elemId = NamingUtil.CreateIFCElementId(mullion); IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, elemObjectType, null, elemObjectType, localPlacement, repHnd, elemId); productWrapper.AddElement(mullionHnd, setter, extraParams, LevelUtil.AssociateElementToLevel(mullion)); PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, mullion, productWrapper); }
/// <summary> /// delete all the mullions of the curtain grid /// </summary> public void DeleteAllMullions() { Transaction act = new Transaction(m_activeDocument, Guid.NewGuid().GetHashCode().ToString()); act.Start(); try { ICollection <ElementId> mullions = m_activeGrid.GetMullionIds(); foreach (ElementId e in mullions) { Mullion mullion = m_activeDocument.GetElement(e) as Mullion; // Exceptions may jump out if attempting to delete "Locked" mullions if (true == mullion.Lockable && true == mullion.Lock) { mullion.Lock = false; } m_activeDocument.Delete(mullion.Id); } } catch (System.Exception e) { TaskDialog.Show("Exception", e.Message); return; } act.Commit(); }
public static Mullion ToMullion(this IMullion item) { var val = new Mullion(); if (item.MullionType != null) { val.MullionType = item.MullionType; } if (item.Parent != null) { val.Parent = item.Parent; } if (item.Code != null) { val.Code = item.Code; } if (item.Next != null) { val.Next = item.Next; } if (item.Previous != null) { val.Previous = item.Previous; } val.IsVirtual = item.IsVirtual; val.Orientation = item.Orientation; val.Length = item.Length; val.MiddlePoint = item.MiddlePoint; return(val); }
/// <summary> /// Exports mullion. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="mullion"> /// The mullion object. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="localPlacement"> /// The local placement handle. /// </param> /// <param name="extraParams"> /// The extrusion creation data. /// </param> /// <param name="setter"> /// The IFCPlacementSetter. /// </param> /// <param name="productWrapper"> /// The IFCProductWrapper. /// </param> public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement, IFCAnyHandle localPlacement, IFCExtrusionCreationData extraParams, IFCPlacementSetter setter, IFCProductWrapper productWrapper) { IFCFile file = exporterIFC.GetFile(); ElementId catId = CategoryUtil.GetSafeCategoryId(mullion); IFCSolidMeshGeometryInfo solidMeshInfo = ExporterIFCUtils.GetSolidMeshGeometry(exporterIFC, geometryElement, Transform.Identity); IList<Solid> solids = solidMeshInfo.GetSolids(); IList<Mesh> polyMeshes = solidMeshInfo.GetMeshes(); bool tryToExportAsExtrusion = true; if (solids.Count != 1 || polyMeshes.Count != 0) tryToExportAsExtrusion = false; IFCAnyHandle shapeRep = BodyExporter.ExportBody(mullion.Document.Application, exporterIFC, catId, solids, polyMeshes, tryToExportAsExtrusion, extraParams); IList<IFCAnyHandle> shapeReps = new List<IFCAnyHandle>(); shapeReps.Add(shapeRep); IFCAnyHandle repHnd = file.CreateProductDefinitionShape(IFCLabel.Create(), IFCLabel.Create(), shapeReps); IFCLabel elemGUID = IFCLabel.CreateGUID(mullion); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); IFCLabel elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion); IFCLabel elemId = NamingUtil.CreateIFCElementId(mullion); //IFCLabel elemType = IFCLabel.Create("MULLION"); IFCAnyHandle mullionHnd = file.CreateMember(elemGUID, ownerHistory, elemObjectType, IFCLabel.Create(), elemObjectType, localPlacement, repHnd, elemId); productWrapper.AddElement(mullionHnd, setter, extraParams, true); }
private void shiftDownMnuItem_Click(object sender, EventArgs e) { Mullion mullion = SelectionEventHandler.SelectedNode as Mullion; if (mullion == null || mullion.Model.Orientation != UrcieSln.Domain.Entities.Orientation.Horizontal) { throw new InvalidOperationException("Invalid mullion"); } PItemRemove.RemoveShiftRightMullion(mullion); }
void Model_PropertyChanged(object sender, PVCModelPropertyChangedEventArgs e) { if (e.PropertyCode == MullionModel.MIDDLE_POINT_PROPERTY_CODE) { Mullion mullion = SelectionEventHandler.SelectedNode as Mullion; if (mullion != null) { MiddlePointTextBox.Text = mullion.Model.MiddlePoint.ToString(); } } }
private void VirtualMullion_Click(object sender, RoutedEventArgs e) { Mullion mullion = SelectionEventHandler.SelectedNode as Mullion; if (mullion == null) { return; } mullion.Model.IsVirtual = VirtualMullion.IsChecked.Value; Frame.Repaint(); }
private void IncreaseMiddlePoint_Click(object sender, RoutedEventArgs e) { if (!SelectToolActive) { return; } Mullion mullion = SelectionEventHandler.SelectedNode as Mullion; if (mullion == null) { return; } MullionMiddlePoint++; }
/// <summary> /// Exports mullion. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="mullion"> /// The mullion object. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="localPlacement"> /// The local placement handle. /// </param> /// <param name="setter"> /// The IFCPlacementSetter. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement, IFCAnyHandle localPlacement, IFCPlacementSetter setter, ProductWrapper productWrapper) { IFCFile file = exporterIFC.GetFile(); using (IFCPlacementSetter mullionSetter = IFCPlacementSetter.Create(exporterIFC, mullion, null, null, ExporterUtil.GetBaseLevelIdForElement(mullion))) { using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData()) { IFCAnyHandle mullionPlacement = mullionSetter.GetPlacement(); Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(localPlacement, mullionPlacement); Transform inverseTrf = relTrf.Inverse; IFCAnyHandle mullionRelativePlacement = ExporterUtil.CreateAxis2Placement3D(file, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX); IFCAnyHandle mullionLocalPlacement = IFCInstanceExporter.CreateLocalPlacement(file, localPlacement, mullionRelativePlacement); extraParams.SetLocalPlacement(mullionLocalPlacement); ElementId catId = CategoryUtil.GetSafeCategoryId(mullion); BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true); IFCAnyHandle repHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, mullion, catId, geometryElement, bodyExporterOptions, null, extraParams, true); if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd)) { extraParams.ClearOpenings(); return; } string elemGUID = GUIDUtil.CreateGUID(mullion); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion); string name = NamingUtil.GetNameOverride(mullion, elemObjectType); string description = NamingUtil.GetDescriptionOverride(mullion, null); string objectType = NamingUtil.GetObjectTypeOverride(mullion, elemObjectType); string elemTag = NamingUtil.GetTagOverride(mullion, NamingUtil.CreateIFCElementId(mullion)); IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, name, description, objectType, mullionLocalPlacement, repHnd, elemTag); ExporterCacheManager.HandleToElementCache.Register(mullionHnd, mullion.Id); productWrapper.AddElement(mullion, mullionHnd, mullionSetter, extraParams, false); ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, mullion); CategoryUtil.CreateMaterialAssociation(exporterIFC, mullionHnd, matId); } } }
private void SelectedMullionType_SelectionChanged(object sender, SelectionChangedEventArgs e) { MullionType mullionType = SelectedMullionType.SelectedItem as MullionType; Mullion mullion = SelectionEventHandler.SelectedNode as Mullion; if (mullion == null) { return; } if (!mullion.Model.MullionType.Equals(MullionType)) { mullion.Model.MullionType = mullionType; mullion.Repaint(); } }
/// <summary> /// Exports mullion. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="mullion"> /// The mullion object. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="localPlacement"> /// The local placement handle. /// </param> /// <param name="extraParams"> /// The extrusion creation data. /// </param> /// <param name="setter"> /// The IFCPlacementSetter. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement, IFCAnyHandle localPlacement, IFCExtrusionCreationData extraParams, IFCPlacementSetter setter, ProductWrapper productWrapper) { IFCFile file = exporterIFC.GetFile(); using (IFCPlacementSetter mullionSetter = IFCPlacementSetter.Create(exporterIFC, mullion)) { IFCAnyHandle mullionPlacement = mullionSetter.GetPlacement(); Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(localPlacement, mullionPlacement); Transform inverseTrf = relTrf.Inverse; IFCAnyHandle mullionRelativePlacement = ExporterUtil.CreateAxis2Placement3D(file, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX); IFCAnyHandle mullionLocalPlacement = IFCInstanceExporter.CreateLocalPlacement(file, localPlacement, mullionRelativePlacement); extraParams.SetLocalPlacement(mullionLocalPlacement); ElementId catId = CategoryUtil.GetSafeCategoryId(mullion); BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true); IFCAnyHandle repHnd = RepresentationUtil.CreateBRepProductDefinitionShape(mullion.Document.Application, exporterIFC, mullion, catId, geometryElement, bodyExporterOptions, null, extraParams); if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd)) { extraParams.ClearOpenings(); return; } string elemGUID = GUIDUtil.CreateGUID(mullion); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion); string elemId = NamingUtil.CreateIFCElementId(mullion); IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, elemObjectType, null, elemObjectType, mullionLocalPlacement, repHnd, elemId); productWrapper.AddElement(mullionHnd, mullionSetter, extraParams, false); ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, mullion); CategoryUtil.CreateMaterialAssociation(mullion.Document, exporterIFC, mullionHnd, matId); PropertyUtil.CreateInternalRevitPropertySets(exporterIFC, mullion, productWrapper); } }
/// <summary> /// reload all the geometry data of the curtain grid (grid lines, vertexes, and convert them to 2D format) /// </summary> public void ReloadGeometryData() { if (null == m_activeGrid) { if (true == m_myDocument.WallCreated) { m_activeGrid = m_myDocument.CurtainWall.CurtainGrid; } else { return; } } Transaction act = new Transaction(m_activeDocument, Guid.NewGuid().GetHashCode().ToString()); act.Start(); //ElementSet mullions = m_activeGrid.Mullions; ICollection <ElementId> mullions = m_activeGrid.GetMullionIds(); act.Commit(); if (0 == mullions.Count) { foreach (ElementId e in mullions) { Mullion mullion = m_activeDocument.GetElement(e) as Mullion; if (null != mullion) { m_mullionType = mullion.MullionType; break; } } } GetULines(); GetVLines(); GetCurtainGridVertexes(); // covert those lines to 2D format m_drawing.GetLines2D(); }
/// <summary> /// Extracts a Dynamo Solid from a Revit Wall object and creates a ParasiteObject /// from the extracted geometry /// </summary> /// <param name="element"></param> /// <param name="outPutSolids"></param> /// <param name="parasiteObjects"></param> /// <param name="OP"></param> /// <param name="doc"></param> public static void GeometryDataFromWall(Element element, List <DynamoSolid> outPutSolids, List <ParasiteObject> parasiteObjects, Options OP, Document doc) { if (element is WallType) { // Cast Element to WallType WallType wallType = element as WallType; // Get Geometry Element GeometryElement geometryElement = wallType.get_Geometry(OP); // Skip if null if (geometryElement != null) { P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, wallType.Name, P_StorageType.String); P_Parameter paramLayer = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String); DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement, new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects); } } // END WALLTYPE CLASS CONDITION else if (element is Wall) { Wall wall = element as Wall; CurtainGrid cgrid = wall.CurtainGrid; // THIS MEANS WALL IS A GLAZED CURTAIN WALL if (cgrid != null) { ICollection <ElementId> panelIds = cgrid.GetPanelIds(); Element[] panels = panelIds.Select(a => doc.GetElement(a)).ToArray(); for (int p = 0; p < panels.Length; p++) { // Ignores Family instances in the Curtain wall. For example doors if (!(panels[p] is Panel panel)) { continue; } GeometryElement geometryElement = panel.get_Geometry(OP); if (geometryElement != null) { P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, panel.Category.Name, P_StorageType.String); P_Parameter paramLayer = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String); DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement, new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects); } } ICollection <ElementId> mullionIds = cgrid.GetMullionIds(); Element[] mullions = mullionIds.Select(a => doc.GetElement(a)).ToArray(); for (int m = 0; m < mullions.Length; m++) { Mullion mullion = mullions[m] as Mullion; //if (!(mullions[m] is Mullion mullion)) continue; GeometryElement geometryElement = mullion.get_Geometry(OP); if (geometryElement != null) { P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, mullion.Category.Name, P_StorageType.String); P_Parameter paramLayer = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String); DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement, new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects); } } } // End of wall that is a curtain wall // THIS MEANS ITS A NORMAL WALL else { GeometryElement geometryElement = element.get_Geometry(OP); if (geometryElement != null) { P_Parameter paramChildLayer = new P_Parameter(P_ParameterType.ChildLayer, wall.WallType.Name, P_StorageType.String); P_Parameter paramLayer = new P_Parameter(P_ParameterType.Layer, element.Category.Name, P_StorageType.String); DynamoParasiteFactory.CreateParasiteObjectFromGeometryElement(geometryElement, new P_Parameter[] { paramChildLayer, paramLayer }, outPutSolids, parasiteObjects); } } } // END WALL CLASS CONDITION else { throw new ParasiteNotImplementedExceptions("Wall type not implemented yet"); } }
private void SelectionEventHandler_SelectionChanged(object sender, PPropertyEventArgs e) { FrameSelected = false; MullionSelected = false; SashSelected = false; FillingSelected = false; IncreaseMiddlePoint.IsEnabled = false; DeacreaseMiddlePoint.IsEnabled = false; SelectedSashType.SelectedItem = null; SelectedSashDirectionComboBox.SelectedItem = null; MiddlePointTextBox.IsEnabled = false; SelectedFillingType.SelectedItem = null; SelectedIProfileType.SelectedItem = null; SelectedIncludeIProfileTypeCheckBox.IsChecked = false; if (SelectionEventHandler.SelectedNode is Mullion) { MullionSelected = true; Mullion mullion = SelectionEventHandler.SelectedNode as Mullion; VirtualMullion.IsChecked = mullion.Model.IsVirtual; SelectedMullionType.SelectedItem = mullion.Model.MullionType; IncreaseMiddlePoint.IsEnabled = true; DeacreaseMiddlePoint.IsEnabled = true; MiddlePointTextBox.IsEnabled = true; MullionMiddlePoint = mullion.Model.MiddlePoint; OnPropertyChanged("MullionMiddlePoint"); mullion.Model.PropertyChanged += Model_PropertyChanged; } else if (SelectionEventHandler.SelectedNode is Sash) { SashSelected = true; Sash sash = SelectionEventHandler.SelectedNode as Sash; SelectedSashType.SelectedItem = sash.Model.SashType; SelectedSashDirectionComboBox.SelectedValue = sash.Direction; SashFixedCheckBox.IsChecked = sash.Fixed; } else if (SelectionEventHandler.SelectedNode is Filling) { FillingSelected = true; Filling filling = SelectionEventHandler.SelectedNode as Filling; SelectedFillingType.SelectedItem = filling.Model.FillingType; if (filling.Model.ProfileType != null) { SelectedIncludeIProfileTypeCheckBox.IsChecked = true; SelectedIProfileType.SelectedItem = filling.Model.ProfileType; } else { SelectedIncludeIProfileTypeCheckBox.IsChecked = false; SelectedIProfileType.SelectedItem = null; } } else if (SelectionEventHandler.SelectedNode is PVCFrame) { FrameSelected = true; } if (e.OldValue is Mullion) { Mullion oldMullion = (Mullion)e.OldValue; oldMullion.Model.PropertyChanged -= Model_PropertyChanged; } }
/// <summary> /// Exports mullion. /// </summary> /// <param name="exporterIFC"> /// The ExporterIFC object. /// </param> /// <param name="mullion"> /// The mullion object. /// </param> /// <param name="geometryElement"> /// The geometry element. /// </param> /// <param name="localPlacement"> /// The local placement handle. /// </param> /// <param name="setter"> /// The PlacementSetter. /// </param> /// <param name="productWrapper"> /// The ProductWrapper. /// </param> public static void Export(ExporterIFC exporterIFC, Mullion mullion, GeometryElement geometryElement, IFCAnyHandle localPlacement, PlacementSetter setter, ProductWrapper productWrapper) { IFCFile file = exporterIFC.GetFile(); using (PlacementSetter mullionSetter = PlacementSetter.Create(exporterIFC, mullion)) { using (IFCExtrusionCreationData extraParams = new IFCExtrusionCreationData()) { IFCAnyHandle mullionPlacement = mullionSetter.LocalPlacement; Transform relTrf = ExporterIFCUtils.GetRelativeLocalPlacementOffsetTransform(localPlacement, mullionPlacement); Transform inverseTrf = relTrf.Inverse; IFCAnyHandle mullionLocalPlacement = ExporterUtil.CreateLocalPlacement(file, localPlacement, inverseTrf.Origin, inverseTrf.BasisZ, inverseTrf.BasisX); extraParams.SetLocalPlacement(mullionLocalPlacement); Transform extrusionLCS = null; // Add a custom direction for trying to create an extrusion based on the base curve of the mullion, if it is a line and not an arc. Curve baseCurve = mullion.LocationCurve; if ((baseCurve != null) && (baseCurve is Line)) { // We won't use curveBounds and origin yet; just need the axis for now. IFCRange curveBounds; XYZ origin, mullionDirection; GeometryUtil.GetAxisAndRangeFromCurve(baseCurve, out curveBounds, out mullionDirection, out origin); // approx 1.0/sqrt(2.0) XYZ planeY = (Math.Abs(mullionDirection.Z) < 0.707) ? XYZ.BasisZ.CrossProduct(mullionDirection) : XYZ.BasisX.CrossProduct(mullionDirection); planeY.Normalize(); XYZ projDir = mullionDirection.CrossProduct(planeY); extrusionLCS = Transform.Identity; extrusionLCS.BasisX = mullionDirection; extrusionLCS.BasisY = planeY; extrusionLCS.BasisZ = projDir; extrusionLCS.Origin = origin; } ElementId catId = CategoryUtil.GetSafeCategoryId(mullion); BodyExporterOptions bodyExporterOptions = new BodyExporterOptions(true); bodyExporterOptions.ExtrusionLocalCoordinateSystem = extrusionLCS; IFCAnyHandle repHnd = RepresentationUtil.CreateAppropriateProductDefinitionShape(exporterIFC, mullion, catId, geometryElement, bodyExporterOptions, null, extraParams, true); if (IFCAnyHandleUtil.IsNullOrHasNoValue(repHnd)) { extraParams.ClearOpenings(); return; } string elemGUID = GUIDUtil.CreateGUID(mullion); IFCAnyHandle ownerHistory = exporterIFC.GetOwnerHistoryHandle(); string elemObjectType = NamingUtil.CreateIFCObjectName(exporterIFC, mullion); string name = NamingUtil.GetNameOverride(mullion, elemObjectType); string description = NamingUtil.GetDescriptionOverride(mullion, null); string objectType = NamingUtil.GetObjectTypeOverride(mullion, elemObjectType); string elemTag = NamingUtil.GetTagOverride(mullion, NamingUtil.CreateIFCElementId(mullion)); IFCAnyHandle mullionHnd = IFCInstanceExporter.CreateMember(file, elemGUID, ownerHistory, name, description, objectType, mullionLocalPlacement, repHnd, elemTag, "MULLION"); ExporterCacheManager.HandleToElementCache.Register(mullionHnd, mullion.Id); productWrapper.AddElement(mullion, mullionHnd, mullionSetter, extraParams, false); ElementId matId = BodyExporter.GetBestMaterialIdFromGeometryOrParameter(geometryElement, exporterIFC, mullion); CategoryUtil.CreateMaterialAssociation(exporterIFC, mullionHnd, matId); } } }
private void Stream( ArrayList data, Mullion mullion ) { data.Add( new Snoop.Data.ClassSeparator( typeof( Mullion ) ) ); data.Add( new Snoop.Data.Object( "Mullion type", mullion.MullionType ) ); data.Add( new Snoop.Data.Bool( "Lock", mullion.Lock ) ); data.Add( new Snoop.Data.Bool( "Lockable", mullion.Lockable ) ); data.Add( new Snoop.Data.Object( "Location curve", mullion.LocationCurve ) ); }
/// <summary> /// Sample file is at /// C:\a\j\adn\case\bsd\1242980\attach\mullion.rvt /// </summary> public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication app = commandData.Application; UIDocument uidoc = app.ActiveUIDocument; Document doc = app.ActiveUIDocument.Document; Selection sel = uidoc.Selection; Options options = app.Application.Create.NewGeometryOptions(); string s, msg = string.Empty; int n; foreach (ElementId id in sel.GetElementIds()) { Mullion mullion = doc.GetElement(id) as Mullion; if (null != mullion) { //Location location = mullion.AsFamilyInstance.Location; // seems to be uninitialised // 2011 Location location = mullion.Location; // 2012 LocationPoint lp = mullion.Location as LocationPoint; Debug.Assert(null != lp, "expected a valid mullion location point"); Debug.Assert(null != mullion.LocationCurve, // 2012 "in Revit 2012, the mullion also has a valid location curve"); // 2012 GeometryElement geoElem = mullion.get_Geometry(options); //GeometryObjectArray objects = geoElem.Objects; // 2012 //n = objects.Size; // 2012 n = geoElem.Count <GeometryObject>(); // 2013 s = string.Format( "Mullion <{0} {1}> at {2} rotation" + " {3} has {4} geo object{5}:", mullion.Name, mullion.Id.IntegerValue, Util.PointString(lp.Point), Util.RealString(lp.Rotation), n, Util.PluralSuffix(n)); if (0 < msg.Length) { msg += "\n\n"; } msg += s; //foreach( GeometryObject obj in objects ) // 2012 foreach (GeometryObject obj in geoElem) // 2013 { GeometryInstance inst = obj as GeometryInstance; Transform t = inst.Transform; s = " Transform " + Util.TransformString(t); msg += "\n" + s; GeometryElement elem2 = inst.SymbolGeometry; //foreach( GeometryObject obj2 in elem2.Objects ) // 2012 foreach (GeometryObject obj2 in elem2) // 2013 { Solid solid = obj2 as Solid; if (null != solid) { FaceArray faces = solid.Faces; n = faces.Size; s = string.Format( " {0} face{1}, face point > WCS point:", n, Util.PluralSuffix(n)); msg += "\n" + s; foreach (Face face in solid.Faces) { s = string.Empty; Mesh mesh = face.Triangulate(); foreach (XYZ p in mesh.Vertices) { s += (0 == s.Length) ? " " : ", "; s += string.Format("{0} > {1}", Util.PointString(p), Util.PointString(t.OfPoint(p))); } msg += "\n" + s; } } } } } } if (0 == msg.Length) { msg = "Please select some mullions."; } Util.InfoMsg(msg); return(Result.Failed); }