コード例 #1
0
    public List <LineSegment> new_get_lower_edge(Part Gpart)
    {
        List <LineSegment> lineSegmentList = new List <LineSegment>();
        Point point1 = new Point();
        Point point2 = new Point();
        Point point3 = new Point();
        Point point4 = new Point();
        Point point5 = new Point();

        Tekla.Structures.Model.Solid solid      = Gpart.GetSolid(Tekla.Structures.Model.Solid.SolidCreationTypeEnum.PLANECUTTED);
        EdgeEnumerator      edgeEnumerator      = solid.GetEdgeEnumerator();
        Point               maximumPoint        = solid.MaximumPoint;
        Point               minimumPoint        = solid.MinimumPoint;
        TransformationPlane transformationPlane = this.myModel.GetWorkPlaneHandler().GetCurrentTransformationPlane();
        Point               point6 = transformationPlane.TransformationMatrixToGlobal.Transform(maximumPoint);
        Point               point7 = transformationPlane.TransformationMatrixToGlobal.Transform(minimumPoint);

        if (point6.Z > point7.Z)
        {
            point3 = minimumPoint;
        }
        else if (point6.Z < point7.Z)
        {
            point3 = maximumPoint;
        }
        if (solid != null)
        {
            while (edgeEnumerator.MoveNext())
            {
                Edge current = edgeEnumerator.Current as Edge;
                if (current.StartPoint.Z - current.EndPoint.Z == 0.0 && current.StartPoint.Z == point3.Z)
                {
                    LineSegment lineSegment = new LineSegment(current.StartPoint, current.EndPoint);
                    lineSegmentList.Add(lineSegment);
                }
            }
        }
        return(lineSegmentList);
    }
コード例 #2
0
    public OBB CreateObb(Part currentBeam)
    {
        OBB obb = (OBB)null;

        if (currentBeam != null)
        {
            WorkPlaneHandler workPlaneHandler = this.myModel.GetWorkPlaneHandler();
            this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
            Tekla.Structures.Model.Solid solid1 = currentBeam.GetSolid();
            Point            center             = this.CallulateCenterPoint(solid1.MaximumPoint, solid1.MinimumPoint);
            CoordinateSystem coordinateSystem   = currentBeam.GetCoordinateSystem();
            workPlaneHandler.SetCurrentTransformationPlane(new TransformationPlane(coordinateSystem));
            Tekla.Structures.Model.Solid solid2 = currentBeam.GetSolid();
            Point  maximumPoint = solid2.MaximumPoint;
            Point  minimumPoint = solid2.MinimumPoint;
            double extent0      = (maximumPoint.X - minimumPoint.X) / 2.0;
            double extent1      = (maximumPoint.Y - minimumPoint.Y) / 2.0;
            double extent2      = (maximumPoint.Z - minimumPoint.Z) / 2.0;
            obb = new OBB(center, coordinateSystem.AxisX, coordinateSystem.AxisY, coordinateSystem.AxisX.Cross(coordinateSystem.AxisY), extent0, extent1, extent2);
            this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
        }
        return(obb);
    }
