public void CK06_Pick2Points() { T3D.Point FirstPoint = null; T3D.Point SecondPoint = null; Picker Picker = new Picker(); try { ArrayList PickPoints = Picker.PickPoints(Picker.PickPointEnum.PICK_TWO_POINTS); FirstPoint = PickPoints[0] as T3D.Point; SecondPoint = PickPoints[1] as T3D.Point; } catch { FirstPoint = SecondPoint = null; } if (FirstPoint != null && SecondPoint != null) { T3D.Vector XVector = new T3D.Vector(SecondPoint.X - FirstPoint.X, SecondPoint.Y - FirstPoint.Y, SecondPoint.Z - FirstPoint.Z); T3D.Vector YVector = XVector.Cross(new T3D.Vector(0, 0, -1)); Model.GetWorkPlaneHandler() .SetCurrentTransformationPlane(new TransformationPlane(FirstPoint , XVector, YVector)); ViewHandler.SetRepresentation("standard"); //PKh> should be add for Tekla-2018 Model.CommitChanges(); mw.Msg("Появляется рисунок осей X и Y ПСК, ось X в направлении от точки 1 к точке 2"); MessageBox.Show("вывел ПСК"); mw.Msg(); } }
private TSG.CoordinateSystem GetBasicViewsCoordinateSystemForTopView(TSG.CoordinateSystem objectCoordinateSystem) { TSG.CoordinateSystem result = new TSG.CoordinateSystem() { Origin = new TSG.Point(objectCoordinateSystem.Origin), AxisX = new TSG.Vector(objectCoordinateSystem.AxisX) * -1.0, AxisY = new TSG.Vector(objectCoordinateSystem.AxisY) }; TSG.Vector tempVector = (result.AxisX.Cross(UpDirection)); if (tempVector == new TSG.Vector()) { tempVector = (objectCoordinateSystem.AxisY.Cross(UpDirection)); } result.AxisX = tempVector.Cross(UpDirection).GetNormal(); result.AxisY = UpDirection.GetNormal(); return(result); }
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 { } }
private void btn_multiBeams_Click(object sender, EventArgs e) { try { Picker picker = new Picker(); ArrayList points = picker.PickPoints(Picker.PickPointEnum.PICK_POLYGON); if (points.Count >= 3) { TSG.Point start = new TSG.Point(0, 0, 0); TSG.Point middle = new TSG.Point(0, 0, 0); TSG.Point end = new TSG.Point(0, 0, 0); TSG.Vector vectorFit = new TSG.Vector(); TSG.Vector vectorZ = new TSG.Vector(); TSG.Vector vectorOne = new TSG.Vector(); TSG.Vector vectorTwo = new TSG.Vector(); ArrayList listBeams = new ArrayList(); ArrayList listPlates = new ArrayList(); double angelDegree = 0.0; for (int i = 0; i < points.Count - 1; i++) { TSM.Beam beam = BeamFirst(points[i] as TSG.Point, points[i + 1] as TSG.Point); beam.Insert(); listBeams.Add(beam); this.model.CommitChanges(); } double primaryWidth = 0.0; double primaryHeight = 0.0; for (int i = 0; i < points.Count - 1; i++) { try { start = points[i] as TSG.Point; middle = points[i + 1] as TSG.Point; end = points[i + 2] as TSG.Point; } catch { } vectorOne = new TSG.Vector(middle.X - start.X, middle.Y - start.Y, middle.Z - start.Z); vectorOne.Normalize(); vectorTwo = new TSG.Vector(middle.X - end.X, middle.Y - end.Y, middle.Z - end.Z); vectorTwo.Normalize(); double angle = vectorOne.GetAngleBetween(vectorTwo); angelDegree = angle * 180 / Math.PI; //TSG.Vector vectorFit = new TSG.Vector(1 * Math.Cos(angle / 2), 1 * Math.Cos(angle / 2), 0); vectorFit = new TSG.Vector(vectorOne.X + vectorTwo.X, vectorOne.Y + vectorTwo.Y, vectorOne.Z + vectorTwo.Z); vectorZ = vectorOne.Cross(vectorTwo); TSG.CoordinateSystem coordinateSystem = new TSG.CoordinateSystem(); double thick; if (tb_thcikPlates.Text != string.Empty) { double.TryParse(tb_thcikPlates.Text, out thick); } else { thick = 20.0; } double offset = thick; double angleFD = 90 - (angelDegree / 2); double angleFR = Math.PI * angleFD / 180; double width = 0.0; double heigth = 0.0; double x = Math.Round(vectorFit.X, 2, MidpointRounding.ToEven); double y = Math.Round(vectorFit.Y, 2, MidpointRounding.ToEven); double z = Math.Round(vectorFit.Z, 2, MidpointRounding.ToEven); TSM.Beam beam1 = listBeams[i] as TSM.Beam; TSM.Beam beam2 = listBeams[i + 1] as TSM.Beam; beam1.GetReportProperty("WIDTH", ref primaryWidth); beam1.GetReportProperty("HEIGHT", ref primaryHeight); if (x == 0.0 && y == 0.0 && z == 0.0) { TSG.Vector bAxisX = beam1.GetCoordinateSystem().AxisX; TSG.Vector bAxisY = beam1.GetCoordinateSystem().AxisY; TSG.Vector bAxisZ = bAxisY.Cross(bAxisX); coordinateSystem = new TSG.CoordinateSystem(middle, bAxisZ, bAxisY); } else { coordinateSystem = new TSG.CoordinateSystem( middle, vectorFit, vectorZ); } TSM.WorkPlaneHandler planeHandler = model.GetWorkPlaneHandler(); TSM.TransformationPlane original = planeHandler.GetCurrentTransformationPlane(); TSM.TransformationPlane beamPlane = new TSM.TransformationPlane(coordinateSystem); planeHandler.SetCurrentTransformationPlane(beamPlane); FitBeam(beam1, -offset); FitBeam(beam2, offset); if (z != 0) { vectorZ = vectorTwo.Cross(vectorOne); planeHandler.SetCurrentTransformationPlane(original); TSG.CoordinateSystem coordinatePlate = new TSG.CoordinateSystem( middle, vectorZ, vectorFit); TSM.TransformationPlane beamPlate = new TSM.TransformationPlane(coordinatePlate); planeHandler.SetCurrentTransformationPlane(beamPlate); width = primaryWidth; heigth = 50 + primaryHeight / (Math.Cos(angleFR)); } else { width = 50 + primaryWidth / (Math.Cos(angleFR)); heigth = primaryHeight; } bool positionPlate = true; for (int k = 0; k < 2; k++) { TSM.ContourPlate plate = PlateFirst(width, heigth, offset); if (positionPlate) { plate.Position.Depth = TSM.Position.DepthEnum.BEHIND; positionPlate = false; } else { plate.Position.Depth = TSM.Position.DepthEnum.FRONT; } plate.Insert(); listPlates.Add(plate); } TSM.ContourPlate plate1 = listPlates[0] as TSM.ContourPlate; TSM.ContourPlate plate2 = listPlates[1] as TSM.ContourPlate; BoltPlatetoPlate(plate1, plate2, heigth, width); WeldBeamToPlate(beam1, plate1); WeldBeamToPlate(beam2, plate2); planeHandler.SetCurrentTransformationPlane(original); this.model.CommitChanges(); listPlates.Clear(); } this.model.CommitChanges(); listBeams.Clear(); } else { MessageBox.Show(Tekla.Structures.Dialog.UIControls.LocalizeForm.Localization.GetText("albl_Invalid_input_parts"));//translation of text in message box } } catch { } }