public void ImprintCopiedEdgeReference()
        {
            var imprint = TestGeomGenerator.CreateImprint();

            imprint.Depth = 2.5;
            imprint.Mode  = Imprint.ImprintMode.Raise;
            Assert.IsTrue(imprint.Make(Shape.MakeFlags.None));

            var edges = imprint.GetBRep().Edges();

            var chamfer = Chamfer.Create(imprint.Body);

            chamfer.Mode  = Chamfer.ChamferModes.Symmetric;
            chamfer.Edges = new[]
            {
                imprint.GetSubshapeReference(edges[9]),
                imprint.GetSubshapeReference(edges[14])
            };
            chamfer.Distance       = 1;
            chamfer.SecondDistance = 1;

            Assert.IsNotNull(chamfer.Edges[0]);
            Assert.IsNotNull(chamfer.Edges[1]);
            Assert.AreNotEqual(chamfer.Edges[0], chamfer.Edges[1], "Double edge references!");

            Assert.IsTrue(chamfer.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(chamfer, Path.Combine(_BasePath, "ImprintCopiedEdge")));
        }
        public void EdgeSelection()
        {
            var ctx = Context.Current;

            var box  = Box.Create(10.0, 10.0, 5.0);
            var body = Body.Create(box);

            ctx.ViewportController.ZoomFitAll();

            var shape = Chamfer.Create(body);

            shape.Distance = 2.0;
            var tool = new EdgeModifierTool(shape);

            ctx.WorkspaceController.StartTool(tool);

            Assert.Multiple(() =>
            {
                ctx.MoveTo(139, 252);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EdgeSelection1"));

                ctx.SelectAt(139, 252);
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EdgeSelection2"));

                tool.Stop();
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EdgeSelection3"));
            });
        }
 public static dynamic GetTSObject(Chamfer dynObject)
 {
     if (dynObject is null)
     {
         return(null);
     }
     return(dynObject.teklaObject);
 }
