public override bool Run(List <InputDefinition> input) { try { Tekla.Structures.Identifier id = (Tekla.Structures.Identifier)(input[0]).GetInput(); Tekla.Structures.Model.Model model = new TSM.Model(); TSM.Beam beam = (TSM.Beam)model.SelectModelObject(id); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane()); TSM.TransformationPlane currentTP = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); CoordinateSystem coordenadasMuro = beam.GetCoordinateSystem(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane(coordenadasMuro)); ParametrosPanel p = new ParametrosPanel(beam); p.dx = data.dx; p.dy = data.dy; p.diametroBarras = data.diametroBarras; p.diametroDiagonal = data.diametroDiagonales; p.adicionalDerecha = data.largoDerecha; p.adicionalIzquierda = data.largoIzquierda; p.adicionalSuperior = data.largoSuperior; p.adicionalInferior = data.largoInferior; PanelMoldar panel = new PanelMoldar(p); panel.fabricar(); model.GetWorkPlaneHandler().SetCurrentTransformationPlane(currentTP); } catch (Exception ex) { ErrorDialog.Show("Exception", ex.Message, ErrorDialog.Severity.ERROR); } return(true); }
public TemporaryWorkplane(TSM.TransformationPlane planeToWorkOn) { _model = new TSM.Model(); // save current plan _oldPlan = _model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); // set workplan _model.GetWorkPlaneHandler().SetCurrentTransformationPlane(planeToWorkOn); Tracer._trace("Setting new plane to work at."); }
public static TemporaryWorkplane FromJsPlane(JsCoordinateSystem coordinateSystem) { if (null == coordinateSystem) { return(null); } var teklaPlane = new TSM.TransformationPlane(coordinateSystem.GetCoordSys()); return(new TemporaryWorkplane(teklaPlane)); }
protected virtual void Dispose(bool disposing) { if (disposing) { // set back old one if (null != _oldPlan) { Tracer._trace("Setting work plane back."); _model?.GetWorkPlaneHandler().SetCurrentTransformationPlane(_oldPlan); } _model = null; _oldPlan = null; } }
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 BtnCreate_Click(object sender, EventArgs e) { TSM.TransformationPlane current = model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); try { model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TSM.TransformationPlane()); TSM.ModelObjectEnumerator selectedModelObjects = new TSMUI.ModelObjectSelector().GetSelectedObjects(); TSD.GADrawing MyDrawing = null; while (selectedModelObjects.MoveNext()) { TSG.CoordinateSystem ModelObjectCoordSys; string ModelObjectName; string DrawingName = "Part basic views" + (selectedModelObjects.Current as TSM.ModelObject).Identifier; GetCoordinateSystemAndNameOfSelectedObject(selectedModelObjects, out ModelObjectCoordSys, out ModelObjectName); MyDrawing = new TSD.GADrawing(DrawingName, "standard"); MyDrawing.Insert(); if (openDrawings.Checked) { drawingHandler.SetActiveDrawing(MyDrawing, true); } else { drawingHandler.SetActiveDrawing(MyDrawing, false); } ArrayList Parts = new ArrayList(); if (selectedModelObjects.Current is TSM.Part) { Parts.Add(selectedModelObjects.Current.Identifier); } else if (selectedModelObjects.Current is TSM.Assembly) { Parts = GetAssemblyParts(selectedModelObjects.Current as TSM.Assembly); } else if (selectedModelObjects.Current is TSM.BaseComponent) { Parts = GetComponentParts(selectedModelObjects.Current as TSM.BaseComponent); } else if (selectedModelObjects.Current is TSM.Task) { Parts = GetTaskParts(selectedModelObjects.Current as TSM.Task); } CreateViews(ModelObjectCoordSys, ModelObjectName, MyDrawing, Parts); MyDrawing.PlaceViews(); drawingHandler.CloseActiveDrawing(true); } if (MyDrawing != null && openDrawings.Checked) { drawingHandler.SetActiveDrawing(MyDrawing); } model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current); } catch (Exception Ex) { model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current); MessageBox.Show(Ex.Message); } }
// The constructor argument defines the database class StructuresData and set the data to be used in the plug-in. public AngleBracingPlugin(StructuresData data) { Data = data; _classModel = new TSM.Model(); // pass fields from Structures Data into AngleBracingPlugin class _angleBracingType = data.AngleBracingType; _anglePosition = data.AnglePosition; _angleBracingProfile = data.AngleBracingProfile; // Convert string offset values to double if (!Double.TryParse(data.AngleOffset, out _angleOffset)) { _angleOffset = 0.0; // Default offset to 0 if parse fails } if (!Double.TryParse(data.FirstOffset, out _firstOffset)) { _firstOffset = 0.0; // Default offset to 0 if parse fails } if (!Double.TryParse(data.SecondOffset, out _secondOffset)) { _secondOffset = 0.0; // Default offset to 0 if parse fails } if (!Double.TryParse(data.ThirdOffset, out _thirdOffset)) { _thirdOffset = 0.0; // Default offset to 0 if parse fails } if (!Double.TryParse(data.FourthOffset, out _fourthOffset)) { _fourthOffset = 0.0; // Default offset to 0 if parse fails } if (!Int32.TryParse(data.BoltQty, out _boltQty)) { _boltQty = 1; // Default bolt quantity to 1 if parse fails } // Assign profile for angle try { _angleProfile = _angleType[_angleBracingProfile]; } catch (IndexOutOfRangeException ex) { _angleProfile = _angleType[0]; } catch (Exception ex) { _angleProfile = _angleType[0]; } if (!Double.TryParse(_angleProfile.Substring(1, 1), out _angleWidth)) { _angleWidth = 0.0; } else { _angleWidth *= 25.4; } _originalPlane = _classModel.GetWorkPlaneHandler().GetCurrentTransformationPlane(); }
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 { } }
private void btnConvert_Click(object sender, EventArgs e) { ModelObjectSelector mos = new ModelObjectSelector(); TSM.ModelObjectEnumerator moe = mos.GetSelectedObjects(); moe.SelectInstances = false; while (moe.MoveNext()) { if (moe.Current is TSM.Part) { TSM.Part part = moe.Current as TSM.Part; // this method needs to be called to properly fill all the properties of the part part.Select(); double partLength = 0.0; double partHeight = 0.0; double partWidth = 0.0; part.GetReportProperty("LENGTH", ref partLength); part.GetReportProperty("HEIGHT", ref partHeight); part.GetReportProperty("WIDTH", ref partWidth); TSM.ModelObjectEnumerator MyAllBooleans = part.GetBooleans(); TSM.ModelObjectEnumerator MyAllBolts = part.GetBolts(); TSM.ModelObject MyFather = part.GetFatherComponent(); TSG.CoordinateSystem coordinateSystem = part.GetCoordinateSystem(); TSM.WorkPlaneHandler planeHandler = model.GetWorkPlaneHandler(); // before we create a new plane we need to store the old one TSM.TransformationPlane original = planeHandler.GetCurrentTransformationPlane(); TSM.TransformationPlane partPlane = new TSM.TransformationPlane(coordinateSystem); planeHandler.SetCurrentTransformationPlane(partPlane); //this.DrawCoordinateSystem(); TSG.Point p1 = new TSG.Point(0, partHeight / 2, 0); TSG.Point p2 = new TSG.Point(partLength, partHeight / 2, 0); TSG.Point p3 = new TSG.Point(partLength, -partHeight / 2, 0); TSG.Point p4 = new TSG.Point(0, -partHeight / 2, 0); TSM.ContourPlate CP = new TSM.ContourPlate(); TSM.ContourPoint conturePoint1 = new TSM.ContourPoint(p1, null); TSM.ContourPoint conturePoint2 = new TSM.ContourPoint(p2, null); TSM.ContourPoint conturePoint3 = new TSM.ContourPoint(p3, null); TSM.ContourPoint conturePoint4 = new TSM.ContourPoint(p4, null); CP.AddContourPoint(conturePoint1); CP.AddContourPoint(conturePoint2); CP.AddContourPoint(conturePoint3); CP.AddContourPoint(conturePoint4); CP.Name = "NEM"; CP.Finish = "xxx"; CP.Profile.ProfileString = "PL" + partWidth; CP.Material.MaterialString = "S235"; CP.Class = "1"; CP.Insert(); while (MyAllBooleans.MoveNext()) { try { TSM.BooleanPart partBooleans = MyAllBooleans.Current as TSM.BooleanPart; TSM.Part partBool = partBooleans.OperativePart as TSM.Part; partBool.Class = TSM.BooleanPart.BooleanOperativeClassName; partBool.Insert(); TSM.BooleanPart myboolpart = new TSM.BooleanPart(); myboolpart.Father = CP; myboolpart.SetOperativePart(partBool); myboolpart.Insert(); partBool.Delete(); } catch (Exception) { throw; } } while (MyAllBolts.MoveNext()) { try { if (MyAllBolts.Current is TSM.BoltGroup) { TSM.BoltGroup b = MyAllBolts.Current as TSM.BoltGroup; TSM.Part toBolted = b.PartToBeBolted as TSM.Part; TSM.Part toBolt = b.PartToBoltTo as TSM.Part; if (toBolted.Identifier.ID == toBolt.Identifier.ID) { b.PartToBeBolted = CP; b.PartToBoltTo = CP; } else if (toBolted.Identifier.ID == part.Identifier.ID) { b.PartToBoltTo.GetBolts(); b.PartToBeBolted = CP; } else { b.PartToBoltTo = CP; b.PartToBeBolted.GetBolts(); } b.Insert(); } } catch (Exception) { throw; } } if (MyFather != null) { TSM.ModelObjectEnumerator elementOfComponenet = MyFather.GetChildren(); while (elementOfComponenet.MoveNext()) { TSM.Part element = elementOfComponenet.Current as TSM.Part; try { if (element is TSM.Part) { if (element.Identifier.ID == part.Identifier.ID) { element = CP; element.Modify(); } else { continue; } } else { continue; } } catch (Exception) { throw; } } } part.Delete(); planeHandler.SetCurrentTransformationPlane(original); } } this.model.CommitChanges(); }