コード例 #3
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            try
            {
                TSM.Model          model          = new TSM.Model();
                TSD.DrawingHandler drawingHandler = new TSD.DrawingHandler();
                TSG.Vector         UpDirection    = new TSG.Vector(0.0, 0.0, 1.0);
                TSD.Size           A3             = new TSD.Size(410, 287);

                TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane();
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane());

                TSM.ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects();
                while (modelObjectEnum.MoveNext())
                {
                    if (modelObjectEnum.Current is Tekla.Structures.Model.Part)
                    {
                        TSM.Part selectedPart = (TSM.Part)modelObjectEnum.Current;

                        string USER_FIELD_3 = "", USER_FIELD_4 = "";
                        selectedPart.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3);
                        selectedPart.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4);
                        USER_FIELD_4 = USER_FIELD_4.Replace("(?)", "");
                        selectedPart.SetUserProperty("USER_FIELD_4", USER_FIELD_4);

                        if (USER_FIELD_3 == "M")
                        {
                            TSD.Drawing gaDrawing = new TSD.GADrawing("BRAD-Mod-Ass", A3);
                            gaDrawing.Name   = selectedPart.Name;
                            gaDrawing.Title1 = "SITEWORK";
                            gaDrawing.Title2 = USER_FIELD_3 + USER_FIELD_4;
                            gaDrawing.Title3 = "";
                            gaDrawing.Insert();
                            drawingHandler.SetActiveDrawing(gaDrawing, false);

                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane(selectedPart.GetCoordinateSystem()));
                            TSM.Solid tsolid  = selectedPart.GetSolid();
                            TSG.Point tsMinPt = tsolid.MinimumPoint;
                            TSG.Point tsMaxPt = tsolid.MaximumPoint;
                            model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new Tekla.Structures.Model.TransformationPlane());

                            if (selectedPart.Name.Contains("BEAM"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX) * -1.0;
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                PlanViewCoordSys.AxisX = tempVector.Cross(UpDirection);
                                PlanViewCoordSys.AxisY = tempVector;

                                TSM.Solid solid = selectedPart.GetSolid();

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisX = tempVector.Cross(UpDirection).GetNormal();
                                FrontViewCoordSys.AxisY = UpDirection.GetNormal();

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 2));
                                FrontView.Modify();
                            }
                            if (selectedPart.Name.Contains("COLUMN"))
                            {
                                TSG.CoordinateSystem ModelObjectCoordSys = selectedPart.GetCoordinateSystem();
                                TSG.CoordinateSystem PlanViewCoordSys    = new TSG.CoordinateSystem();
                                PlanViewCoordSys.Origin = new TSG.Point(ModelObjectCoordSys.Origin);
                                PlanViewCoordSys.AxisX  = new TSG.Vector(ModelObjectCoordSys.AxisX);
                                PlanViewCoordSys.AxisY  = new TSG.Vector(ModelObjectCoordSys.AxisY);

                                TSG.Vector tempVector = (PlanViewCoordSys.AxisX.Cross(UpDirection));
                                if (tempVector == new TSG.Vector())
                                {
                                    tempVector = (ModelObjectCoordSys.AxisY.Cross(UpDirection));
                                }

                                TSG.AABB aabbPlanView = new TSG.AABB();
                                aabbPlanView.MinPoint = new TSG.Point(-50, tsMinPt.Y - 50, tsMinPt.Z - 50);
                                aabbPlanView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Y + 50, tsMaxPt.Z + 50);

                                TSD.View PlanView = new TSD.View(gaDrawing.GetSheet(), PlanViewCoordSys, PlanViewCoordSys, aabbPlanView, "BRAD-Mod-Ass");
                                PlanView.Name  = "TOP";
                                PlanView.Scale = 10;
                                PlanView.Attributes.Shortening.CutParts      = true;
                                PlanView.Attributes.Shortening.MinimumLength = 1200;
                                PlanView.Attributes.Shortening.Offset        = 0.5;
                                PlanView.Origin = new TSG.Point(100, 200);
                                PlanView.Insert();
                                PlanView.Attributes.FixedViewPlacing = true;
                                PlanView.Modify();

                                TSG.CoordinateSystem FrontViewCoordSys = (TSG.CoordinateSystem)PlanViewCoordSys;
                                FrontViewCoordSys.AxisY = new TSG.Vector(ModelObjectCoordSys.AxisY).Cross(UpDirection) * -1;

                                TSG.AABB aabbFrontView = new TSG.AABB();
                                aabbFrontView.MinPoint = new TSG.Point(-50, tsMinPt.Z - 50, tsMinPt.Y - 50);
                                aabbFrontView.MaxPoint = new TSG.Point(tsMaxPt.X + 50, tsMaxPt.Z + 50, tsMaxPt.Y + 50);

                                TSD.View FrontView = new TSD.View(gaDrawing.GetSheet(), FrontViewCoordSys, FrontViewCoordSys, aabbFrontView, "BRAD-Mod-Ass");
                                FrontView.Name  = "FRONT";
                                FrontView.Scale = 10;
                                FrontView.Attributes.Shortening.CutParts      = true;
                                FrontView.Attributes.Shortening.MinimumLength = 1200;
                                FrontView.Attributes.Shortening.Offset        = 0.5;
                                FrontView.Origin = new TSG.Point(100, (200 - FrontView.Height - 30));
                                FrontView.Insert();
                                FrontView.Attributes.FixedViewPlacing = true;
                                FrontView.Modify();
                            }
                            drawingHandler.CloseActiveDrawing(true);
                        }
                    }
                }
                MessageBox.Show("Drawings Created");
                model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current);
            }
            catch { }
        }