Esempio n. 4
0
        public void ChamferSparsityTest()
        {
            Console.WriteLine("Begin Chamfer Sparsity Test");
            var chamfer  = new[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            var expected = chamfer.Sum();
            var actual   = Chamfer.Sparsity(chamfer);

            Assert.IsTrue(expected == actual);
            Console.WriteLine("Sparsity Calculated Successfully");
        }
Esempio n. 5
0
        public void ChamferScaleTest()
        {
            Console.WriteLine("Chamfer Scaling Test");
            var chamfer   = new int[] { 0, 1, 2, 3, 4, 3, 2, 1, 0, 1, 0, 1, 2, 3, 2, 1, 0, 1, 2, 1, 0 };
            var largeSize = chamfer.Length * 2;
            var actual    = Chamfer.ScaleChamfer(chamfer, largeSize);

            Assert.IsTrue(actual.Length == 2 * chamfer.Length);
            Assert.IsTrue(actual[16] == 0);
            Console.WriteLine("Chamfer Test Scaling Successful");
        }
Esempio n. 6
0
        public void ChamferCalculationTest()
        {
            Console.WriteLine("Chamfer Testing Begin...");
            var features = new double[] { 0, 0, 10, 0, 0, 0, 10, 10, 0, 10 };
            var expected = new double[] { 0, 1, 0, 1, 2, 1, 0, 0, 1, 0 };
            var actual   = Chamfer.Measure(features);

            Assert.IsTrue(expected.Length == actual.Length);
            for (int ii = 0; ii < features.Length; ii++)
            {
                Assert.IsTrue(Math.Abs(expected[ii] - actual[ii]) < 0.001);
            }
            Console.WriteLine("Chamfer Successful");
        }
Esempio n. 7
0
        // Fase am Ende des Schraubenschaftes
        public void ErzeugeFase(MetrischeGewindegroesse m)
        {
            hsp_catiaPart.Part.InWorkObject = hsp_catiaPart.Part.MainBody;

            ShapeFactory catshapeFactoryFase = (ShapeFactory)hsp_catiaPart.Part.ShapeFactory;

            Reference reference1 = hsp_catiaPart.Part.CreateReferenceFromBRepName(
                "REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;1)));None:();Cf11:());Face:(Brp:(Pad.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", SchaftPad);

            SchaftFase = catshapeFactoryFase.AddNewChamfer(reference1, CatChamferPropagation.catTangencyChamfer, CatChamferMode.catLengthAngleChamfer, CatChamferOrientation.catNoReverseChamfer, m.fase, 45);

            SchaftFase.set_Name("Fase");
            hsp_catiaPart.Part.Update();
        }
Esempio n. 8
0
        public void ChamferSimilarityTest()
        {
            Console.WriteLine("Begin Chamfer Similarity Test");

            Console.WriteLine("Begin Chamfer Similarity Test with Equal Size Arrays");
            var c1 = new[] { 0, 1, 2, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 };
            var c2 = new[] { 0, 1, 2, 3, 2, 1, 0, 0, 0, 1, 0, 1, 0 };

            var c1DotC2 = (new[] { 0, 1, 4, 3, 0, 1, 0, 0, 0, 1, 0, 1, 0 }).Sum();
            var c1DotC1 = (new[] { 0, 1, 4, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0 }).Sum();
            var c2DotC2 = (new[] { 0, 1, 4, 9, 4, 1, 0, 0, 0, 1, 0, 1, 0 }).Sum();

            var expected = c1DotC2 / (double)Math.Max(c1DotC1, c2DotC2);
            var actual   = Chamfer.Similarity(c1, c2);

            Assert.IsTrue(Math.Abs(expected - actual) < 0.001);

            Console.WriteLine("Begin Chamfer Similarity Test with Differently Sized Arrays");

            var          larger    = new[] { 0, 1, 2, 3, 4, 5, 5 };
            var          smaller   = new[] { 0, 1, 2, 3 };
            const double expected0 = 1.000;
            var          actual0   = Chamfer.Similarity(smaller, larger);

            Assert.IsTrue(Math.Abs(expected0 - actual0) < 0.001);

            var sDoTs = (new[] { 0, 1, 4, 9 }).Sum();
            var lDoTl = (new[] { 1, 4, 9, 16 }).Sum();
            var sDoTl = (new[] { 0, 2, 6, 12 }).Sum();

            var expected1 = sDoTl / (double)Math.Max(sDoTs, lDoTl);
            var actual1   = Chamfer.Similarity(smaller, larger, 1);

            Assert.IsTrue(Math.Abs(expected1 - actual1) < 0.001);

            Console.WriteLine("Begin Chamfer Similarity Scan Test");
            var expected2     = Chamfer.Similarity(smaller, larger, 2);
            var expected3     = Chamfer.Similarity(smaller, larger, 3);
            var expectedScan  = new[] { expected0, expected1, expected2, expected3 };
            var actualScan    = Chamfer.ScanSimilarity(smaller, larger);
            var actualReverse = Chamfer.ScanSimilarity(larger, smaller);

            var diff        = actualScan.Zip(expectedScan, (act, exp) => Math.Abs(act - exp)).Sum();
            var diffReverse = actualReverse.Zip(actualScan, (rev, scan) => Math.Abs(rev - scan)).Sum();

            Assert.IsTrue(diff < 0.001);
            Assert.IsTrue(diffReverse < 0.001);

            Console.WriteLine("End Chamfer Similarity Test");
        }
Esempio n. 9
0
        public static void ChamferFromLeft(string filepath)
        {
            logger.Trace("Starting Chamfer From Left");
            double[] kernel = new[] { -1.0, 0.0, 1.0 };
            Bitmap   source = new Bitmap(filepath);
            var      image  = new Image <Bgra, Byte>(source);

            double[] lumas       = Luminousity.RepresentativeLuminousity(image, 2, 4, Direction.FromLeft);
            int[]    indicies    = Utility.GetKernelIndicies(kernel, -1);
            var      convolution = Utility.Convolute(lumas, kernel, indicies);
            var      processed   = Utility.Threshold(Utility.Absolute(convolution), 0.3);
            var      chamfers    = Chamfer.Measure(processed);

            Visualizer.Plot(chamfers, "Convolution Result");
        }
Esempio n. 10
0
        public void ChamferFaces(int edgeToChamfer, int faceToImprint, Imprint.ImprintMode mode)
        {
            var body    = TestGeomGenerator.CreateBox().Body;
            var chamfer = Chamfer.Create(body, new[] { body.Shape.GetSubshapeReference(SubshapeType.Edge, edgeToChamfer) });

            chamfer.Distance = 5.0;
            var imprint = Imprint.Create(body, body.Shape.GetSubshapeReference(SubshapeType.Face, faceToImprint));
            var center  = imprint.Sketch.AddPoint(new Pnt2d(0, 0));
            var rim     = imprint.Sketch.AddPoint(new Pnt2d(0, 2));

            imprint.Sketch.AddSegment(new SketchSegmentCircle(center, rim));
            imprint.Mode = mode;

            Assert.IsTrue(imprint.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(body.Shape, Path.Combine(_BasePath, $"ChamferFaces_{edgeToChamfer}_{mode}")));
        }
        public void EnhanceContinuesEdges()
        {
            var ctx = Context.Current;

            var body = TestData.GetBodyFromBRep(Path.Combine(_BasePath, "EnhanceContinuesEdges_Source.brep"));

            ctx.ViewportController.ZoomFitAll();

            var shape = Chamfer.Create(body);

            shape.Distance = 0.3f;
            ctx.WorkspaceController.StartTool(new EdgeModifierTool(shape));

            Assert.Multiple(() =>
            {
                // Hilight single edge
                ctx.ViewportController.MouseMove(new Point(310, 350));
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EnhanceContinuesEdges1"));

                // Select edge -> Expect extension to three edges
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseUp(false);
                ctx.ViewportController.MouseMove(new Point(0, 0));
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EnhanceContinuesEdges2"));

                // The same on the lower three edges
                ctx.ViewportController.MouseMove(new Point(250, 370));
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseUp(false);
                ctx.ViewportController.MouseMove(new Point(0, 0));
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EnhanceContinuesEdges3"));

                // Deselect via another edge (not the original)
                ctx.ViewportController.MouseMove(new Point(250, 340));
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseUp(false);
                ctx.ViewportController.MouseMove(new Point(0, 0));
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EnhanceContinuesEdges4"));

                // Deselect via same edge (the original)
                ctx.ViewportController.MouseMove(new Point(250, 370));
                ctx.ViewportController.MouseDown();
                ctx.ViewportController.MouseUp(false);
                ctx.ViewportController.MouseMove(new Point(0, 0));
                AssertHelper.IsSameViewport(Path.Combine(_BasePath, "EnhanceContinuesEdges5"));
            });
        }
Esempio n. 12
0
        public void FaceSelection()
        {
            var imprint = TestGeomGenerator.CreateImprint(TestSketchGenerator.SketchType.Circle);

            Assume.That(imprint, Is.Not.Null);
            imprint.Depth = 5.0;

            var shape = Chamfer.Create(imprint.Body);

            shape.AddAllEdges();
            shape.Mode           = Chamfer.ChamferModes.TwoDistances;
            shape.Distance       = 0.2;
            shape.SecondDistance = 1;

            Assert.IsTrue(shape.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "FaceSelection")));
        }
