public static dynamic GetTSObject(ModelObjectSelector dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Пример #2
0
        private void MallinnaLaatta()
        {
            ModelObjectSelector   mSelector = malli.GetModelObjectSelector();
            ModelObjectEnumerator enumer    = mSelector.GetAllObjects();

            for (int i = 0; i < enumer.GetSize(); i++)
            {
                ModelObject obj = enumer.Current;
                if (obj is ContourPlate)
                {
                    if (((ContourPlate)obj).Name == "LASKETTU_LAATTA")
                    {
                        ContourPlate laattaTemp = (ContourPlate)obj;
                        laattaTemp.Contour.ContourPoints[0] = new ContourPoint(new Point(0, 0, 3000), null);
                        laattaTemp.Contour.ContourPoints[1] = new ContourPoint(new Point(0, laatanKorkeus, 3000), null);
                        laattaTemp.Contour.ContourPoints[2] = new ContourPoint(new Point(laatanLeveys, laatanKorkeus, 3000), null);
                        laattaTemp.Contour.ContourPoints[3] = new ContourPoint(new Point(laatanLeveys, 0, 3000), null);
                        PoistaRaudoitus(laattaTemp);
                        laattaTemp.Modify();
                        malli.CommitChanges();
                        return;
                    }
                }
                enumer.MoveNext();
            }
            ContourPlate laatta = new ContourPlate();

            laatta.Name = "LASKETTU_LAATTA";
            ContourPoint vasenAlanurkka = new ContourPoint(new Point(0, 0, 3000), null);
            ContourPoint vasenYlanurkka = new ContourPoint(new Point(0, laatanKorkeus, 3000), null);
            ContourPoint oikeaYlanurkka = new ContourPoint(new Point(laatanLeveys, laatanKorkeus, 3000), null);
            ContourPoint oikeaAlanurkka = new ContourPoint(new Point(laatanLeveys, 0, 3000), null);

            laatta.AddContourPoint(vasenAlanurkka);
            laatta.AddContourPoint(vasenYlanurkka);
            laatta.AddContourPoint(oikeaYlanurkka);
            laatta.AddContourPoint(oikeaAlanurkka);

            laatta.Profile.ProfileString = Asetukset.LaatanPaksuus.ToString();
            if (!string.IsNullOrWhiteSpace(Asetukset.BetoninLujuus.ToString()))
            {
                laatta.Material.MaterialString = betonimateriaalit[Asetukset.BetoninLujuus];
            }
            else
            {
                laatta.Material.MaterialString = "Concrete_Undefined";
            }
            laatta.Position.Depth = Position.DepthEnum.FRONT;

            laatta.Insert();
            malli.CommitChanges();
        }
        /// <summary>
        /// Overload of Tekla's method, using an instance of <see cref="Geometry3d.OBB"/> as input parameter instead of 2 points.
        /// </summary>
        /// <param name="selector">Model object selector to select nearby objects.</param>
        /// <param name="box">Oriented bounding box as input.</param>
        /// <returns>Enumerator of model objects being near to given AABB.</returns>
        public static ModelObjectEnumerator GetObjectsByBoundingBox(this ModelObjectSelector selector, Geometry3d.OBB box)
        {
            var workPlaneHandler           = new Model.Model().GetWorkPlaneHandler();
            var currentTransformationPlane = workPlaneHandler.GetCurrentTransformationPlane();

            workPlaneHandler.SetCurrentTransformationPlane(new TransformationPlane(box.Center, box.Axis0, box.Axis1));
            var result = selector.GetObjectsByBoundingBox(
                MinPoint: new Geometry3d.Point(-box.Extent0, -box.Extent1, -box.Extent2),
                MaxPoint: new Geometry3d.Point(box.Extent0, box.Extent1, box.Extent2));

            workPlaneHandler.SetCurrentTransformationPlane(currentTransformationPlane);
            return(result);
        }
 /// <summary>
 /// Overload of Tekla's method, using an instance of <see cref="Geometry3d.AABB"/> as input parameter instead of 2 points.
 /// </summary>
 /// <param name="selector">Model object selector to select nearby objects.</param>
 /// <param name="box">Axis-aligned bounding box as input.</param>
 /// <returns>Enumerator of model objects being near to given AABB.</returns>
 public static ModelObjectEnumerator GetObjectsByBoundingBox(this ModelObjectSelector selector, Geometry3d.AABB box)
 {
     return(selector.GetObjectsByBoundingBox(box.MinPoint, box.MaxPoint));
 }
Пример #5
0
        private void btnConvert_Click(object sender, EventArgs e)
        {
            ModelObjectSelector mos = new ModelObjectSelector();

            TSM.ModelObjectEnumerator moe = mos.GetSelectedObjects();

            moe.SelectInstances = false;

            while (moe.MoveNext())
            {
                if (moe.Current is TSM.Part)
                {
                    TSM.Part part = moe.Current as TSM.Part;

                    // this method needs to be called to properly fill all the properties of the part
                    part.Select();

                    double partLength = 0.0;
                    double partHeight = 0.0;
                    double partWidth  = 0.0;
                    part.GetReportProperty("LENGTH", ref partLength);
                    part.GetReportProperty("HEIGHT", ref partHeight);
                    part.GetReportProperty("WIDTH", ref partWidth);

                    TSM.ModelObjectEnumerator MyAllBooleans = part.GetBooleans();
                    TSM.ModelObjectEnumerator MyAllBolts    = part.GetBolts();
                    TSM.ModelObject           MyFather      = part.GetFatherComponent();


                    TSG.CoordinateSystem coordinateSystem = part.GetCoordinateSystem();
                    TSM.WorkPlaneHandler planeHandler     = model.GetWorkPlaneHandler();

                    // before we create a new plane we need to store the old one
                    TSM.TransformationPlane original  = planeHandler.GetCurrentTransformationPlane();
                    TSM.TransformationPlane partPlane = new TSM.TransformationPlane(coordinateSystem);
                    planeHandler.SetCurrentTransformationPlane(partPlane);

                    //this.DrawCoordinateSystem();

                    TSG.Point p1 = new TSG.Point(0, partHeight / 2, 0);
                    TSG.Point p2 = new TSG.Point(partLength, partHeight / 2, 0);
                    TSG.Point p3 = new TSG.Point(partLength, -partHeight / 2, 0);
                    TSG.Point p4 = new TSG.Point(0, -partHeight / 2, 0);

                    TSM.ContourPlate CP            = new TSM.ContourPlate();
                    TSM.ContourPoint conturePoint1 = new TSM.ContourPoint(p1, null);
                    TSM.ContourPoint conturePoint2 = new TSM.ContourPoint(p2, null);
                    TSM.ContourPoint conturePoint3 = new TSM.ContourPoint(p3, null);
                    TSM.ContourPoint conturePoint4 = new TSM.ContourPoint(p4, null);

                    CP.AddContourPoint(conturePoint1);
                    CP.AddContourPoint(conturePoint2);
                    CP.AddContourPoint(conturePoint3);
                    CP.AddContourPoint(conturePoint4);
                    CP.Name   = "NEM";
                    CP.Finish = "xxx";
                    CP.Profile.ProfileString   = "PL" + partWidth;
                    CP.Material.MaterialString = "S235";
                    CP.Class = "1";

                    CP.Insert();

                    while (MyAllBooleans.MoveNext())
                    {
                        try
                        {
                            TSM.BooleanPart partBooleans = MyAllBooleans.Current as TSM.BooleanPart;

                            TSM.Part partBool = partBooleans.OperativePart as TSM.Part;
                            partBool.Class = TSM.BooleanPart.BooleanOperativeClassName;
                            partBool.Insert();

                            TSM.BooleanPart myboolpart = new TSM.BooleanPart();
                            myboolpart.Father = CP;
                            myboolpart.SetOperativePart(partBool);
                            myboolpart.Insert();
                            partBool.Delete();
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }


                    while (MyAllBolts.MoveNext())
                    {
                        try
                        {
                            if (MyAllBolts.Current is TSM.BoltGroup)
                            {
                                TSM.BoltGroup b = MyAllBolts.Current as TSM.BoltGroup;

                                TSM.Part toBolted = b.PartToBeBolted as TSM.Part;
                                TSM.Part toBolt   = b.PartToBoltTo as TSM.Part;
                                if (toBolted.Identifier.ID == toBolt.Identifier.ID)
                                {
                                    b.PartToBeBolted = CP;
                                    b.PartToBoltTo   = CP;
                                }
                                else if (toBolted.Identifier.ID == part.Identifier.ID)
                                {
                                    b.PartToBoltTo.GetBolts();
                                    b.PartToBeBolted = CP;
                                }
                                else
                                {
                                    b.PartToBoltTo = CP;
                                    b.PartToBeBolted.GetBolts();
                                }
                                b.Insert();
                            }
                        }
                        catch (Exception)
                        {
                            throw;
                        }
                    }

                    if (MyFather != null)
                    {
                        TSM.ModelObjectEnumerator elementOfComponenet = MyFather.GetChildren();
                        while (elementOfComponenet.MoveNext())
                        {
                            TSM.Part element = elementOfComponenet.Current as TSM.Part;
                            try
                            {
                                if (element is TSM.Part)
                                {
                                    if (element.Identifier.ID == part.Identifier.ID)
                                    {
                                        element = CP;

                                        element.Modify();
                                    }
                                    else
                                    {
                                        continue;
                                    }
                                }
                                else
                                {
                                    continue;
                                }
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }
                    }



                    part.Delete();
                    planeHandler.SetCurrentTransformationPlane(original);
                }
            }

            this.model.CommitChanges();
        }