public static void Run(Tekla.Technology.Akit.IScript akit) { Model model = new Model(); //Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); DrawingHandler dh = new DrawingHandler(); DrawingObjectEnumerator doe = dh.GetDrawingObjectSelector().GetSelected(); while (doe.MoveNext()) { string CONN_CODE_END1 = "", CONN_CODE_END2 = ""; if (doe.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part dPart = (Tekla.Structures.Drawing.Part)doe.Current; Tekla.Structures.Model.Part mPart = (Tekla.Structures.Model.Part)model.SelectModelObject((Identifier)dPart.ModelIdentifier); if (mPart is Beam) { Beam beam = (Beam)mPart; ViewBase view = dPart.GetView(); mPart.GetUserProperty("CONN_CODE_END1", ref CONN_CODE_END1); mPart.GetUserProperty("CONN_CODE_END2", ref CONN_CODE_END2); if (CONN_CODE_END1 != "") { Tekla.Structures.Drawing.Text text = new Tekla.Structures.Drawing.Text(view, beam.StartPoint + new Point(200, 200), CONN_CODE_END1, new LeaderLinePlacing(beam.StartPoint)); text.Insert(); } if (CONN_CODE_END2 != "") { Tekla.Structures.Drawing.Text text = new Tekla.Structures.Drawing.Text(view, beam.EndPoint + new Point(200, 200), CONN_CODE_END2, new LeaderLinePlacing(beam.EndPoint)); text.Insert(); } } } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); if (modelObjectEnum.GetSize() > 0) { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part part = (Tekla.Structures.Model.Part)modelObjectEnum.Current; string USER_FIELD_3 = "", USER_FIELD_4 = "", PRELIM_MARK = ""; part.GetUserProperty("USER_FIELD_3", ref USER_FIELD_3); part.GetUserProperty("USER_FIELD_4", ref USER_FIELD_4); part.GetUserProperty("PRELIM_MARK", ref PRELIM_MARK); USER_FIELD_4 = USER_FIELD_4.Replace("(?)", ""); if (USER_FIELD_3 == "Z") { part.SetUserProperty("USER_FIELD_2", PRELIM_MARK); part.SetUserProperty("PRELIM_MARK", USER_FIELD_3 + USER_FIELD_4); part.Modify(); } } } model.CommitChanges(); MessageBox.Show("Process Complete"); } } catch { } }
private static void swapTopInForm(TSM.Part part) { int topInForm = 6; part.GetUserProperty("FixedMainView", ref topInForm); if (topInForm == (int)TopInFormEnum.FRONT) { part.SetUserProperty("FixedMainView", (int)TopInFormEnum.BACK); } else if (topInForm == (int)TopInFormEnum.BACK) { part.SetUserProperty("FixedMainView", (int)TopInFormEnum.FRONT); } else if (topInForm == (int)TopInFormEnum.START) { part.SetUserProperty("FixedMainView", (int)TopInFormEnum.END); } else if (topInForm == (int)TopInFormEnum.END) { part.SetUserProperty("FixedMainView", (int)TopInFormEnum.START); } else if (topInForm == (int)TopInFormEnum.TOP) { part.SetUserProperty("FixedMainView", (int)TopInFormEnum.BOTTOM); } else if (topInForm == (int)TopInFormEnum.BOTTOM) { part.SetUserProperty("FixedMainView", (int)TopInFormEnum.TOP); } }
private TopInFormEnum getTopInForm(TSM.Part part) { int topInForm = 6; part.GetUserProperty("FixedMainView", ref topInForm); TopInFormEnum value = (TopInFormEnum)topInForm; return(value); }
public static bool checkProperty(string prop, TSM.Part part, TSD.Drawing drawing) { string dummy = "dummy"; part.GetUserProperty(prop, ref dummy); int dummyInt = -987; part.GetUserProperty(prop, ref dummyInt); bool status = checker(dummy, dummyInt); if (status == false) { MainWindow._form.consoleOutput(drawing.Mark + " " + prop + " is not set", "L2"); } return(status); }
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 { } }