Esempio n. 13
0
        /// <summary>
        ///   Given two shreds, calculate the offset value at which the two shreds are most similar
        /// </summary>
        /// <param name="first"> The first shred staged for comparison </param>
        /// <param name="second"> The other shred staged for comparison </param>
        /// <param name="directionA"> Direction of this shred to be compared </param>
        /// <param name="orientationA"> Orientation of this shred to be compared </param>
        /// <param name="directionB"> Direction of the other shred to be compared </param>
        /// <param name="orientationB"> Orientiation of the other shred to be compared </param>
        /// <returns> Tuple containing the max similarity value and the offset at which that occured </returns>
        public static MatchData CompareShred(Shred first,
                                             Shred second,
                                             Direction directionA,
                                             Orientation orientationA,
                                             Direction directionB,
                                             Orientation orientationB)
        {
            Side   sideA   = new Side(first, directionA, orientationA);
            Side   sideB   = new Side(second, directionB, orientationB);
            double penalty = 1.0;

            if (ORIENTATION_PENALTY)
            {
                if (first.TrueOrienation != null && second.TrueOrienation != null)
                {
                    if (!(
                            (first.TrueOrienation == orientationA && second.TrueOrienation == orientationB) ||
                            (first.TrueOrienation == Enumeration.Opposite(orientationA) && second.TrueOrienation == Enumeration.Opposite(orientationB))))
                    {
                        penalty = 0.15;
                    }
                }
            }

            if (NORMALIZATION_ENABLED)
            {
                double max = Chamfer.NormalizedSimilarity(
                    first.GetChamfer(directionA, orientationA),
                    second.GetChamfer(directionB, orientationB));
                double[] scan = new double[1];

                return(new MatchData(max * penalty, 0, scan, sideA, sideB));
            }
            else
            {
                double[] scan = Chamfer.ScanSimilarity(
                    first.GetChamfer(directionA, orientationA),
                    second.GetChamfer(directionB, orientationB));

                Tuple <double, int> maxData = Utility.Max(scan);
                double max  = maxData.Item1;
                int    best = maxData.Item2;
                return(new MatchData(max * penalty, best, scan, sideA, sideB));
            }
        }
