/// <summary> /// HeghlightElements(List<Elm>elements, color) - change color of elements in list /// </summary> /// <param name="elements"></param> /// <param name="color"></param> public void HighlightElements(Dictionary<string, Elm> els, int color = 1) { Log.set("TS_OpenAPI.HighLightElements"); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); int totalCnt = objectList.GetSize(); var colorObjects = new List<ModelObject>(); while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart != null) { string guid = string.Empty; myPart.GetReportProperty("GUID", ref guid); if (els.ContainsKey(guid)) colorObjects.Add(myPart); } } var _color = new Color(0.0, 0.0, 1.0); ModelObjectVisualization.SetTransparencyForAll(TemporaryTransparency.SEMITRANSPARENT); ModelObjectVisualization.SetTemporaryState(colorObjects, _color); log.Info("\tTotal elements without price = " + colorObjects.Count); Log.exit(); }
public static List <TSM.Reinforcement> getReinforcements(TSM.Part part) { List <TSM.Reinforcement> reinf = new List <TSM.Reinforcement>(); TSM.ModelObjectEnumerator reinforcementEnum = part.GetReinforcements(); while (reinforcementEnum.MoveNext()) { reinf.Add(reinforcementEnum.Current as TSM.Reinforcement); } return(reinf); }
private static List <TSM.Assembly> getSelectedAssemblys(TSM.ModelObjectEnumerator selectedObjects) { List <TSM.Assembly> selectedAssemblys = new List <TSM.Assembly>(); while (selectedObjects.MoveNext()) { if (selectedObjects.Current is TSM.Assembly) { selectedAssemblys.Add(selectedObjects.Current as TSM.Assembly); } } return(selectedAssemblys); }
private void GetIdNumbers_Click(object sender, EventArgs e) { Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnumerator = drawingHandler.GetDrawingObjectSelector().GetSelected(); ArrayList SelectedObjectArray = new ArrayList(); ArrayList MarkArray = new ArrayList(); while (drawingObjectEnumerator.MoveNext()) { if (drawingObjectEnumerator.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part part = drawingObjectEnumerator.Current as Tekla.Structures.Drawing.Part; SelectedObjectArray.Add(model.SelectModelObject(new Identifier(part.ModelIdentifier.ID))); DrawingObjectArray.Add(part); } if (drawingObjectEnumerator.Current is Tekla.Structures.Drawing.Bolt) { Tekla.Structures.Drawing.Bolt bolt = drawingObjectEnumerator.Current as Tekla.Structures.Drawing.Bolt; SelectedObjectArray.Add(model.SelectModelObject(new Identifier(bolt.ModelIdentifier.ID))); DrawingObjectArray.Add(bolt); } } modelObjectSelector.Select(SelectedObjectArray); Tekla.Structures.Model.ModelObjectEnumerator modelObjectEnumerator = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnumerator.MoveNext()) { if (modelObjectEnumerator.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part modelPart = modelObjectEnumerator.Current as Tekla.Structures.Model.Part; MarkArray.Add(modelPart.Identifier.ID.ToString()); } if (modelObjectEnumerator.Current is Tekla.Structures.Model.BoltGroup) { Tekla.Structures.Model.BoltGroup modelBolt = modelObjectEnumerator.Current as Tekla.Structures.Model.BoltGroup; MarkArray.Add(modelBolt.Identifier.ID.ToString()); } } MarkArray.Sort(); string MarkList = ""; foreach (string strMark in MarkArray) { MarkList = strMark + " " + MarkList; } Clipboard.SetDataObject(MarkList); richTextBox1.Text = MarkList; drawingHandler.GetDrawingObjectSelector().SelectObjects(DrawingObjectArray, false); }
private void GetMarks(string MarkType) { Model model = new Model(); Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); Drawing drawing = drawingHandler.GetActiveDrawing(); DrawingObjectEnumerator drawingObjectEnumerator = drawingHandler.GetDrawingObjectSelector().GetSelected(); ArrayList SelectedObjectArray = new ArrayList(); ArrayList MarkArray = new ArrayList(); while (drawingObjectEnumerator.MoveNext()) { if (drawingObjectEnumerator.Current is Tekla.Structures.Drawing.Part) { Tekla.Structures.Drawing.Part part = drawingObjectEnumerator.Current as Tekla.Structures.Drawing.Part; SelectedObjectArray.Add(model.SelectModelObject(new Identifier(part.ModelIdentifier.ID))); DrawingObjectArray.Add(part); } } modelObjectSelector.Select(SelectedObjectArray); Tekla.Structures.Model.ModelObjectEnumerator modelObjectEnumerator = model.GetModelObjectSelector().GetSelectedObjects(); while (modelObjectEnumerator.MoveNext()) { if (modelObjectEnumerator.Current is Tekla.Structures.Model.Part) { Tekla.Structures.Model.Part modelPart = modelObjectEnumerator.Current as Tekla.Structures.Model.Part; string mark = ""; try { modelPart.GetReportProperty(MarkType, ref mark); if (!MarkArray.Contains(mark)) { MarkArray.Add(mark); } } catch { } } } MarkArray.Sort(); string MarkList = ""; foreach (string strMark in MarkArray) { MarkList = strMark + " " + MarkList; } Clipboard.SetDataObject(MarkList); richTextBox1.Text = MarkList; drawingHandler.GetDrawingObjectSelector().SelectObjects(DrawingObjectArray, false); }
private static void changePartToSubAssembly(TSM.Assembly assembly, ArrayList wrongParts, Tekla.Technology.Akit.IScript akit) { TSM.UI.ModelObjectSelector selector = new TSM.UI.ModelObjectSelector(); selector.Select(wrongParts); akit.Callback("acmdRemoveFromAssemblyActionCB", "", "View_01 window_1"); //assembly.Modify(); selector = new TSM.UI.ModelObjectSelector(); TSM.ModelObjectEnumerator selectionEnum = selector.GetSelectedObjects(); while (selectionEnum.MoveNext()) { if (selectionEnum.Current is TSM.Part) { TSM.Part newPart = selectionEnum.Current as TSM.Part; TSM.Assembly partNewAssembly = newPart.GetAssembly() as TSM.Assembly; ArrayList currentSelection = new ArrayList(); currentSelection.Add(assembly); selector.Select(currentSelection); TSM.ModelObjectEnumerator selectionEnum2 = selector.GetSelectedObjects(); while (selectionEnum2.MoveNext()) { if (selectionEnum2.Current is TSM.Assembly) { TSM.Assembly newAssembly = selectionEnum2.Current as TSM.Assembly; newAssembly.Add(partNewAssembly); newAssembly.Modify(); } } } } foreach (TSM.Part part in wrongParts) { TSM.Assembly newAssembly = part.GetAssembly() as TSM.Assembly; removeAssemblyPropertys(newAssembly, akit); } }
private static ArrayList GetTaskParts(TSM.Task task) { ArrayList Parts = new ArrayList(); TSM.ModelObjectEnumerator myMembers = task.GetChildren(); while (myMembers.MoveNext()) { if (myMembers.Current is TSM.Task) { Parts.AddRange(GetTaskParts(myMembers.Current as TSM.Task)); } else if (myMembers.Current is TSM.Part) { Parts.Add(myMembers.Current.Identifier); } } return(Parts); }
public List<Emb> ReadCustomParts() { List<Emb> result = new List<Emb>(); // TSM.Model model = new TSM.Model(); TSM.ModelObjectSelector selector = this.model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); List<Part> parts = new List<Part>(); while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart == null) continue; if (myPart.Class != "100" && myPart.Class != "101") continue; parts.Add(myPart); if (myPart.Name.Contains("SBKL")) continue; // var project_code = myPart.GetUserProperty("j_fabricator_name", ref vendorName); } return result; }
public static ArrayList getParts(Tekla.Structures.Model.UI.View view) { ArrayList visibleParts = new ArrayList(); Point min = new Point(-999999, -999999, -999999); Point max = new Point(999999, 999999, 999999); TSM.UI.ModelObjectSelector selector = new TSM.UI.ModelObjectSelector(); TSM.ModelObjectEnumerator allObjects = selector.GetObjectsByBoundingBox(min, max, view); while (allObjects.MoveNext()) { if (allObjects.Current is TSM.Part) { if ((allObjects.Current as TSM.Part).Material.MaterialString.StartsWith("C")) { visibleParts.Add(allObjects.Current); } } } return(visibleParts); }
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 { } }
public Tekla() { } // конструктор класса Tekla - пока пустой 6.4.17 public List<Elm> Read(string dir = "", string name = "") { Log.set("TS_OpenAPI.Read"); List<Elm> elements = new List<Elm>(); // 6.4.17 //TSM.Model model = new TSM.Model(); ////////////List<Part> parts = new List<Part>(); ModInfo = model.GetInfo(); if (dir != "" && ModInfo.ModelPath != dir || name != "" && ModInfo.ModelName != String.Concat(name, ".db1")) Msg.F("Tekla.Read: Another model loaded, not", name); ModInfo.ModelName = ModInfo.ModelName.Replace(".db1", ""); TSM.ModelObjectSelector selector = model.GetModelObjectSelector(); System.Type[] Types = new System.Type[1]; Types.SetValue(typeof(Part), 0); TSM.ModelObjectEnumerator objectList = selector.GetAllObjectsWithType(Types); int totalCnt = objectList.GetSize(); var progress = new TSM.Operations.Operation.ProgressBar(); bool displayResult = progress.Display(100, "TSmatch", "Reading model. Pass component records:", "Cancel", " "); int ii = 0; while (objectList.MoveNext()) { TSM.Part myPart = objectList.Current as TSM.Part; if (myPart != null) { ii++; double lng = 0.0; double weight = 0.0; double vol = 0.0; string guid = ""; string mat_type = ""; double price = 0.0; myPart.GetReportProperty("GUID", ref guid); myPart.GetReportProperty("LENGTH", ref lng); myPart.GetReportProperty("WEIGHT", ref weight); myPart.GetReportProperty("VOLUME", ref vol); myPart.GetReportProperty("MATERIAL_TYPE", ref mat_type); lng = Math.Round(lng, 0); //string cut = ""; //myPart.GetReportProperty("CAST_UNIT_TYPE", ref cut); //ModAtr.Add(new AttSet(myPart.Material.MaterialString, // profile, lng, weight, vol)); //21/6/2016 в отладке Elm.Elements.Add(new Elm()); elements.Add(new Elm(guid, myPart.Material.MaterialString, mat_type, myPart.Profile.ProfileString, lng, weight, vol, price)); // !! if (ii % 500 == 0) // progress update every 500th items { if (progress.Canceled()) { // new Log("\n\n======= TSmatch pass model CANCEL!! ======= ii=" + ii); // TSD.Show() break; } progress.SetProgress(ii.ToString(), 100 * ii / totalCnt); } } } //while progress.Close(); Scale(elements); elements.Sort(); Log.exit(); return elements; } // Read
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(); }
//InterSectionTest 3 private void button4_Click(object sender, EventArgs e) { //부재 선택 Picker picker = new Picker(); TSM.Part part = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "철근형태를 수정할 부재를 선택하세요.") as TSM.Part; TSM.Part intersectingpart = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "간섭하는 부재를 선택하세요.") as TSM.Part; //Intersection 처리 double partFrontLength = 0.0; double intersectionLength = 0.0; //할당해야함 TSG.OBB iPartOBB = CreateOrientedBoundingBox(intersectingpart); TSG.Vector partLVector = new TSG.Vector(); if (part.GetType().Name == "Beam") { TSM.Beam beam = part as TSM.Beam; TSG.LineSegment lineSegment = new TSG.LineSegment(beam.StartPoint, beam.EndPoint); TSG.Point firstPoint = TSG.Intersection.LineSegmentToObb(lineSegment, iPartOBB).Point1; TSG.Point secondPoint = TSG.Intersection.LineSegmentToObb(lineSegment, iPartOBB).Point2; partFrontLength = TSG.Distance.PointToPoint(beam.StartPoint, firstPoint); intersectionLength = TSG.Distance.PointToPoint(firstPoint, secondPoint); partLVector = new TSG.Vector(beam.EndPoint - beam.StartPoint).GetNormal(); } else if (part.GetType().Name == "ContourPlate") //ContourPlate인 경우 추후 작성 { TSM.ContourPlate contourPlate = part as TSM.ContourPlate; } //철근 그룹화 해제 후 singleRebar 저장 ModelObjectEnumerator reinforcement = part.GetReinforcements(); List <TSM.SingleRebar> singleRebars = new List <TSM.SingleRebar>(); List <TSM.SingleRebar> group = new List <TSM.SingleRebar>(); //그룹화를 위한 List int rebarCount = 0; //총 단일철근 수량 ArrayList rebarInterval = new ArrayList(); //철근 간격 (싱글 타입일 때는 철근 간격을 어떻게 구하지? > 일단 PASS) while (reinforcement.MoveNext()) { if (reinforcement.Current.GetType().Name == "SingleRebar") //부재에 속한 철근이 SingleRebar타입일 때 { TSM.SingleRebar singleRebar = reinforcement.Current as TSM.SingleRebar; singleRebars.Add(singleRebar); MessageBox.Show("SingleRebar 타입은 현재 지원 불가"); } else //부재에 속한 철근이 RebarGroup타입일 때 { TSM.RebarGroup rebarGroup = reinforcement.Current as TSM.RebarGroup; rebarInterval = rebarGroup.Spacings; //철근 간격 저장 TSM.ModelObjectEnumerator rebarEnumerator = TSM.Operations.Operation.Ungrouping(rebarGroup); while (rebarEnumerator.MoveNext()) { TSM.ModelObject rebar = rebarEnumerator.Current; TSM.SingleRebar singleRebar = rebar as TSM.SingleRebar; singleRebars.Add(singleRebar); } } rebarCount = singleRebars.Count; // 총 단일수량 저장 } //철근 재배치 for (int i = 0; i < singleRebars.Count - (intersectionLength / (double)rebarInterval[0]); i++) // 딱 안떨어지는 경우 고려해줘야함 { double frontLength = (i * (double)rebarInterval[0]); if (frontLength >= partFrontLength) { if (i == singleRebars.Count) { break; } else { for (int j = 0; j < singleRebars[i].Polygon.Points.Count; j++) { TSM.SingleRebar newSingleRebar = singleRebars[i]; TSG.Point intersectionLengthPoint = new TSG.Point(intersectionLength * partLVector.X, intersectionLength * partLVector.Y, intersectionLength * partLVector.Z); newSingleRebar.Polygon.Points[j] = newSingleRebar.Polygon.Points[j] as TSG.Point + intersectionLengthPoint; singleRebars[i].Delete(); newSingleRebar.Insert(); group.Add(newSingleRebar); } } } else { group.Add(singleRebars[i]); } } for (int i = singleRebars.Count - (int)(intersectionLength / (double)rebarInterval[0]); i < singleRebars.Count; i++) { singleRebars[i].Delete(); } TSM.RebarGroup newRebarGroup = TSM.Operations.Operation.Group(group); }
//InterSectionTest 2 private void button1_Click_1(object sender, EventArgs e) { //부재 선택 Picker picker = new Picker(); TSM.ModelObject part = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "부재를 선택하세요.") as TSM.ModelObject; TSM.ContourPlate contourPlate = part as TSM.ContourPlate; Solid solid = contourPlate.GetSolid(); //철근 정보 받기 //철근 선택 및 그룹철근 분할 ModelObjectEnumerator reinforcement = contourPlate.GetReinforcements(); List <TSM.SingleRebar> singleRebars = new List <TSM.SingleRebar>(); List <TSM.SingleRebar> group = new List <TSM.SingleRebar>(); //수정안된 철근 while (reinforcement.MoveNext()) { if (reinforcement.Current.GetType().Name == "SingleRebar") { TSM.SingleRebar singleRebar = reinforcement.Current as TSM.SingleRebar; singleRebars.Add(singleRebar); } else { TSM.RebarGroup rebarGroup = reinforcement.Current as TSM.RebarGroup; TSM.ModelObjectEnumerator rebarEnumerator = TSM.Operations.Operation.Ungrouping(rebarGroup); while (rebarEnumerator.MoveNext()) { TSM.ModelObject rebar = rebarEnumerator.Current; TSM.SingleRebar singleRebar = rebar as TSM.SingleRebar; singleRebars.Add(singleRebar); } } } //Intersect (마구리와 철근 겹치는 부분을 철근의 새 포인트로 지정한다.) TSG.LineSegment rebarLineSegment = null; ArrayList intersectLinesegment = new ArrayList(); for (int j = 0; j < singleRebars.Count; j++) //철근 선택 반복문 { TSG.Point point1 = singleRebars[j].Polygon.Points[0] as TSG.Point; TSG.Point point2 = singleRebars[j].Polygon.Points[1] as TSG.Point; TSM.SingleRebar newSingleRebar = singleRebars[j]; if (singleRebars[j].Polygon.Points.Count == 2) //직선철근일때 { rebarLineSegment = new TSG.LineSegment(point1, point2); } intersectLinesegment = solid.Intersect(rebarLineSegment); newSingleRebar.Polygon.Points[0] = intersectLinesegment[0] as TSG.Point; newSingleRebar.Polygon.Points[1] = intersectLinesegment[1] as TSG.Point; singleRebars[j].Delete(); newSingleRebar.Insert(); if (newSingleRebar.Polygon.Points[0] as TSG.Point == point1 && newSingleRebar.Polygon.Points[1] as TSG.Point == point2) { group.Add(newSingleRebar); } } TSM.RebarGroup nonmodifiedGroup = TSM.Operations.Operation.Group(group); }
//InterSectionTest 1 private void button3_Click(object sender, EventArgs e) { //기본 객체 생성 TSM.Part girder = null; TSM.Component component = new TSM.Component(); TSM.Part endPiece = null; List <TSM.ContourPlate> endPieceList = new List <TSM.ContourPlate>(); //1. 부재를 Input 으로 받는다. Picker picker = new Picker(); TSM.ModelObject part = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "부재를 선택하세요.") as TSM.ModelObject; if (part.GetType().Name == "Beam") //선택한 거더가 단일객체일 경우 { girder = part as TSM.Beam; endPiece = picker.PickObject(Picker.PickObjectEnum.PICK_ONE_OBJECT, "부재를 선택하세요.") as TSM.ContourPlate; //연장할 마구리를 직접 선택 //마구리 객체 OBB 생성 (추후 수정 - Girder 단일부재일 때도 마구리 1개이상 가능하므로) TSG.OBB obb = CreateOrientedBoundingBox(endPiece); //마구리 OBB 객체 생성 TSG.LineSegment rebarLineSegment = null; //철근 선택 및 그룹철근 분할 ModelObjectEnumerator reinforcement = girder.GetReinforcements(); List <TSM.SingleRebar> singleRebars = new List <TSM.SingleRebar>(); List <TSM.SingleRebar> group1 = new List <TSM.SingleRebar>(); //수정된 철근 List <TSM.SingleRebar> group2 = new List <TSM.SingleRebar>(); //수정안된 철근 while (reinforcement.MoveNext()) { if (reinforcement.Current.GetType().Name == "SingleRebar") //부재 내 철근이 SingleRebar타입일때 { TSM.SingleRebar singleRebar = reinforcement.Current as TSM.SingleRebar; singleRebars.Add(singleRebar); } else //부재 내 철근이 rebarGroup타입일때 { TSM.RebarGroup rebarGroup = reinforcement.Current as TSM.RebarGroup; TSM.ModelObjectEnumerator rebarEnumerator = TSM.Operations.Operation.Ungrouping(rebarGroup); while (rebarEnumerator.MoveNext()) { TSM.ModelObject rebar = rebarEnumerator.Current; TSM.SingleRebar singleRebar = rebar as TSM.SingleRebar; singleRebars.Add(singleRebar); } } } for (int j = 0; j < singleRebars.Count; j++) //철근 선택 반복문 { TSG.Point rebarStartPoint = singleRebars[j].Polygon.Points[0] as TSG.Point; TSG.Point rebarEndPoint = singleRebars[j].Polygon.Points[1] as TSG.Point; TSM.SingleRebar newSingleRebar = singleRebars[j]; //기존 철근을 삭제하고 형태가 변형된 새 철근 삽입 if (singleRebars[j].Polygon.Points.Count == 2) //직선철근일때 { rebarLineSegment = new TSG.LineSegment(rebarStartPoint, rebarEndPoint); } TSG.LineSegment intersectLine = TSG.Intersection.LineSegmentToObb(rebarLineSegment, obb); //만나는 점이 하나일 때 output 형태 > 두 점이 같은지점으로 찍힘 if (intersectLine != null) // 철근과 마구리가 만날때 / 한 점만 만날때는 Linesegment의 point1 과 point2 가 같은 값임 { //철근 선을 연장 rebarLineSegment = new TSG.LineSegment(rebarStartPoint, rebarEndPoint + new TSG.Point(0, 100000, 0)); //추후 수정( y방향이 아니라 철근의 진행방향으로) intersectLine = TSG.Intersection.LineSegmentToObb(rebarLineSegment, obb); //마구리 가까운쪽이 철근 Point1 인경우 if (intersectLine.Point1.Equals(intersectLine.Point2)) { rebarLineSegment = new TSG.LineSegment(rebarStartPoint + new TSG.Point(0, 100000, 0), rebarEndPoint); intersectLine = TSG.Intersection.LineSegmentToObb(rebarLineSegment, obb); newSingleRebar.Polygon.Points[0] = intersectLine.Point2; } else //마구리 가까운쪽이 철근 Point2 인경우 { newSingleRebar.Polygon.Points[1] = intersectLine.Point2; } singleRebars[j].Delete(); newSingleRebar.Insert(); group1.Add(newSingleRebar); } else { group2.Add(singleRebars[j]); //수정안된 철근들 그룹에 넣기 } TSM.RebarGroup modifiedGroup = TSM.Operations.Operation.Group(group1); TSM.RebarGroup nonmodifiedGroup = TSM.Operations.Operation.Group(group2); } } else if (part.ToString() == "Tekla.Structures.Model.Component") //선택한 거더가 컴포넌트일 경우 { component = part as TSM.Component; //반환된 Girder의 타입 결정 TSM.Assembly assembly = component.GetAssembly(); if (assembly.GetMainPart().GetType().Name == "Beam") { girder = assembly.GetMainPart() as TSM.Beam; } else if (assembly.GetMainPart().GetType().Name == "ContourPlate") { girder = assembly.GetMainPart() as TSM.ContourPlate; } // Input으로 받은 부재에 연결되어있는 마구리와 철근정보를 받아온다. //반환된 Secondaries의 타입 결정 endPieceList = new List <TSM.ContourPlate>(); for (int i = 0; i < assembly.GetSecondaries().Count; i++) { TSM.Part secondary = assembly.GetSecondaries()[i] as TSM.Part; if (secondary.Name == "EndPiece") { endPieceList.Add(secondary as TSM.ContourPlate); } } } }