コード例 #4
0
    public List <LineSegment> Get_Lower_face_edge(Part GPart)
    {
        this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
        Tekla.Structures.Model.Solid solid = GPart.GetSolid();
        EdgeEnumerator     edgeEnumerator  = solid.GetEdgeEnumerator();
        List <LineSegment> lineSegmentList = new List <LineSegment>();

        if (solid != null)
        {
            while (edgeEnumerator.MoveNext())
            {
                Edge        current     = edgeEnumerator.Current as Edge;
                LineSegment lineSegment = new LineSegment(current.StartPoint, current.EndPoint);
                if (Math.Abs(lineSegment.Point1.Z - lineSegment.Point2.Z) < 1.0)
                {
                    lineSegmentList.Add(lineSegment);
                }
            }
            for (int index1 = 0; index1 < lineSegmentList.Count; ++index1)
            {
                LineSegment lineSegment1 = lineSegmentList[index1];
                for (int index2 = 0; index2 < lineSegmentList.Count; ++index2)
                {
                    LineSegment lineSegment2 = lineSegmentList[index2];
                    if (Math.Abs(lineSegment1.Point1.X - lineSegment2.Point1.X) < 1.0 && Math.Abs(lineSegment1.Point1.Y - lineSegment2.Point1.Y) < 1.0 && lineSegment1.Point1.Z != lineSegment2.Point1.Z)
                    {
                        if (lineSegment2.Point1.Z > lineSegment1.Point1.Z)
                        {
                            lineSegmentList.Remove(lineSegment2);
                        }
                        else
                        {
                            lineSegmentList.Remove(lineSegment1);
                        }
                    }
                }
            }
            for (int index1 = 0; index1 < lineSegmentList.Count; ++index1)
            {
                LineSegment lineSegment1 = lineSegmentList[index1];
                for (int index2 = 0; index2 < lineSegmentList.Count; ++index2)
                {
                    LineSegment lineSegment2 = lineSegmentList[index2];
                    Point       point1       = lineSegment2.Point1;
                    LineSegment lineSegment3 = new LineSegment(lineSegment2.Point2, point1);
                    if (Math.Abs(lineSegment1.Point1.X - lineSegment3.Point1.X) < 1.0 && Math.Abs(lineSegment1.Point1.Y - lineSegment3.Point1.Y) < 1.0 && lineSegment1.Point1.Z != lineSegment3.Point1.Z)
                    {
                        if (lineSegment3.Point1.Z > lineSegment1.Point1.Z)
                        {
                            lineSegmentList.Remove(lineSegment2);
                        }
                        else
                        {
                            lineSegmentList.Remove(lineSegment1);
                        }
                    }
                }
            }
        }
        return(lineSegmentList);
    }
