public Beam CutBeamByPart(Beam beam, Part part, bool startSideCut = true) { // вырезаем ThasBeam по MainBeam var partClass = part.Class; BooleanPart Beam = new BooleanPart(); Beam.Father = beam; part.Class = BooleanPart.BooleanOperativeClassName; Beam.SetOperativePart(part); Beam.Insert(); part.Class = partClass; part.Modify(); // создаем режущую плоскость, чтобы отбросить //..(левую) часть ThisBeam по плоскости MainBeam CutPlane BeamLineCut = new CutPlane(); BeamLineCut.Father = beam; Plane BeamCutPlane = new Plane(); var cs = part.GetCoordinateSystem(); if (startSideCut) { cs.AxisX *= -1; } BeamCutPlane.AxisX = cs.AxisX; BeamCutPlane.AxisY = cs.AxisY; BeamCutPlane.Origin = cs.Origin; BeamLineCut.Plane = BeamCutPlane; BeamLineCut.Insert(); Model.CommitChanges(); return(beam); }
public static bool SolidToSolidIntersect(Part part1, Part part2) { double originalVolume = 0.0; part1.GetReportProperty("VOLUME_NET", ref originalVolume); var cuttingPart = new BooleanPart { Father = part1 }; part2.Class = BooleanPart.BooleanOperativeClassName; cuttingPart.SetOperativePart(part2); cuttingPart.Insert(); double volumeAfterCut = 0.0; part1.GetReportProperty("VOLUME_NET", ref volumeAfterCut); cuttingPart.Delete(); if (originalVolume > volumeAfterCut) { Tracer._trace("volume change"); return(true); } return(false); }
public ContourPlate CreateCut( Point point1, Point point2, Point point3, Point point4, Part Part_To_Be_Cut) { ContourPlate contourPlate = new ContourPlate(); contourPlate.Profile.ProfileString = "PL500"; contourPlate.Material.MaterialString = "ANTIMATERIAL"; contourPlate.Finish = ""; contourPlate.Class = "BlOpCl"; contourPlate.Position.Depth = Position.DepthEnum.MIDDLE; contourPlate.AddContourPoint(new ContourPoint(point1, (Chamfer)null)); contourPlate.AddContourPoint(new ContourPoint(point2, (Chamfer)null)); contourPlate.AddContourPoint(new ContourPoint(point3, (Chamfer)null)); contourPlate.AddContourPoint(new ContourPoint(point4, (Chamfer)null)); contourPlate.Insert(); BooleanPart booleanPart = new BooleanPart(); booleanPart.Father = (ModelObject)Part_To_Be_Cut; booleanPart.OperativePart = (Part)contourPlate; booleanPart.Insert(); return(contourPlate); }
/* * public static ContourPlate CreateCuttingPart(string profileString, string mate) * { * var plate = new ContourPlate(); * * //var myProfileString = "PL" + (thickness).ToString("F2"); * * string sysProfileString = null; * * ProfileConversion.ConvertFromCurrentUnits(profileString, ref sysProfileString); * plate.Profile.ProfileString = sysProfileString; * plate.Material.MaterialString = "ANTIMATERIAL"; * 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.BEHIND; * plate.Position.Plane = Position.PlaneEnum.MIDDLE; * plate.Position.PlaneOffset = 0; * plate.Position.Rotation = Position.RotationEnum.FRONT; * plate.Position.RotationOffset = 0.0; * * return plate; * } */ private void TryApplyCuts(Part part, List <Tuple <AABB, Part> > cutSolids) { if (null == cutSolids) { return; } var partBox = part.GetAABB(); // check collision foreach (var cutObjects in cutSolids) { var aabb = cutObjects.Item1; var operativePart = cutObjects.Item2; if (!GeometryUtils.testAABBAABB(aabb, partBox)) { continue; } BooleanPart Beam = new BooleanPart(); Beam.Father = part; Beam.SetOperativePart(operativePart); if (!Beam.Insert()) { Tracer._trace("Insert failed!"); } //Tracer._trace($"Cut solid: {part.Name}."); } }
public void part_cut(Part part_to_becut, Part cut_part) { BooleanPart booleanPart = new BooleanPart(); booleanPart.Father = (ModelObject)part_to_becut; cut_part.Class = "BlOpCl"; booleanPart.OperativePart = cut_part; booleanPart.Insert(); }
private void TryApplyCuts(Part part, List <Part> cutContours) { foreach (var cutObject in cutContours) { cutObject.Insert(); if (SolidToSolidIntersect(part, cutObject)) { var plate = new BooleanPart { Father = part }; plate.SetOperativePart(cutObject); if (!plate.Insert()) { Tracer._trace("Insert failed!"); } Tracer._trace($"Cut contour: {part.Profile.ProfileString}."); } cutObject.Delete(); } }
internal static ModelObject GetBooleanPart() { var beam = GetBeam(); var cuttingPart = new Beam() { StartPoint = new Point(5500, 6000, 0), EndPoint = new Point(5500, 8000, 0), Class = BooleanPart.BooleanOperativeClassName, }; cuttingPart.Profile.ProfileString = "100*100"; cuttingPart.Insert(); var cut = new BooleanPart(); cut.Father = beam; cut.SetOperativePart(cuttingPart); cut.Insert(); cuttingPart.Delete(); return(cut); }
/// <summary> /// Adds the cut for the wallshoe components /// </summary> /// <param name="variables">List of doubles with dimensions of the component</param> /// <param name="p1">The point which gives the x position of the component on fatherpart</param> /// <param name="minY">Fatherparts solids miminum Y position</param> /// <param name="maxY">Fatherparts solids miminum Y position</param> /// <param name="changeDirection">Boolean to give the direction</param> /// <param name="fatherpart">Part to insert the cut to</param> private bool AddWallShoeCut(double[] variables, Point p1, double minY, double maxY, bool changeDirection, Part fatherpart) { try { ContourPlate cutpart = new ContourPlate(); BooleanPart bPart = new BooleanPart(); cutpart.Name = "Leikkaus"; cutpart.Position.Depth = Position.DepthEnum.MIDDLE; cutpart.Position.Plane = Position.PlaneEnum.MIDDLE; cutpart.Class = BooleanPart.BooleanOperativeClassName; cutpart.Material.MaterialString = "Reikä"; cutpart.Profile.ProfileString = "PL135"; cutpart.Profile.ProfileString = "PL" + variables[4]; if (!changeDirection) { cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - variables[0], p1.Z + variables[1]), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - variables[0], p1.Z + variables[1] + variables[2]), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + variables[1] + variables[2] + (Math.Tan(variables[3] * Math.PI / 180) * ((maxY - minY) / 2 + variables[0]))), null)); } else { cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y + variables[0], p1.Z + variables[1]), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y + variables[0], p1.Z + variables[1] + variables[2]), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + variables[1] + variables[2] + (Math.Tan(variables[3] * Math.PI / 180) * ((minY - maxY) / 2 + variables[0]))), null)); } cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + variables[1]), null)); cutpart.Insert(); bPart.Father = fatherpart; bPart.SetOperativePart(cutpart); if (!bPart.Insert()) { WriteLog("Leikkauksen (1) tekeminen epäonnistui!"); } cutpart.Delete(); } catch (Exception ex) { WriteLog(ex.Message + "\n" + ex.StackTrace); return(false); } return(true); }
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); }
public Beam CreateCut(Point point1, Part Part_To_Be_Cut, string Partprofile) { Beam beam = new Beam(); beam.Profile.ProfileString = Partprofile; beam.Material.MaterialString = "ANTIMATERIAL"; beam.Finish = ""; beam.Class = "BlOpCl"; beam.Position.Depth = Position.DepthEnum.MIDDLE; beam.Position.Rotation = Position.RotationEnum.TOP; beam.Position.Plane = Position.PlaneEnum.MIDDLE; double num = 0.0; Part_To_Be_Cut.GetReportProperty("END_Z", ref num); beam.StartPoint = new Point(point1.X, point1.Y, num + 500.0); beam.EndPoint = new Point(point1.X, point1.Y, num - 500.0); beam.Insert(); BooleanPart booleanPart = new BooleanPart(); booleanPart.Father = (ModelObject)Part_To_Be_Cut; booleanPart.OperativePart = (Part)beam; booleanPart.Insert(); return(beam); }
public override bool Run(List <InputDefinition> Input) { try { GetValuesFromDialog(); WorkPlaneHandler wph = Model.GetWorkPlaneHandler(); TransformationPlane tp = wph.GetCurrentTransformationPlane(); TransformationPlane tppart = null; BoltGroup bg = Model.SelectModelObject((Identifier)Input[0].GetInput()) as BoltGroup; bg.Select(); List <Part> parts = new List <Part>(); parts.Add(bg.PartToBeBolted); parts.Add(bg.PartToBoltTo); foreach (Part p in bg.OtherPartsToBolt) { parts.Add(p); } #region Clear List <Part> _part = new List <Part>(); foreach (Part p in parts) { bool flag = false; foreach (Part pp in _part) { if (pp.Identifier.ID == p.Identifier.ID) { flag = true; } } if (!flag) { _part.Add(p); } } parts.Clear(); parts = _part; #endregion foreach (Part p in parts) { if (p is Beam) { Beam b = p as Beam; b.Select(); double k = 0.0; b.GetReportProperty("PROFILE.FLANGE_SLOPE_RATIO", ref k); if (k == 0) { continue; } tppart = new TransformationPlane(p.GetCoordinateSystem()); wph.SetCurrentTransformationPlane(tppart); bg.Select(); foreach (Point pb in bg.BoltPositions) { Point _pb = new Point(pb); #region Уклон полок - точки через солид GeometricPlane gp = new GeometricPlane( _pb, new Vector(0, 1, 0), new Vector(0, 0, 1)); List <List <Point> > lp = IntersectSolid(p.GetSolid(), gp); List <LineSegment> ls = new List <LineSegment>(); for (int i = 0; i < lp[0].Count - 1; i++) { Point p1 = lp[0][i]; Point p2 = lp[0][i + 1]; Vector v = new Vector(p2.X - p1.X, p2.Y - p1.Y, p2.Z - p1.Z); v.Normalize(1.0); if (v.Y != 0 && v.Z != 0) { ControlLine cl = new ControlLine(); cl.Line.Point1 = p1; cl.Line.Point2 = p2; // cl.Insert(); ls.Add(new LineSegment(p1, p2)); } } Point _p1 = lp[0][0]; Point _p2 = lp[0][lp[0].Count - 1]; Vector _v = new Vector(_p2.X - _p1.X, _p2.Y - _p1.Y, _p2.Z - _p1.Z); if (_v.Y != 0 && _v.Z != 0) { ls.Add(new LineSegment(_p1, _p2)); ControlLine cl = new ControlLine(); cl.Line.Point1 = _p1; cl.Line.Point2 = _p2; // cl.Insert(); } #endregion #region Точки для построения пластины double diam = bg.BoltSize; double tol = GOST_10906_78[diam][0]; double _b = GOST_10906_78[diam][1]; double t1 = GOST_10906_78[diam][2]; double t2 = GOST_10906_78[diam][3]; int kf = (_pb.Z <= ((Point)b.GetReferenceLine(false)[0]).Z ? -1 : 1); _pb.Z += kf * _b * 0.5; double h = double.MaxValue; LineSegment lsb = ls[0]; foreach (LineSegment lsi in ls) { double t = Distance.PointToLineSegment(_pb, lsi); if (h >= t) { h = t; lsb = lsi; } } //ControlLine cli = new ControlLine(); //cli.Line.Point1 = lsb.Point1; //cli.Line.Point2 = lsb.Point2; //cli.Insert(); Point pb1 = new Point(_pb.X, _pb.Y + 1000, _pb.Z); Point pbi = Intersection.LineToLine( new Line(lsb), new Line(_pb, pb1)).Point1; //cli.Line.Point1 = _pb; //cli.Line.Point2 = pbi; //cli.Insert(); #endregion ContourPlate cp = new ContourPlate(); Contour cr = new Contour(); cr.AddContourPoint(new ContourPoint(new Point(pbi.X - _b * 0.5, pbi.Y, pbi.Z), null)); cr.AddContourPoint(new ContourPoint(new Point(pbi.X + _b * 0.5, pbi.Y, pbi.Z), null)); cr.AddContourPoint(new ContourPoint(new Point(pbi.X + _b * 0.5, pbi.Y, pbi.Z - kf * _b), null)); cr.AddContourPoint(new ContourPoint(new Point(pbi.X - _b * 0.5, pbi.Y, pbi.Z - kf * _b), null)); cp.Contour = cr; cp.Profile.ProfileString = "PL" + t1.ToString(); cp.AssemblyNumber.Prefix = prefix_asm; cp.AssemblyNumber.StartNumber = start_part; cp.PartNumber.Prefix = prefix_part; cp.PartNumber.StartNumber = start_part; cp.Name = name; cp.Material.MaterialString = material; cp.Finish = finish; if (kf == -1 && pbi.Y > 0) { cp.Position.Depth = Position.DepthEnum.FRONT; } else if (kf == -1 && pbi.Y < 0) { cp.Position.Depth = Position.DepthEnum.BEHIND; } else if (kf == 1 && pbi.Y > 0) { cp.Position.Depth = Position.DepthEnum.BEHIND; } else if (kf == 1 && pbi.Y < 0) { cp.Position.Depth = Position.DepthEnum.FRONT; } cp.Insert(); if (weight != 0.0 && us_prop_weight != "") { cp.SetUserProperty(us_prop_weight, weight); cp.Modify(); } BooleanPart bp = new BooleanPart(); ContourPlate cp2 = new ContourPlate(); Contour cr2 = new Contour(); cr2.AddContourPoint(new ContourPoint(new Point(pbi.X, pbi.Y, pbi.Z), null)); cr2.AddContourPoint(new ContourPoint(new Point(pbi.X, pbi.Y, pbi.Z - kf * _b), null)); cr2.AddContourPoint(new ContourPoint(new Point(pbi.X, pbi.Y + (pbi.Y > 0 ? -1 * (t1 - t2) : (t1 - t2)), pbi.Z - kf * _b), null)); cp2.Contour = cr2; cp2.Profile.ProfileString = "PL" + (_b + 10).ToString(); cp2.Class = BooleanPart.BooleanOperativeClassName; cp2.Insert(); bp.Father = cp; bp.OperativePart = cp2; bp.Insert(); cp2.Delete(); BoltArray ba = new BoltArray(); ba.FirstPosition = pb; ba.SecondPosition = new Point(pb.X + 100, pb.Y, pb.Z); ba.BoltStandard = bg.BoltStandard; ba.Position.Rotation = Position.RotationEnum.TOP; ba.BoltType = bg.BoltType; ba.BoltSize = bg.BoltSize; ba.Tolerance = tol; ba.Bolt = false; ba.AddBoltDistX(0); ba.AddBoltDistY(0); ba.PartToBeBolted = cp; ba.PartToBoltTo = cp; ba.Insert(); } } } wph.SetCurrentTransformationPlane(tp); } catch (Exception Exc) { MessageBox.Show(Exc.ToString()); } return(true); }
private void InsertComponents(ModelObject mObj, List <TSM.Component> components) { TransformationPlane originalTransformationplane = null; try { lock (wHandler) { originalTransformationplane = wHandler.GetCurrentTransformationPlane(); } ComponentInput compInput = new ComponentInput(); Part fatherpart = mObj as Part; Assembly assembly = fatherpart.GetAssembly(); // Get the transformationplane from objects coordinate systems vectors and because objects coordinate system is not the same XY plane as of models, // so cross product needs to be made for the Y-axis TransformationPlane fatherpartsTransformationPlane = new TransformationPlane(fatherpart.GetCoordinateSystem().Origin, fatherpart.GetCoordinateSystem().AxisX, Vector.Cross(fatherpart.GetCoordinateSystem().AxisY, fatherpart.GetCoordinateSystem().AxisX)); lock (wHandler) { wHandler.SetCurrentTransformationPlane(fatherpartsTransformationPlane); } double minX = fatherpart.GetSolid().MinimumPoint.X; double minY = fatherpart.GetSolid().MinimumPoint.Y; double minZ = fatherpart.GetSolid().MinimumPoint.Z; double maxX = fatherpart.GetSolid().MaximumPoint.X; double maxY = fatherpart.GetSolid().MaximumPoint.Y; double maxZ = fatherpart.GetSolid().MaximumPoint.Z; Solid s = fatherpart.GetSolid(); FaceEnumerator fEnum = s.GetFaceEnumerator(); StringBuilder sb = new StringBuilder(); while (fEnum.MoveNext()) { sb.AppendLine(fEnum.Current.Normal.ToString()); } Point p1 = null; Point p2 = null; List <Point> cutPartPoints = new List <Point>() { new Point(), new Point(), new Point(), new Point() }; ContourPlate cutpart = null; for (int i = 0; i < components.Count; i++) { cutpart = new ContourPlate(); cutpart.Name = "Leikkaus"; cutpart.Position.Depth = Position.DepthEnum.MIDDLE; cutpart.Position.Plane = Position.PlaneEnum.MIDDLE; cutpart.Class = BooleanPart.BooleanOperativeClassName; cutpart.Material.MaterialString = "Reikä"; cutpart.Profile.ProfileString = "PL135"; BooleanPart bPart = new BooleanPart(); compInput = new ComponentInput(); switch (i) { case 0: p1 = new Point(minX + 300, 0, minZ); p2 = new Point(minX + 300, maxY, minZ); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 40), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 161.68), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 161.68 + (Math.Tan(9.88 * Math.PI / 180) * ((maxY - minY) / 2 + 52))), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 40), null)); cutpart.Insert(); bPart.Father = fatherpart; bPart.SetOperativePart(cutpart); if (!bPart.Insert()) { SetInfoText("Leikkauksen (1) tekeminen epäonnistui!"); } cutpart.Delete(); break; case 1: p1 = new Point(maxX - 300, 0, minZ); p2 = new Point(maxX - 300, maxY, minZ); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 40), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 161.68), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 161.68 + (Math.Tan(9.88 * Math.PI / 180) * ((maxY - minY) / 2 + 52))), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 40), null)); cutpart.Insert(); bPart.Father = fatherpart; bPart.SetOperativePart(cutpart); if (!bPart.Insert()) { SetInfoText("Leikkauksen (2) tekeminen epäonnistui!"); } cutpart.Delete(); break; case 2: p1 = new Point(minX + 300, 0, maxZ + 135); p2 = new Point(minX + 300, maxY, maxZ + 135); break; case 3: p1 = new Point(maxX - 300, 0, maxZ + 135); p2 = new Point(maxX - 300, maxY, maxZ + 135); break; } compInput.AddOneInputPosition(p1); compInput.AddOneInputPosition(p2); components[i].SetComponentInput(compInput); if (!components[i].Insert()) { SetInfoText("Komponentin laittaminen epäonnistui!"); } } foreach (TSM.Component c in components) { assembly.Add(c); assembly.Modify(); } } catch (Exception ex) { ExceptionOccured(ex.Message, ex.StackTrace); SetInfoText("Komponentin asettamisessa tapahtui virhe!"); } finally { lock (wHandler) { wHandler.SetCurrentTransformationPlane(originalTransformationplane); } } }
static void Main(string[] args) { var model = new Model(); if (model.GetConnectionStatus()) { Console.WriteLine("You can start writting your Tekla project"); //insert fence handles var beamHandle1 = new Beam() { StartPoint = new Point(0.0, 0.0, 3000.0), EndPoint = new Point(36000.0, 0.0, 3000.0), Profile = new Profile { ProfileString = "RHS200*5" } }; beamHandle1.Insert(); var beamHandle2 = new Beam() { StartPoint = new Point(0.0, 0.0, 3000.0), EndPoint = new Point(0.0, 30000.0, 3000.0), Profile = new Profile { ProfileString = "RHS200*5" } }; beamHandle2.Insert(); var beamHandle3 = new Beam() { StartPoint = new Point(36000.0, 0.0, 3000.0), EndPoint = new Point(36000.0, 30000.0, 3000.0), Profile = new Profile { ProfileString = "RHS200*5" } }; beamHandle3.Insert(); var beamHandle4 = new Beam() { StartPoint = new Point(0.0, 30000.0, 3000.0), EndPoint = new Point(36000.0, 30000.0, 3000.0), Profile = new Profile { ProfileString = "RHS200*5" } }; beamHandle4.Insert(); //insert fence columns for (int index = 0; index <= 36000; index += 3000) { var point = new Point(index * 1.0, 0.0); var column = AddColumn(point, 3000); } for (int index = 3000; index <= 30000; index += 3000) { var point = new Point(0.0, index * 1.0); var column = AddColumn(point, 3000); } for (int index = 3000; index <= 36000; index += 3000) { var point = new Point(index * 1.0, 30000.0); var column = AddColumn(point, 3000); } for (int index = 3000; index <= 27000; index += 3000) { var point = new Point(36000.0, index * 1.0); var column = AddColumn(point, 3000); } Console.WriteLine("Give the weight of the house, number between 10 and 34:"); string val = Console.ReadLine(); int houseWeight = Convert.ToInt32(val); Console.WriteLine("Give the height of the house, number between 3 and 10"); string val1 = Console.ReadLine(); int houseHeight = Convert.ToInt32(val1); Console.WriteLine("Give the side weight of the house, number between 10 and 28"); string val2 = Console.ReadLine(); int houseSideWeight = Convert.ToInt32(val2); //int houseSideWeight = 20; //int houseWeight = 25; //int houseHeight = 6; var frontWall = AddPlate(new List <Point> { new Point(1000, 1000, 0), new Point(houseWeight * 1000, 1000, 0), new Point(houseWeight * 1000, 1000, houseHeight * 1000), new Point(1000, 1000, houseHeight * 1000) }); var leftWall = AddPlate(new List <Point> { new Point(1000, 1000, 0), new Point(1000, houseSideWeight * 1000, 0), new Point(1000, houseSideWeight * 1000, houseHeight * 1000), new Point(1000, 1000, houseHeight * 1000) }); var rightWall = AddPlate(new List <Point> { new Point(houseWeight * 1000, 1000, 0), new Point(houseWeight * 1000, houseSideWeight * 1000, 0), new Point(houseWeight * 1000, houseSideWeight * 1000, houseHeight * 1000), new Point(houseWeight * 1000, 1000, houseHeight * 1000) }); var backWall = AddPlate(new List <Point> { new Point(1000, houseSideWeight * 1000, 0), new Point(houseWeight * 1000, houseSideWeight * 1000, 0), new Point(houseWeight * 1000, houseSideWeight * 1000, houseHeight * 1000), new Point(1000, houseSideWeight * 1000, houseHeight * 1000) }); var Floor = AddPlate(new List <Point> { new Point(1000, 1000, 0), new Point(houseWeight * 1000, 1000, 0), new Point(houseWeight * 1000, houseSideWeight * 1000, 0), new Point(1000, houseSideWeight * 1000, 0) }); var Roof = AddPlate(new List <Point> { new Point(1000, 1000, houseHeight * 1000), new Point(houseWeight * 1000, 1000, houseHeight * 1000), new Point(houseWeight * 1000, houseSideWeight * 1000, houseHeight * 1000), new Point(1000, houseSideWeight * 1000, houseHeight * 1000) }); var leftSideRoof = AddPlate(new List <Point> { new Point(1000, 1000, houseHeight * 1000), new Point((houseWeight / 2) * 1000, 1000, (houseHeight + (houseHeight / 2)) * 1000), new Point((houseWeight / 2) * 1000, houseSideWeight * 1000, (houseHeight + (houseHeight / 2)) * 1000), new Point(1000, houseSideWeight * 1000, houseHeight * 1000) }); var RightSideRoof = AddPlate(new List <Point> { new Point(houseWeight * 1000, 1000, houseHeight * 1000), new Point((houseWeight / 2) * 1000, 1000, (houseHeight + (houseHeight / 2)) * 1000), new Point((houseWeight / 2) * 1000, houseSideWeight * 1000, (houseHeight + (houseHeight / 2)) * 1000), new Point(houseWeight * 1000, houseSideWeight * 1000, houseHeight * 1000) }); var frontRoofWall = AddPlate(new List <Point> { new Point(1000, 1000, houseHeight * 1000), new Point((houseWeight / 2) * 1000, 1000, (houseHeight + (houseHeight / 2)) * 1000), new Point(houseWeight * 1000, 1000, houseHeight * 1000) }); var backRoofWall = AddPlate(new List <Point> { new Point(1000, houseSideWeight * 1000, houseHeight * 1000), new Point((houseWeight / 2) * 1000, houseSideWeight * 1000, (houseHeight + (houseHeight / 2)) * 1000), new Point(houseWeight * 1000, houseSideWeight * 1000, houseHeight * 1000) }); var cutDoor = AddCutPlate(new List <Point> { new Point((houseWeight / 2) * 1000 - 1000, 1000, 50), new Point((houseWeight / 2) * 1000 + 1000, 1000, 50), new Point((houseWeight / 2) * 1000 + 1000, 1000, (houseHeight / 2) * 1000), new Point((houseWeight / 2) * 1000 - 1000, 1000, (houseHeight / 2) * 1000) }); var boolPart1 = new BooleanPart { Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT, Father = frontWall }; boolPart1.SetOperativePart(cutDoor); boolPart1.Insert(); //cutDoor.Delete(); var cutBackDoor = AddCutPlate(new List <Point> { new Point((houseWeight / 2) * 1000 - 1000, houseSideWeight * 1000, 50), new Point((houseWeight / 2) * 1000 + 1000, houseSideWeight * 1000, 50), new Point((houseWeight / 2) * 1000 + 1000, houseSideWeight * 1000, (houseHeight / 2) * 1000), new Point((houseWeight / 2) * 1000 - 1000, houseSideWeight * 1000, (houseHeight / 2) * 1000) }); var boolPart3 = new BooleanPart { Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT, Father = backWall }; boolPart3.SetOperativePart(cutBackDoor); boolPart3.Insert(); var cutLeftWindow = AddCutPlate(new List <Point> { new Point(3000, 1000, 2000), new Point(5000, 1000, 2000), new Point(5000, 1000, houseHeight * 1000 - 1000), new Point(3000, 1000, houseHeight * 1000 - 1000) }); var boolPart2 = new BooleanPart { Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT, Father = frontWall }; boolPart2.SetOperativePart(cutLeftWindow); boolPart2.Insert(); cutLeftWindow.Delete(); var cutRightWindow = AddCutPlate(new List <Point> { new Point(houseWeight * 1000 - 4000, 1000, 2000), new Point(houseWeight * 1000 - 2000, 1000, 2000), new Point(houseWeight * 1000 - 2000, 1000, houseHeight * 1000 - 1000), new Point(houseWeight * 1000 - 4000, 1000, houseHeight * 1000 - 1000) }); var boolPart4 = new BooleanPart { Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT, Father = frontWall }; boolPart4.SetOperativePart(cutRightWindow); boolPart4.Insert(); cutRightWindow.Delete(); model.CommitChanges(); } else { Console.WriteLine("Please open Tekla first!"); } Console.ReadLine(); }
public void CK09_PolygonCut() { // Current Workplane. Reminder how the user had the model before you did stuff. TransformationPlane CurrentPlane = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); Picker Picker = new Picker(); Beam PickedPart = null; try { PickedPart = (Beam)Picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART); } catch { PickedPart = null; } if (PickedPart != null) { // Change the workplane to the coordinate system of the Beam var psk = new TransformationPlane(PickedPart.GetCoordinateSystem()); Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(psk); ContourPlate ContourPlateObject = new ContourPlate(); ContourPlateObject.AssemblyNumber.Prefix = "XX"; ContourPlateObject.AssemblyNumber.StartNumber = 1; ContourPlateObject.Name = "CUT"; ContourPlateObject.PartNumber.Prefix = "xx"; ContourPlateObject.Profile.ProfileString = "200"; ContourPlateObject.Material.MaterialString = "ANTIMATERIAL"; ContourPlateObject.Finish = ""; // This is the Important Part! ContourPlateObject.Class = BooleanPart.BooleanOperativeClassName; ContourPlateObject.Position.Depth = Position.DepthEnum.MIDDLE; // when doing a polygon cut make sure you don't do roght alone edge //..or sometimes you maight get a solid error and your part will disappeared ContourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(-10, -10, 0), null)); ContourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(100, -10, 0), null)); ContourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(100, 100, 0), null)); ContourPlateObject.AddContourPoint(new ContourPoint(new T3D.Point(-10, 100, 0), null)); if (!ContourPlateObject.Insert()) { Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Plate wasn't created."); // SetWorkPlane back to what user had before Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane); } else { BooleanPart PolygonCut = new BooleanPart(); PolygonCut.Father = PickedPart; PolygonCut.OperativePart = ContourPlateObject; PolygonCut.Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT; if (!PolygonCut.Insert()) { // SetWorkPlane back to what user had before Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane); } else { // We don't need the phisical part in the model anymore. ContourPlateObject.Delete(); // SetWorkPlane back to what user had before Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane); // Show the fitting in the model but the user //..will never see the workplane change Model.CommitChanges(); } } } }
public void CK09_PartCut() { // Current Workplane. Reminder how the user had the model before you did stuff. TransformationPlane CurrentPlane = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); Picker Picker = new Picker(); Beam PickedPart = null; try { PickedPart = (Beam)Picker.PickObject(Picker.PickObjectEnum.PICK_ONE_PART); } catch { PickedPart = null; } if (PickedPart != null) { // Change the workplane to the coordinate system of the Beam var psk = new TransformationPlane(PickedPart.GetCoordinateSystem()); Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(psk); Beam BeamPartObject = new Beam(); BeamPartObject.StartPoint = new T3D.Point(400, 0, -200); BeamPartObject.StartPoint = new T3D.Vector(400, 0, 200); BeamPartObject.Profile.ProfileString = "D200"; BeamPartObject.Material.MaterialString = "ANTIMATERIAL"; BeamPartObject.Class = BooleanPart.BooleanOperativeClassName; BeamPartObject.Name = "CUT"; BeamPartObject.Position.Depth = Position.DepthEnum.MIDDLE; BeamPartObject.Position.Rotation = Position.RotationEnum.FRONT; BeamPartObject.Position.Plane = Position.PlaneEnum.MIDDLE; if (!BeamPartObject.Insert()) { Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Cut wasn't created."); // SetWorkPlane back to what user had before Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane); } else { BooleanPart PartCut = new BooleanPart(); PartCut.Father = PickedPart; PartCut.OperativePart = BeamPartObject; PartCut.Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT; if (!PartCut.Insert()) { // SetWorkPlane back to what user had before Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane); } else { // We don't need the phisical part in the model anymore. BeamPartObject.Delete(); // SetWorkPlane back to what user had before Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(CurrentPlane); // Show the fitting in the model but the user //..will never see the workplane change Model.CommitChanges(); } } } }
private void btnPartCut_Click(object sender, EventArgs e) { // Current Workplane. Remember how the user had the model before you made changes TransformationPlane currentPlane = currentModel.GetWorkPlaneHandler().GetCurrentTransformationPlane(); TSMUI.Picker myPicker = new TSMUI.Picker(); Part pickedPart = null; try { pickedPart = myPicker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART) as Part; } catch { pickedPart = null; } if (pickedPart != null) { // Change the workplaen to the coordinate system of the part currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane(pickedPart.GetCoordinateSystem())); Beam beamPartObject = new Beam(); beamPartObject.StartPoint = new T3D.Point(400, 0, -200); beamPartObject.EndPoint = new T3D.Point(400, 0, 200); beamPartObject.Profile.ProfileString = "D200"; beamPartObject.Material.MaterialString = "ANTIMATERIAL"; beamPartObject.Class = BooleanPart.BooleanOperativeClassName; beamPartObject.Name = "CUT";; beamPartObject.Position.Depth = Position.DepthEnum.MIDDLE; beamPartObject.Position.Rotation = Position.RotationEnum.FRONT; beamPartObject.Position.Plane = Position.PlaneEnum.MIDDLE; if (!beamPartObject.Insert()) { Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Cut was not created."); // Setworkplane back to what user had vefore changes currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); } else { BooleanPart partCut = new BooleanPart(); partCut.Father = pickedPart; partCut.OperativePart = beamPartObject; partCut.Type = BooleanPart.BooleanTypeEnum.BOOLEAN_CUT; if (!partCut.Insert()) { // Setworkplane back to what user had before currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); } else { // We don't need the physical part in the model anymore beamPartObject.Delete(); // Setworkplane back to what user had before currentModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentPlane); // Show the fitting in the model but the user will never see the workplane change currentModel.CommitChanges(); } } } }