Ejemplo n.º 1
0
        public static void Run()
        {
            //Add delegates
            DbPostElementChange.AddPostCreateElement(DbElementTypeInstance.PIPE, new DbPostElementChange.PostCreateDelegate(PostCreateSubscriber));
            DbPostElementChange.AddPreDeleteElement(DbElementTypeInstance.PIPE, new DbPostElementChange.PreDeleteDelegate(PreDeleteSubscriber));
            DbPostElementChange.AddPostMoveElement(DbElementTypeInstance.PIPE, new DbPostElementChange.PostMoveDelegate(PostMoveSubscriber));
            DbPostElementChange.AddPostAttributeChange(DbAttributeInstance.AREA, new DbPostElementChange.PostAttributeChangeDelegate(PostSetAttSubscriber));
            DbPostElementChange.AddPostAttributeChange(DbAttributeInstance.NAME, new DbPostElementChange.PostAttributeChangeDelegate(PostSetAttSubscriber));
            DbPostElementChange.AddPostRefAttributeChange(DbAttributeInstance.CREF, new DbPostElementChange.PostRefAttributeChangeDelegate(PostSetRefAttSubscriber));

            //Post create
            DbElement newele = Example.Instance.mZone.Create(1, DbElementTypeInstance.PIPE);

            //Pre Delete
            newele.Delete();

            //Post move
            Example.Instance.mPipe.InsertAfter(Example.Instance.mEqui);

            //Post set attribute
            int area = Example.Instance.mEqui.GetInteger(DbAttributeInstance.AREA) + 1;

            Example.Instance.mEqui.SetAttribute(DbAttributeInstance.AREA, area);

            //Post set ref attribute
            Example.Instance.mNozz1.SetAttribute(DbAttributeInstance.CREF, Example.Instance.mBran);
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            //add database changes event handler
            DatabaseService.Changes += new DbChangesEventHandler(DatabaseService_Changes);

            //
            // Element Creation, Deletion, Re-order, Include, Copy
            //
            DbElement nozz1 = Example.Instance.mEqui.CreateFirst(DbElementTypeInstance.NOZZLE);

            Pdms.Utilities.CommandLine.Command.Update();

            DbElement nozz2 = Example.Instance.mEqui.CreateLast(DbElementTypeInstance.NOZZLE);

            Pdms.Utilities.CommandLine.Command.Update();

            nozz1.Copy(Example.Instance.mNozz1);                    // Copy element
            nozz1.SetAttribute(DbAttributeInstance.DESC, "nozzle"); // Change only one part
            Pdms.Utilities.CommandLine.Command.Update();            // Make sure these changes are ignored
            nozz1.Copy(Example.Instance.mNozz1);                    // Re-Copy element - should indicate only the description part has changed
            Pdms.Utilities.CommandLine.Command.Update();

            nozz1.InsertAfterLast(Example.Instance.mEqui);
            Pdms.Utilities.CommandLine.Command.Update();

            nozz1.Delete();
            Pdms.Utilities.CommandLine.Command.Update();
        }
Ejemplo n.º 3
0
        public void CreateBox(DbElement owner, IfcObjectGeometryData primitive)
        {
            DbElement dbElement = owner.Create(0, (DbElementType)DbElementTypeInstance.BOX);

            try
            {
                AABB     aabb   = new AABB(primitive.StartPointTS, primitive.EndPointTS);
                Point    point  = new Point(aabb.GetCenterPoint().X, aabb.GetCenterPoint().Y, aabb.GetCenterPoint().Z);
                Position pos    = Position.Create(point.X, point.Y, point.Z);
                Vector   xdirTs = primitive.XDirTS;
                xdirTs.Normalize();
                Vector ydirTs = primitive.YDirTS;
                ydirTs.Normalize();
                Orientation orientation = Tools.CreateOrientation(xdirTs, ydirTs);
                Tools.CreatePosOri(dbElement, pos, orientation);
                double num1 = Math.Round(primitive.XDimension, 0);
                Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.XLEN, num1);
                double num2 = Math.Round(primitive.YDimension, 0);
                Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.YLEN, num2);
                double num3 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0);
                Tools.SetAttribute(dbElement, (DbAttribute)DbAttributeInstance.ZLEN, num3);
            }
            catch
            {
                dbElement.Delete();
            }
        }
Ejemplo n.º 4
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();
            }
        }