コード例 #5
0
 public void createconnection(Part main, ArrayList secondries)
 {
     foreach (Identifier secondry in secondries)
     {
         Part        part1    = main;
         Part        part2    = (Part)this.myModel.SelectModelObject(secondry);
         List <Beam> beamList = new List <Beam>();
         this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(part1.GetCoordinateSystem()));
         Tekla.Structures.Model.Solid solid1 = part1.GetSolid();
         Point maximumPoint = solid1.MaximumPoint;
         Point minimumPoint = solid1.MinimumPoint;
         Tekla.Structures.Model.Solid solid2 = part2.GetSolid();
         double num  = 0.0;
         Type   type = part1.GetType();
         if (type.Name == "Beam")
         {
             num = solid2.MaximumPoint.X;
         }
         else if (type.Name == "ContourPlate")
         {
             num = solid2.MaximumPoint.Y;
         }
         Assembly assembly = part2.GetAssembly();
         assembly.SetMainPart(part2);
         ArrayList secondaries = assembly.GetSecondaries();
         Point     point1      = new Point();
         Point     point2      = new Point();
         Point     point3      = new Point();
         Point     point4      = new Point();
         if (type.Name == "Beam")
         {
             point1 = new Point(num, maximumPoint.Y + this.data.positive_Y + this.data.Plate_h, maximumPoint.Z + this.data.negative_X + this.data.Plate_h);
             point2 = new Point(num, maximumPoint.Y + this.data.positive_Y + this.data.Plate_h, minimumPoint.Z + this.data.positive_X * -1.0 - this.data.Plate_h);
             point3 = new Point(num, minimumPoint.Y + this.data.negative_Y * -1.0 - this.data.Plate_h, minimumPoint.Z + this.data.positive_X * -1.0 - this.data.Plate_h);
             point4 = new Point(num, minimumPoint.Y + this.data.negative_Y * -1.0 - this.data.Plate_h, maximumPoint.Z + this.data.negative_X + this.data.Plate_h);
         }
         else if (type.Name == "ContourPlate")
         {
             point1 = new Point(maximumPoint.X + this.data.positive_Y + this.data.Plate_h, num, maximumPoint.Z + this.data.negative_X + this.data.Plate_h);
             point2 = new Point(maximumPoint.X + this.data.positive_Y + this.data.Plate_h, num, minimumPoint.Z + this.data.positive_X * -1.0 - this.data.Plate_h);
             point3 = new Point(minimumPoint.X + this.data.negative_Y * -1.0 - this.data.Plate_h, num, minimumPoint.Z + this.data.positive_X * -1.0 - this.data.Plate_h);
             point4 = new Point(minimumPoint.X + this.data.negative_Y * -1.0 - this.data.Plate_h, num, maximumPoint.Z + this.data.negative_X + this.data.Plate_h);
         }
         for (int index = 0; index < secondaries.Count; ++index)
         {
             if (secondaries[index].GetType().Name == "PolyBeam")
             {
                 secondaries.RemoveAt(secondaries.IndexOf(secondaries[index]));
                 if (index >= 0)
                 {
                     --index;
                     continue;
                 }
                 if (secondaries.Count == 0)
                 {
                     break;
                 }
             }
             Part Part_To_Be_Cut = (Part)secondaries[index];
             if (Part_To_Be_Cut.Class != "211")
             {
                 this.CreateCut(point1, point2, point3, point4, Part_To_Be_Cut).Delete();
             }
         }
         ContourPlate cut  = this.CreateCut(point1, point2, point3, point4, part2);
         OBB          obb1 = new OBB();
         OBB          obb2 = this.CreateObb((Part)cut);
         foreach (LineSegment lineSegment in this.Get_Lower_face_edge(part2))
         {
             if (obb2.Intersects(lineSegment))
             {
                 try
                 {
                     LineSegment obb3 = Intersection.LineSegmentToObb(lineSegment, obb2);
                     Beam        beam = this.insert_toeplate(obb3.Point1, obb3.Point2);
                     this.insert_weld(part2, (Part)beam);
                     beamList.Add(beam);
                 }
                 catch (Exception)
                 {
                 }
             }
         }
         cut.Delete();
         for (int index = 0; index < beamList.Count; ++index)
         {
             try
             {
                 this.part_cut((Part)beamList[index], (Part)beamList[index + 1]);
             }
             catch (Exception)
             {
             }
         }
         try
         {
             this.part_cut((Part)beamList[beamList.Count - 1], (Part)beamList[0]);
         }
         catch (Exception)
         {
         }
         for (int index = 0; index < secondaries.Count; ++index)
         {
             if (secondaries[index] is Beam beam && beam.Class == "211")
             {
                 secondaries.Remove((object)beam);
                 index = -1;
             }
         }
         foreach (Part GPart in secondaries)
         {
             foreach (LineSegment lineSegment in this.Get_Lower_face_edge(GPart))
             {
                 if (obb2.Intersects(lineSegment))
                 {
                     try
                     {
                         LineSegment obb3 = Intersection.LineSegmentToObb(lineSegment, obb2);
                         Beam        beam = this.insert_toeplate(obb3.Point1, obb3.Point2);
                         beamList.Add(beam);
                     }
                     catch (Exception)
                     {
                     }
                 }
             }
         }
         for (int index1 = 0; index1 <= beamList.Count - 1; ++index1)
         {
             Beam beam1 = beamList[index1];
             for (int index2 = index1 + 1; index2 <= beamList.Count - 1; ++index2)
             {
                 Beam beam2 = beamList[index2];
                 this.combine_beams_have_same_vector((Part)beam1, (Part)beam2);
             }
         }
     }
 }