Esempio n. 14
0
        public void Cylinder()
        {
            var baseshape = new Cylinder()
            {
                Radius = 10,
                Height = 10,
            };
            var body = Body.Create(baseshape);

            var shape = Chamfer.Create(body);

            shape.AddAllEdges();
            shape.Mode     = Chamfer.ChamferModes.Symmetric;
            shape.Distance = 3;

            Assert.IsTrue(shape.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "Cylinder")));
        }
Esempio n. 15
0
        public void Box()
        {
            var baseshape = new Box()
            {
                DimensionX = 10,
                DimensionY = 10,
                DimensionZ = 10,
            };
            var body = Body.Create(baseshape);

            var shape = Chamfer.Create(body);

            shape.AddAllEdges();
            shape.Mode     = Chamfer.ChamferModes.Symmetric;
            shape.Distance = 3;

            Assert.IsTrue(shape.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "Box")));
        }
        private List <Part> CreateContours(JsPart[] sectionContours)
        {
            var contours = new List <Part>();

            if (null == sectionContours)
            {
                return(contours);
            }

            Chamfer stub = null;

            foreach (var contourDef in sectionContours)
            {
                var    plate            = new ContourPlate();
                string sysProfileString = null;
                ProfileConversion.ConvertFromCurrentUnits(contourDef.profile, ref sysProfileString);
                plate.Profile.ProfileString   = sysProfileString;
                plate.Material.MaterialString = contourDef.material;
                plate.Class                      = BooleanPart.BooleanOperativeClassName;
                plate.Name                       = "CUTPART";
                plate.PartNumber.Prefix          = "0";
                plate.PartNumber.StartNumber     = 0;
                plate.AssemblyNumber.Prefix      = " ";
                plate.AssemblyNumber.StartNumber = 0;

                plate.Position.Depth       = Position.DepthEnum.MIDDLE;
                plate.Position.Plane       = Position.PlaneEnum.MIDDLE;
                plate.Position.PlaneOffset = 0;
                if (null != contourDef.rotation)
                {
                    plate.Position.Rotation = EnumConverter.TryFromInt((int)contourDef.rotation, Position.RotationEnum.FRONT);
                }
                plate.Position.RotationOffset = 0.0;
                plate.Contour = new Contour()
                {
                    ContourPoints = new ArrayList(contourDef.points.Select(jp => new ContourPoint(jp.ToTS(), null)).ToArray())
                };
                contours.Add(plate);
            }
            Tracer._trace($"Created {contours.Count} cut contours");
            return(contours);
        }
Esempio n. 17
0
        public void DistanceAngleSwapped()
        {
            var baseshape = new Box()
            {
                DimensionX = 10,
                DimensionY = 10,
                DimensionZ = 10,
            };
            var body = Body.Create(baseshape);

            var shape = Chamfer.Create(body);

            shape.AddAllEdges();
            shape.Mode               = Chamfer.ChamferModes.DistanceAngle;
            shape.Distance           = 3;
            shape.Angle              = 20;
            shape.ReverseOrientation = true;

            Assert.IsTrue(shape.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(shape, Path.Combine(_BasePath, "DistanceAngleSwapped")));
        }