Ejemplo n.º 5
0
        public void CreateExtrusion(DbElement owner, IfcObjectGeometryData primitive, bool chamfers)
        {
            DbElement dbElement1 = owner.Create(0, (DbElementType)DbElementTypeInstance.EXTRUSION);

            try
            {
                Vector xdirTs = primitive.XDirTS;
                xdirTs.Normalize();
                Vector ydirTs = primitive.YDirTS;
                ydirTs.Normalize();
                CoordinateSystem CoordSys    = new CoordinateSystem(primitive.PolygonPointsTS[0], xdirTs, ydirTs);
                Matrix           matrix      = MatrixFactory.ToCoordinateSystem(CoordSys);
                Orientation      orientation = Tools.CreateOrientation(xdirTs, ydirTs);
                Position         pos         = Position.Create(CoordSys.Origin.X, CoordSys.Origin.Y, CoordSys.Origin.Z);
                Tools.CreatePosOri(dbElement1, pos, orientation);
                double num1 = Math.Round(Distance.PointToPoint(primitive.StartPointTS, primitive.EndPointTS), 0);
                Tools.SetAttribute(dbElement1, (DbAttribute)DbAttributeInstance.HEIG, num1);
                DbElement     dbElement2 = dbElement1.Create(0, (DbElementType)DbElementTypeInstance.LOOP);
                int           index      = 0;
                List <Point>  points;
                List <double> chamfers1;
                new PolygonCreator().GetPolygonPointsArcMiddelePoint(primitive, out points, out chamfers1);
                List <Point> list = points.Select <Point, Point>((Func <Point, Point>)(p => matrix.Transform(p))).ToList <Point>();
                Tools.CleanPolygonImport(ref chamfers1, ref list);
                foreach (Point point in list)
                {
                    DbElement element = dbElement2.Create(0, (DbElementType)DbElementTypeInstance.VERTEX);
                    Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.POS, Position.Create(point.X, point.Y, point.Z));
                    double num2 = chamfers ? Math.Floor(chamfers1[index]) : 0.0;
                    Tools.SetAttribute(element, (DbAttribute)DbAttributeInstance.FRAD, num2);
                    ++index;
                }
            }
            catch
            {
                dbElement1.Delete();
            }
        }
Ejemplo n.º 6
0
        public void Create()
        {
            //Delete Example Site if it already exists
            DbElement site = DbElement.GetElement("/ExampleSite");

            if (site.IsValid)
            {
                site.Delete();
            }

            //Get world element
            mWorld = DbElement.GetElement("/*");

            //ExampleSite
            mSite = mWorld.Create(0, DbElementTypeInstance.SITE);
            mSite.SetAttribute(DbAttributeInstance.NAME, "/ExampleSite");

            //ExampleZone
            mZone = mSite.Create(0, DbElementTypeInstance.ZONE);
            mZone.SetAttribute(DbAttributeInstance.NAME, "/ExampleZone");

            //ExampleEqui
            mEqui = mZone.Create(0, DbElementTypeInstance.EQUIPMENT);
            mEqui.SetAttribute(DbAttributeInstance.NAME, "/ExampleEqui");

            //ExampleCyli
            mCyli = mEqui.Create(0, DbElementTypeInstance.CYLINDER);
            mCyli.SetAttribute(DbAttributeInstance.NAME, "/ExampleCyli");

            //ExampleBox
            mBox = mEqui.Create(0, DbElementTypeInstance.BOX);
            mBox.SetAttribute(DbAttributeInstance.NAME, "/ExampleBox");

            //ExampleNozz1
            mNozz1 = mEqui.Create(0, DbElementTypeInstance.NOZZLE);
            mNozz1.SetAttribute(DbAttributeInstance.NAME, "/ExampleNozz1");

            //ExampleNozz2
            mNozz2 = mEqui.Create(0, DbElementTypeInstance.NOZZLE);
            mNozz2.SetAttribute(DbAttributeInstance.NAME, "/ExampleNozz2");

            //ExamplePipe
            mPipe = mZone.Create(0, DbElementTypeInstance.PIPE);
            mPipe.SetAttribute(DbAttributeInstance.NAME, "/ExamplePipe");

            //ExampleBran
            mBran = mPipe.Create(0, DbElementTypeInstance.BRANCH);
            mBran.SetAttribute(DbAttributeInstance.NAME, "/ExampleBran");

            //ExampleGask
            mGask = mBran.Create(0, DbElementTypeInstance.GASKET);
            mGask.SetAttribute(DbAttributeInstance.NAME, "/ExampleGask");

            //ExampleElbow
            mElbo = mBran.Create(0, DbElementTypeInstance.ELBOW);
            mElbo.SetAttribute(DbAttributeInstance.NAME, "/ExampleElbow");

            //ExampleTee
            mTee = mBran.Create(0, DbElementTypeInstance.TEE);
            mTee.SetAttribute(DbAttributeInstance.NAME, "/ExampleTee");
        }