Example #1
0
        public void CreateCylinder(DbElement owner, IfcObjectGeometryData primitive)
        {
            DbElement element = owner.Create(0, (DbElementType)DbElementTypeInstance.CYLINDER);

            try
            {
                Position    position1        = Tools.GetPosition("POS WRT WORLD", ((object)owner.GetActualType()).Equals((object)DbElementTypeInstance.TMPLATE) ? owner.get_Owner() : owner);
                Orientation orientation1     = Tools.GetOrientation("ORI WRT WORLD", ((object)owner.GetActualType()).Equals((object)DbElementTypeInstance.TMPLATE) ? owner.get_Owner() : owner);
                Direction   direction1       = orientation1.XDir();
                Direction   direction2       = orientation1.YDir();
                Matrix      coordinateSystem = MatrixFactory.ToCoordinateSystem(new CoordinateSystem(new Point(position1.get_X(), position1.get_Y(), position1.get_Z()), new Vector(direction1.get_East(), direction1.get_North(), direction1.get_Up()), new Vector(direction2.get_East(), direction2.get_North(), direction2.get_Up())));
                double      num1             = Math.Max(primitive.XDimension, primitive.YDimension);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.DIAM, num1);
                Point startPointTs = primitive.StartPointTS;
                Point endPointTs   = primitive.EndPointTS;
                new Vector(endPointTs - startPointTs).Normalize();
                AABB        aabb         = new AABB(startPointTs, endPointTs);
                Point       p            = new Point(aabb.GetCenterPoint().X, aabb.GetCenterPoint().Y, aabb.GetCenterPoint().Z);
                Point       point1       = coordinateSystem.Transform(startPointTs);
                Point       point2       = coordinateSystem.Transform(endPointTs);
                Point       point3       = coordinateSystem.Transform(p);
                Orientation orientation2 = Orientation.Create("Z  IS " + ((object)Direction.Create(Position.Create(point1.X, point1.Y, point1.Z), Position.Create(point2.X, point2.Y, point2.Z))).ToString());
                Position    position2    = Position.Create(
                    .X, point3.Y, point3.Z);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.POS, position2);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.ORI, orientation2);
                double num2 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0);
                Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.HEIG, num2);
            }
            catch
            {
                element.Delete();
            }
        }