Esempio n. 18
0
        internal void ErzeugeFase()
        {
            part_Schraube.InWorkObject = part_Schraube;

            Reference reffase = (Reference)part_Schraube.CreateReferenceFromName("");

            Chamfer fase1 = shapefac.AddNewChamfer(reffase, CatChamferPropagation.catMinimalChamfer, CatChamferMode.catLengthAngleChamfer, CatChamferOrientation.catNoReverseChamfer, 1, 45);

            Bodies             bodies1             = part_Schraube.Bodies;
            Body               bodie1              = bodies1.Item("Hauptkörper");
            Shapes             schapes1            = bodie1.Shapes;
            ConstRadEdgeFillet constRadEdgeFillet1 = (ConstRadEdgeFillet)schapes1.Item("Kanntenverundung");
            Reference          reference2          = part_Schraube.CreateReferenceFromBRepName("REdge:(Edge:(Face:(Brp:(Pad.1;1);None:();Cf11:());Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;1)));None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", constRadEdgeFillet1);

            fase1.AddElementToChamfer(reference2);
            fase1.Mode        = CatChamferMode.catLengthAngleChamfer;
            fase1.Propagation = CatChamferPropagation.catTangencyChamfer;
            fase1.Orientation = CatChamferOrientation.catNoReverseChamfer;

            part_Schraube.Update();
        }
        public void ChamferEdgeReference()
        {
            var imprint = TestGeomGenerator.CreateImprint();

            imprint.Depth = 2.5;
            imprint.Mode  = Imprint.ImprintMode.Raise;
            //var body = Body.Create(imprint);
            Assume.That(imprint.Make(Shape.MakeFlags.None));

            var edges = imprint.GetBRep().Edges();

            Assume.That(edges.Count, Is.EqualTo(15));
            var edgeRefs = new[]
            {
                imprint.GetSubshapeReference(edges[1]),
                imprint.GetSubshapeReference(edges[6]),
                imprint.GetSubshapeReference(edges[7]),
                imprint.GetSubshapeReference(edges[8]),
            };

            Assert.That(edgeRefs[0].ShapeId, Is.Not.EqualTo(imprint.Guid));
            Assert.That(edgeRefs[1].ShapeId, Is.Not.EqualTo(imprint.Guid));
            Assert.That(edgeRefs[2].ShapeId, Is.Not.EqualTo(imprint.Guid));
            Assert.That(edgeRefs[3].ShapeId, Is.Not.EqualTo(imprint.Guid));

            var chamfer = Chamfer.Create(imprint.Body, edgeRefs);

            chamfer.Mode           = Chamfer.ChamferModes.Symmetric;
            chamfer.Distance       = 2;
            chamfer.SecondDistance = 2;

            Assert.IsTrue(chamfer.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(chamfer, Path.Combine(_BasePath, "ChamferEdgeWithImprint")));

            imprint.IsSkipped = true;
            Assert.IsTrue(chamfer.Make(Shape.MakeFlags.None));
            Assert.IsTrue(ModelCompare.CompareShape(chamfer, Path.Combine(_BasePath, "ChamferEdgeWithoutImprint")));
        }
        public void SelectionRestoreAfterBrepUpdate()
        {
            var ctx = Context.Current;
            var sel = ctx.WorkspaceController.Selection;

            var body1 = TestData.GetBodyFromBRep(@"SourceData\BRep\ImprintRingFace.brep");

            ctx.ViewportController.ZoomFitAll();

            // Select
            ctx.ViewportController.MouseMove(new Point(250, 250));
            ctx.ViewportController.MouseDown();
            ctx.ViewportController.MouseUp(false);
            ctx.ViewportController.MouseMove(new Point(0, 0));
            Assert.That(sel.SelectedEntities.Count, Is.EqualTo(1));
            Assert.That(sel.SelectedEntities[0], Is.EqualTo(body1));
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SelectionRestoreAfterBrepUpdate1"));

            // Update
            Chamfer.Create(body1, new[] { new SubshapeReference(SubshapeType.Edge, body1.Shape.Guid, 14) });
            Assert.That(sel.SelectedEntities.Count, Is.EqualTo(1));
            Assert.That(sel.SelectedEntities[0], Is.EqualTo(body1));
            AssertHelper.IsSameViewport(Path.Combine(_BasePath, "SelectionRestoreAfterBrepUpdate2"));
        }
