/// <summary> /// Processes an IfcGridAxis object. /// </summary> /// <param name="ifcGridAxis">The IfcGridAxis handle.</param> /// <returns>The IFCGridAxis object.</returns> public static IFCGridAxis ProcessIFCGridAxis(IFCAnyHandle ifcGridAxis) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcGridAxis)) { Importer.TheLog.LogNullError(IFCEntityType.IfcGridAxis); return(null); } IFCEntity gridAxis; if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcGridAxis.StepId, out gridAxis)) { try { gridAxis = new IFCGridAxis(ifcGridAxis); } catch (Exception ex) { Importer.TheLog.LogError(ifcGridAxis.StepId, ex.Message, false); return(null); } } return(gridAxis as IFCGridAxis); }
private int FindMatchingGrid(IFCGridAxis gridAxis, ref IList <Curve> curves, ref int curveCount) { IList <Curve> otherCurves = gridAxis.AxisCurve.GetCurves(); int id = gridAxis.Id; return(FindMatchingGrid(otherCurves, id, ref curves, ref curveCount)); }
private IList <IFCGridAxis> ProcessOneAxis(IFCAnyHandle ifcGrid, string axisName) { IList <IFCGridAxis> gridAxes = new List <IFCGridAxis>(); List <IFCAnyHandle> ifcAxes = IFCAnyHandleUtil.GetAggregateInstanceAttribute <List <IFCAnyHandle> >(ifcGrid, axisName); if (ifcAxes != null) { foreach (IFCAnyHandle axis in ifcAxes) { IFCGridAxis gridAxis = IFCGridAxis.ProcessIFCGridAxis(axis); if (gridAxis != null) { if (gridAxis.DuplicateAxisId == -1) { gridAxes.Add(gridAxis); } else { IFCEntity originalEntity; if (IFCImportFile.TheFile.EntityMap.TryGetValue(gridAxis.DuplicateAxisId, out originalEntity)) { IFCGridAxis originalGridAxis = originalEntity as IFCGridAxis; if (originalGridAxis != null) { gridAxes.Add(originalGridAxis); } } } } } } return(gridAxes); }
/// <summary> /// Processes IfcGridAxis attributes. /// </summary> /// <param name="ifcGridAxis">The IfcGridAxis handle.</param> protected override void Process(IFCAnyHandle ifcGridAxis) { base.Process(ifcGridAxis); AxisTag = IFCImportHandleUtil.GetOptionalStringAttribute(ifcGridAxis, "AxisTag", null); IFCAnyHandle axisCurve = IFCImportHandleUtil.GetRequiredInstanceAttribute(ifcGridAxis, "AxisCurve", true); AxisCurve = IFCCurve.ProcessIFCCurve(axisCurve); bool found = false; bool sameSense = IFCImportHandleUtil.GetRequiredBooleanAttribute(ifcGridAxis, "SameSense", out found); SameSense = found ? sameSense : true; // We are going to check if this grid axis is a vertical duplicate of any existing axis. // If so, we will throw an exception so that we don't create duplicate grids. // We will only initialize these values if we actually intend to use them below. IList <Curve> curves = null; int curveCount = 0; ElementId gridId = ElementId.InvalidElementId; if (Importer.TheCache.GridNameToElementMap.TryGetValue(AxisTag, out gridId)) { Grid grid = IFCImportFile.TheFile.Document.GetElement(gridId) as Grid; if (grid != null) { IList <Curve> otherCurves = new List <Curve>(); Curve gridCurve = grid.Curve; if (gridCurve != null) { otherCurves.Add(gridCurve); int matchingGridId = FindMatchingGrid(otherCurves, grid.Id.IntegerValue, ref curves, ref curveCount); if (matchingGridId != -1) { Importer.TheCache.UseGrid(grid); CreatedElementId = grid.Id; return; } } } } IDictionary <string, IFCGridAxis> gridAxes = IFCImportFile.TheFile.IFCProject.GridAxes; IFCGridAxis gridAxis = null; if (gridAxes.TryGetValue(AxisTag, out gridAxis)) { int matchingGridId = FindMatchingGrid(gridAxis, ref curves, ref curveCount); if (matchingGridId != -1) { DuplicateAxisId = matchingGridId; return; } } gridAxes.Add(new KeyValuePair <string, IFCGridAxis>(AxisTag, this)); }
/// <summary> /// Processes an IfcGridAxis object. /// </summary> /// <param name="ifcGridAxis">The IfcGridAxis handle.</param> /// <returns>The IFCGridAxis object.</returns> public static IFCGridAxis ProcessIFCGridAxis(IFCAnyHandle ifcGridAxis) { if (IFCAnyHandleUtil.IsNullOrHasNoValue(ifcGridAxis)) { IFCImportFile.TheLog.LogNullError(IFCEntityType.IfcGridAxis); return null; } IFCEntity gridAxis; if (!IFCImportFile.TheFile.EntityMap.TryGetValue(ifcGridAxis.StepId, out gridAxis)) { try { gridAxis = new IFCGridAxis(ifcGridAxis); } catch { return null; } } return (gridAxis as IFCGridAxis); }
private int FindMatchingGrid(IFCGridAxis gridAxis, ref IList<Curve> curves, ref int curveCount) { IList<Curve> otherCurves = gridAxis.AxisCurve.GetCurves(); int id = gridAxis.Id; return FindMatchingGrid(otherCurves, id, ref curves, ref curveCount); }