Esempio n. 1
0
        public Buildable Convert(DbElement element)
        {
            Size      size      = new Size();
            Position  position  = new Position();
            Direction direction = new Direction();

            size.Height   = element.GetDouble(DbAttributeInstance.HEIG);
            size.Diameter = element.GetDouble(DbAttributeInstance.DIAM);

            var q = new DbQualifier();

            q.Add(1);
            q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT);
            var pos = element.GetPosition(DbAttributeInstance.PPOS, q);

            position.X = pos.X;
            position.Y = pos.Y;
            position.Z = pos.Z;

            var d = element.GetDirection(DbAttributeInstance.PDIR, q);

            direction.X = d.ToString();
            direction.Y = d.ToString();
            direction.Z = d.ToString();


            return(new Buildable(DbElementTypeInstance.SCYLINDER, element, size, position, direction, element.ElementType));
        }
Esempio n. 2
0
        public Buildable Convert(DbElement element)
        {
            Size      size      = new Size();
            Position  position  = new Position();
            Direction direction = new Direction();

            size.Diameter = element.GetDouble(DbAttributeInstance.ROUT) - element.GetDouble(DbAttributeInstance.RINS);

            var q = new DbQualifier();

            q.Add(1);
            q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT);
            var pos = element.GetPosition(DbAttributeInstance.PPOS, q);

            position.X = pos.X;
            position.Y = pos.Y;
            position.Z = pos.Z;

            var d = element.GetDirection(DbAttributeInstance.PDIR, q);

            direction.X = d.ToString();
            direction.Y = d.ToString();
            direction.Z = d.ToString();

            //TODO: fix mess
            q = new DbQualifier();
            q.Add(2);
            q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT);
            Position  position2  = new Position();
            Direction direction2 = new Direction();

            pos         = element.GetPosition(DbAttributeInstance.PPOS, q);
            position2.X = pos.X;
            position2.Y = pos.Y;
            position2.Z = pos.Z;

            d            = element.GetDirection(DbAttributeInstance.PDIR, q);
            direction2.X = d.ToString();
            direction2.Y = d.ToString();
            direction2.Z = d.ToString();



            return(new Buildable(DbElementTypeInstance.SCTORUS, element, size, position, direction, position2, direction2));
        }
Esempio n. 3
0
        private void ExportTube(DbElement tubeEle, D3Transform transform, int color)
        {
            double ltLength = tubeEle.GetDouble(DbAttributeInstance.ITLE);

            if (ltLength <= 0.001)
            {
                return;
            }

            double   lbore = tubeEle.GetDoubleArray(DbAttributeInstance.PARA)[1];
            D3Vector dir   = null;

            DbElement prevEle = tubeEle.Previous;

            if (prevEle == null || !prevEle.IsValid)
            {
                DbElement branchEle = tubeEle.Owner;
                dir = transform.Multiply(GeometryUtility.ToD3VectorRef(branchEle.GetDirection(DbAttributeInstance.HDIR)));
            }
            else
            {
                int     leave = prevEle.GetInteger(DbAttributeInstance.LEAV);
                AxisDir ptax  = EvalDirection.Eval(prevEle, "P" + leave);
                if (ptax == null)
                {
                    return;
                }

                D3Transform eleTrans = transform.Multiply(GetTransform(prevEle));
                dir = eleTrans.Multiply(GeometryUtility.ToD3VectorRef(ptax.Dir));
            }

            D3Point pos = transform.Multiply(GeometryUtility.ToD3Point(tubeEle.GetPosition(DbAttributeInstance.ITPS)));

            pos.MoveBy(dir * (-ltLength / 2));

            Cylinder cyl = new Cylinder();

            cyl.Org    = new Point(pos);
            cyl.Height = new Point(dir).Mul(ltLength);
            cyl.Radius = lbore / 2.0;
            cyl.Color  = color;
            session.Save(cyl);
        }
Esempio n. 4
0
        public Buildable Convert(DbElement element)
        {
            Size      size      = new Size();
            Position  position  = new Position();
            Direction direction = new Direction();


            var q = new DbQualifier();

            q.Add(1);
            q.wrtQualifier = element.OwnerInHierarchyOfType(DbElementTypeInstance.EQUIPMENT);

            var nozzleConfig = new NozzleConfig();

            size.Diameter = element.GetDouble(DbAttributeInstance.PPBO, q);
            var description = element.GetString(DbAttributeInstance.DESC);

            if (string.IsNullOrWhiteSpace(description))
            {
                nozzleConfig.Coco = element.GetString(DbAttributeInstance.PPCO, q);
            }
            else
            {
                nozzleConfig.Coco = description;
            }

            var pos = element.GetPosition(DbAttributeInstance.PPOS, q);

            position.X = pos.X;
            position.Y = pos.Y;
            position.Z = pos.Z;

            var d = element.GetDirection(DbAttributeInstance.PDIR, q);

            direction.X = d.ToString();
            direction.Y = d.ToString();
            direction.Z = d.ToString();

            //TODO: handle multiple BLRFARRAYS

            var catref = DbElement.GetElement();

            if (element.GetValidRef(DbAttributeInstance.CATR, ref catref))
            {
                var catrefOfCatref = DbElement.GetElement();
                if (catref.GetValidRef(DbAttributeInstance.CATR, ref catrefOfCatref))
                {
                    DbElement[] blrfarray = new DbElement[5];
                    if (catrefOfCatref.GetValidRefArray(DbAttributeInstance.BLRF, ref blrfarray))
                    {
                        nozzleConfig.Blrfarray = blrfarray;
                    }

                    var attributes = catrefOfCatref.GetAttributes();
                    foreach (DbAttribute item in attributes)
                    {
                        Console.WriteLine(item.Description);
                    }


                    nozzleConfig.Parameters = catrefOfCatref.GetDoubleArray(DbAttributeInstance.PARA);

                    var dataset = DbElement.GetElement();
                    if (catrefOfCatref.GetValidRef(DbAttributeInstance.DTRE, ref dataset))
                    {
                        nozzleConfig.Dataset = dataset;
                    }
                    //if (!dataset.IsValid) {
                    //    var flanScom = MDB.CurrentMDB.FindElement("/EMFWBR0-40-0");
                    //    if (flanScom.GetValidRef(DbAttributeInstance.DTRE, ref dataset)) {
                    //        Console.WriteLine(dataset);
                    //        nozzleConfig.Dataset = dataset;
                    //    }
                    //}
                }
            }

            var name = element.Name().ToUpper();

            if (name.Contains("ARRIVE"))
            {
                nozzleConfig.Ppoint = 1;
            }
            else if (name.Contains("LEAVE"))
            {
                nozzleConfig.Ppoint = 2;
            }
            else if (name.Contains("P#"))
            {
                if (int.TryParse(name.Split('#').Last(), out int p))
                {
                    nozzleConfig.Ppoint = p;
                }
            }
            return(new Buildable(DbElementTypeInstance.NOZZLE, element, size, position, direction, nozzleConfig));
        }