Esempio n. 21
0
        public static void AddContourPoint(this ContourPlate cp, Point p, Chamfer chamfer = null)
        {
            var cPoint = new ContourPoint(p, chamfer);

            cp.AddContourPoint(cPoint);
        }
 void ExecuteSelectNone()
 {
     Chamfer.RemoveAllEdges();
     CommmitChange();
 }
 void ExecuteSelectAll()
 {
     Chamfer.AddAllEdges();
     CommmitChange();
 }
Esempio n. 24
0
        public void ErzeugeBalken(double l)
        {
            //Hauptkörper in Bearbeitung
            catiaPart.Part.InWorkObject = catiaPart.Part.MainBody;
            ShapeFactory shapeFac = (ShapeFactory)catiaPart.Part.ShapeFactory;


            //BLOCK
            Pad newPad = shapeFac.AddNewPad(catiaProfil, l);

            newPad.set_Name("Block");



            catiaPart.Part.Update();



            //FASE

            Reference reference1 = catiaPart.Part.CreateReferenceFromName("");

            Chamfer chamfer = shapeFac.AddNewChamfer(
                reference1,
                CatChamferPropagation.catTangencyChamfer,
                CatChamferMode.catLengthAngleChamfer,
                CatChamferOrientation.catNoReverseChamfer,
                1,
                45);

            Reference reference2 = catiaPart.Part.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", newPad);

            /*("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());Face:(Brp:(Pad.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1);*/

            //"RSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1)

            chamfer.AddElementToChamfer(reference2);
            chamfer.Mode        = CatChamferMode.catLengthAngleChamfer;
            chamfer.Propagation = CatChamferPropagation.catTangencyChamfer;
            chamfer.Orientation = CatChamferOrientation.catNoReverseChamfer;

            catiaPart.Part.Update();


            Reference reference3 = catiaPart.Part.CreateReferenceFromName("");

            Chamfer chamfer2 = shapeFac.AddNewChamfer(
                reference3,
                CatChamferPropagation.catTangencyChamfer,
                CatChamferMode.catLengthAngleChamfer,
                CatChamferOrientation.catNoReverseChamfer,
                1,
                45);

            Reference reference4 = catiaPart.Part.CreateReferenceFromBRepName("RSur:(Face:(Brp:(Pad.1;1);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", newPad);

            /*("REdge:(Edge:(Face:(Brp:(Pad.1;0:(Brp:(Sketch.1;3)));None:();Cf11:());Face:(Brp:(Pad.1;2);None:();Cf11:());None:(Limits1:();Limits2:());Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1);*/

            //"RSur:(Face:(Brp:(Pad.1;2);None:();Cf11:());WithTemporaryBody;WithoutBuildError;WithSelectingFeatureSupport;MFBRepVersion_CXR15)", pad1)
            chamfer2.AddElementToChamfer(reference4);
            chamfer2.Mode        = CatChamferMode.catLengthAngleChamfer;
            chamfer2.Propagation = CatChamferPropagation.catTangencyChamfer;
            chamfer2.Orientation = CatChamferOrientation.catNoReverseChamfer;


            catiaPart.Part.Update();
        }
Esempio n. 25
0
        public static ContourPlate InsertCutPlate(ContourPlate cuttedPlate, ArrayList points,
                                                  string profileString, string materialString, Chamfer chamfer = null)
        {
            var cp = new ContourPlate();

            foreach (Point point in points)
            {
                cp.AddContourPoint(point, chamfer);
            }
            cp.Profile.ProfileString   = profileString;
            cp.Material.MaterialString = materialString;
            cp.Class = BooleanPart.BooleanOperativeClassName;
            cp.Insert();
            var bp = new BooleanPart {
                Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT, Father = cuttedPlate
            };

            bp.SetOperativePart(cp);
            bp.Insert();
            cp.Delete();
            return(cp);
        }