コード例 #6
0
        public override bool Run(List <InputDefinition> Input)
        {
            try
            {
                GetvaluesFormDialog();
                var identifien1 = (Identifier)Input[0].GetInput();
                var identifien2 = (Identifier)Input[1].GetInput();
                var object1     = new tsm.Model().SelectModelObject(identifien1) as tsm.ModelObject;
                var object2     = new tsm.Model().SelectModelObject(identifien2) as tsm.ModelObject;
                //-------------------------------------------------------------------------
                tsm.RebarGroup rebargroup0 = null;
                tsm.RebarGroup rebargroup1 = null;
                while (rebargroup0 == null & rebargroup1 == null)
                {
                    try
                    {
                        tsm.ModelObject obj0 = object1;
                        if (obj0 as tsm.RebarGroup != null)
                        {
                            rebargroup0 = obj0 as tsm.RebarGroup;
                            r0          = Double.Parse(rebargroup0.Size);
                            sol0        = rebargroup0.GetSolid();
                            maxx0       = sol0.MaximumPoint.X;
                            maxy0       = sol0.MaximumPoint.Y;
                            maxz0       = sol0.MaximumPoint.Z;
                            minx0       = sol0.MinimumPoint.X;
                            miny0       = sol0.MinimumPoint.Y;
                            minz0       = sol0.MinimumPoint.Z;
                        }
                        tsm.ModelObject obj1 = object2;
                        if (obj1 as tsm.RebarGroup != null)
                        {
                            rebargroup1 = obj1 as tsm.RebarGroup;
                            r1          = Double.Parse(rebargroup1.Size);
                            onplan0     = Double.Parse(rebargroup1.OnPlaneOffsets[0].ToString());
                            sol1        = rebargroup1.GetSolid();
                            maxx1       = sol1.MaximumPoint.X;
                            maxy1       = sol1.MaximumPoint.Y;
                            maxz1       = sol1.MaximumPoint.Z;
                            minx1       = sol1.MinimumPoint.X;
                            miny1       = sol1.MinimumPoint.Y;
                            minz1       = sol1.MinimumPoint.Z;
                        }
                        if (r0 >= r1)
                        {
                            r = r1;
                        }
                        else
                        {
                            r = r0;
                        }
                        if (_Combo_Spacing == "Auto")
                        {
                            if (r == 12 || r == 14)
                            {
                                _Spacing = r + 2;
                            }
                            else if (r == 8 || r == 10 || r > 14 & r <= 12)
                            {
                                _Spacing = r + 3;
                            }
                            else if (r == 25)
                            {
                                _Spacing = r + 4;
                            }
                            else
                            {
                                _Spacing = r + 5;
                            }
                        }
                        //------------------------------------------------------------------
                        poly0.Points.Add(new g3d.Point(minx0, maxy0 - r / 2, maxz0 - r / 2));
                        poly0.Points.Add(new g3d.Point(maxx0 - _LapLenght * r - _CrankRatio * r - 50, maxy0 - r / 2, maxz0 - r / 2));
                        poly0.Points.Add(new g3d.Point(maxx0 - _LapLenght * r - 50, maxy0 - r / 2, maxz0 - r / 2 - _Spacing));
                        poly0.Points.Add(new g3d.Point(maxx0, maxy0 - r / 2, maxz0 - r / 2 - _Spacing));

                        poly1.Points.Add(new g3d.Point(maxx0 - _LapLenght * r, maxy1 - r / 2, maxz1 - r / 2));
                        poly1.Points.Add(new g3d.Point(maxx1, maxy1 - r / 2, maxz1 - r / 2));
                        //-------------------------------------------------------------------
                        //end tạo điểm polygon
                        rebargroup0.Polygons.Clear();
                        rebargroup0.Polygons.Add(poly0);
                        rebargroup0.OnPlaneOffsets.Clear();
                        rebargroup0.OnPlaneOffsets.Add(0.0);

                        rebargroup0.Modify();

                        rebargroup1.Polygons.Clear();
                        rebargroup1.Polygons.Add(poly1);
                        rebargroup1.OnPlaneOffsets.Clear();
                        rebargroup1.OnPlaneOffsets.Add(0.0);
                        rebargroup1.Modify();
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(true);
        }
コード例 #7
0
 public void createconnection(Point center_point, ArrayList Gratting_assembly_arraylist)
 {
     foreach (Identifier ID in Gratting_assembly_arraylist)
     {
         Part part1 = (Part)this.myModel.SelectModelObject(ID);
         this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
         this.myModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane());
         this.Get_Lower_face_edge(part1);
         string Partprofile1;
         string Partprofile2;
         if (this.data.holeType == 0)
         {
             Partprofile1 = "ROD" + (this.data.holeDiam - this.data.Plate_h).ToString();
             Partprofile2 = "ROD" + this.data.holeDiam.ToString();
         }
         else
         {
             Partprofile1 = this.data.hole_L.ToString() + "*" + this.data.hole_w.ToString();
             Partprofile2 = Partprofile1;
         }
         Assembly assembly = part1.GetAssembly();
         assembly.SetMainPart(part1);
         ArrayList secondaries = assembly.GetSecondaries();
         for (int index = 0; index < secondaries.Count; ++index)
         {
             if (secondaries[index].GetType().Name == "PolyBeam")
             {
                 secondaries.RemoveAt(secondaries.IndexOf(secondaries[index]));
                 if (index > 0)
                 {
                     --index;
                 }
                 else
                 {
                     index = 0;
                 }
                 if (secondaries.Count == 0)
                 {
                     break;
                 }
             }
             if (((Part)secondaries[index]).Class != "211")
             {
                 this.CreateCut(center_point, (Part)secondaries[index], Partprofile2).Delete();
             }
         }
         Beam cut1 = this.CreateCut(center_point, part1, Partprofile1);
         OBB  obb1 = this.CreateObb((Part)cut1);
         List <LineSegment> lowerFaceEdge   = this.Get_Lower_face_edge(part1);
         List <Beam>        beamList        = new List <Beam>();
         List <LineSegment> lineSegmentList = new List <LineSegment>();
         if (this.data.holeType == 0)
         {
             Point point1 = new Point();
             Point point2 = new Point();
             foreach (LineSegment lineSegment in lowerFaceEdge)
             {
                 if (obb1.Intersects(lineSegment))
                 {
                     LineSegment obb2 = Intersection.LineSegmentToObb(lineSegment, obb1);
                     lineSegmentList.Add(obb2);
                 }
             }
             Point point1_1 = lineSegmentList[lineSegmentList.Count / 2].Point1;
             List <LineSegment>           lowerEdge = this.new_get_lower_edge(part1);
             ArrayList                    arrayList = new ArrayList();
             List <Point>                 pointList = new List <Point>();
             Tekla.Structures.Model.Solid solid     = cut1.GetSolid();
             foreach (LineSegment line in lowerEdge)
             {
                 if ((uint)solid.Intersect(line).Count > 0U)
                 {
                     foreach (object obj in solid.Intersect(line))
                     {
                         pointList.Add(obj as Point);
                     }
                 }
             }
             Point P1 = pointList[0];
             Point P2 = pointList[pointList.Count - 1];
             if (point1_1 == P1 || point1_1 == P2)
             {
                 point1_1 = lineSegmentList[lineSegmentList.Count / 2 - 1].Point1;
             }
             Chamfer C = new Chamfer();
             C.Type = Chamfer.ChamferTypeEnum.CHAMFER_ARC_POINT;
             PolyBeam polyBeam = new PolyBeam();
             polyBeam.Profile.ProfileString   = "PL" + this.data.Plate_b.ToString() + "*" + this.data.Plate_h.ToString();
             polyBeam.Position.Depth          = Position.DepthEnum.FRONT;
             polyBeam.Position.Plane          = Position.PlaneEnum.MIDDLE;
             polyBeam.Position.Rotation       = Position.RotationEnum.TOP;
             polyBeam.Position.DepthOffset    = this.data.offset;
             polyBeam.Material.MaterialString = this.data.Plate_matrial;
             polyBeam.PartNumber.Prefix       = this.data.Pos_1;
             polyBeam.PartNumber.StartNumber  = this.data.Plate_pos2;
             polyBeam.Name = this.data.Plate_name;
             polyBeam.AddContourPoint(new ContourPoint(P1, (Chamfer)null));
             polyBeam.AddContourPoint(new ContourPoint(point1_1, C));
             polyBeam.AddContourPoint(new ContourPoint(P2, (Chamfer)null));
             polyBeam.Insert();
             Beam cut2 = this.CreateCut(center_point, part1, Partprofile2);
             this.insert_weld(part1, (Part)polyBeam);
             cut1.Delete();
             cut2.Delete();
             ModelObjectEnumerator booleans = polyBeam.GetBooleans();
             while (booleans.MoveNext())
             {
                 (booleans.Current as BooleanPart).Delete();
             }
         }
         else
         {
             foreach (LineSegment lineSegment in lowerFaceEdge)
             {
                 if (obb1.Intersects(lineSegment))
                 {
                     try
                     {
                         LineSegment obb2 = Intersection.LineSegmentToObb(lineSegment, obb1);
                         Beam        beam = this.insert_toeplate(obb2.Point1, obb2.Point2);
                         this.insert_weld(part1, (Part)beam);
                         beamList.Add(beam);
                     }
                     catch (Exception)
                     {
                     }
                 }
             }
             cut1.Delete();
             foreach (Part part2 in beamList)
             {
                 ModelObjectEnumerator booleans = part2.GetBooleans();
                 while (booleans.MoveNext())
                 {
                     (booleans.Current as BooleanPart).Delete();
                 }
             }
             for (int index = 0; index < beamList.Count; ++index)
             {
                 try
                 {
                     this.part_cut((Part)beamList[index], (Part)beamList[index + 1]);
                 }
                 catch (Exception)
                 {
                 }
             }
             try
             {
                 this.part_cut((Part)beamList[beamList.Count - 1], (Part)beamList[0]);
             }
             catch (Exception)
             {
             }
             for (int index = 0; index < secondaries.Count; ++index)
             {
                 Beam beam = secondaries[index] as Beam;
                 if (beam.Class == "211")
                 {
                     secondaries.Remove((object)beam);
                     index = -1;
                 }
             }
             foreach (Part GPart in secondaries)
             {
                 foreach (LineSegment lineSegment in this.Get_Lower_face_edge(GPart))
                 {
                     if (obb1.Intersects(lineSegment))
                     {
                         try
                         {
                             LineSegment obb2 = Intersection.LineSegmentToObb(lineSegment, obb1);
                             Beam        beam = this.insert_toeplate(obb2.Point1, obb2.Point2);
                             beamList.Add(beam);
                         }
                         catch (Exception)
                         {
                         }
                     }
                 }
             }
             for (int index1 = 0; index1 <= beamList.Count - 1; ++index1)
             {
                 Beam beam1 = beamList[index1];
                 for (int index2 = index1 + 1; index2 <= beamList.Count - 1; ++index2)
                 {
                     Beam beam2 = beamList[index2];
                     this.combine_beams_have_same_vector((Part)beam1, (Part)beam2);
                 }
             }
         }
     }
 }