Esempio n. 26
0
        public static ContourPlate InsertPlate(ArrayList points,
                                               string profileString, string materialString, Chamfer chamfer = null)
        {
            var cp = new ContourPlate();

            foreach (Point point in points)
            {
                cp.AddContourPoint(point, chamfer);
            }
            cp.Profile.ProfileString   = profileString;
            cp.Material.MaterialString = materialString;
            cp.Insert();
            return(cp);
        }
Esempio n. 27
0
        public static ContourPlate InsertPlate(Point A, Point B, Point C,
                                               string profileString, string materialString, Chamfer chamfer = null)
        {
            var cp = new ContourPlate();

            cp.AddContourPoint(A, chamfer);
            cp.AddContourPoint(B, chamfer);
            cp.AddContourPoint(C, chamfer);
            cp.Profile.ProfileString   = profileString;
            cp.Material.MaterialString = materialString;
            cp.Insert();
            return(cp);
        }
Esempio n. 28
0
        public void CK08_CreatePlate()
        {
            ArrayList PickedPoints = null;
            Picker    Picker       = new Picker();

            try
            {
                PickedPoints = Picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON);
            }
            catch { PickedPoints = null; }
            if (PickedPoints != null)
            {
                ContourPlate Plate = new ContourPlate();
                Plate.AssemblyNumber.Prefix      = "P";
                Plate.AssemblyNumber.StartNumber = 1;
                Plate.PartNumber.Prefix          = "p";
                Plate.PartNumber.StartNumber     = 1;
                Plate.Name = "PLATE";
                Plate.Profile.ProfileString   = "PL25";
                Plate.Material.MaterialString = "C245";
                Plate.Finish         = "";
                Plate.Class          = "1";
                Plate.Position.Depth = Position.DepthEnum.FRONT;
                foreach (T3D.Point ThisPoint in PickedPoints)
                {
                    var chamfer     = new Chamfer(12.7, 12.7, Chamfer.ChamferTypeEnum.CHAMFER_LINE);
                    var conturPoint = new ContourPoint(ThisPoint, chamfer);
                    Plate.AddContourPoint(conturPoint);
                }
                if (!Plate.Insert())
                {
                    Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Plate wasn't created.");
                }
                else
                {
                    // Change the workplane to the coordinate system of the plate.
                    var transformationPlane = new TransformationPlane(Plate.GetCoordinateSystem());
                    Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(transformationPlane);

                    // Show the plate in the model and the workplane change.
                    Model.CommitChanges();

                    // This gets the plate's coordinates and information in the current workplane.
                    Plate.Select();
                    ReperShow(Plate.GetCoordinateSystem());
                    // Draw the coordinate of the plate in the model in the local coordinate system.
                    GraphicsDrawer Drawer = new GraphicsDrawer();
                    foreach (ContourPoint ContourPoint in Plate.Contour.ContourPoints)
                    {
                        double    x = ContourPoint.X, y = ContourPoint.Y, z = ContourPoint.Z;
                        T3D.Point CornerPoint = new T3D.Point(x, y, z);
                        PointXYZ(ContourPoint);
                        //double ImperialValue = 25.4;
                        //double XValue = Math.Round(CornerPoint.X / ImperialValue, 4);
                        //double YValue = Math.Round(CornerPoint.Y / ImperialValue, 4);
                        //double ZValue = Math.Round(CornerPoint.Z / ImperialValue, 4);
                        //Drawer.DrawText(CornerPoint, "(" + XValue + "," + YValue + "," + ZValue + ")", new Color(1,0,0));
                        Drawer.DrawLineSegment(new LineSegment(new T3D.Point(0, 0, 0), new T3D.Point(0, 0, 500)), new Color(1, 0, 0));
                    }
                    mw.Msg("На экране Tekla построена пластина по заданным точкам"
                           + " и показаны координаты этих точек и репер ПСК.  [OK]");
                    MessageBox.Show("Построена пластина.");
                    mw.Msg();
                }
            }
        }
Esempio n. 29
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);
                 }
             }
         }
     }
 }