Beispiel #1
0
        public _Assembly(TSM.Assembly assembly)
        {
            _assembly = assembly;
            _objClass = (assembly.GetMainPart() as TSM.Part).Class;

            TSM.Part mainPart = assembly.GetMainPart() as TSM.Part;
            _topInFrom = getTopInForm(mainPart);
        }
        private string getObjectName(CastUnitDrawing currentDrawing)
        {
            var currentModelObject = _myModel.SelectModelObject(currentDrawing.CastUnitIdentifier);

            TSM.Assembly currentAssembly = currentModelObject as TSM.Assembly;
            TSM.Part     currentMainPart = currentAssembly.GetMainPart() as TSM.Part;

            return(currentMainPart.Name);
        }
Beispiel #3
0
        private static ArrayList GetAssemblyParts(TSM.Assembly assembly)
        {
            ArrayList   Parts            = new ArrayList();
            IEnumerator AssemblyChildren = (assembly).GetSecondaries().GetEnumerator();

            Parts.Add((assembly).GetMainPart().Identifier);

            while (AssemblyChildren.MoveNext())
            {
                Parts.Add((AssemblyChildren.Current as TSM.ModelObject).Identifier);
            }

            return(Parts);
        }
Beispiel #4
0
        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)
                {
                    TSM.Assembly assembly = selectedObjects.Current as TSM.Assembly;
                    selectedAssemblys.Add(assembly);
                }
            }

            return(selectedAssemblys);
        }
        public static bool main(TSD.Drawing drawing)
        {
            bool drawingStatus = true;

            TSM.Model _myModel = new TSM.Model();

            if (drawing is TSD.GADrawing)
            {
                drawingStatus = checkDrawing(UserSettings_UDA._GA_drawingProperties, drawing as TSD.GADrawing);
            }
            else if (drawing is TSD.CastUnitDrawing)
            {
                TSD.CastUnitDrawing cu = drawing as TSD.CastUnitDrawing;
                TSM.Assembly        currentAssembly = _myModel.SelectModelObject(cu.CastUnitIdentifier) as TSM.Assembly;
                TSM.Part            currentMainPart = currentAssembly.GetMainPart() as TSM.Part;

                drawingStatus = checkDrawing(UserSettings_UDA._CU_drawingProperties, cu);
                if (drawingStatus)
                {
                    drawingStatus = checkPart(UserSettings_UDA._CU_partProperties, currentMainPart, cu);
                }
            }
            else if (drawing is TSD.AssemblyDrawing)
            {
                TSD.AssemblyDrawing asd             = drawing as TSD.AssemblyDrawing;
                TSM.Assembly        currentAssembly = _myModel.SelectModelObject(asd.AssemblyIdentifier) as TSM.Assembly;
                TSM.Part            currentMainPart = currentAssembly.GetMainPart() as TSM.Part;

                drawingStatus = checkDrawing(UserSettings_UDA._A_drawingProperties, asd);
                if (drawingStatus)
                {
                    drawingStatus = checkPart(UserSettings_UDA._A_partProperties, currentMainPart, asd);
                }
            }
            else if (drawing is TSD.SinglePartDrawing)
            {
                TSD.SinglePartDrawing sp = drawing as TSD.SinglePartDrawing;
                TSM.Part currentPart     = _myModel.SelectModelObject(sp.PartIdentifier) as TSM.Part;

                drawingStatus = checkDrawing(UserSettings_UDA._SP_drawingProperties, sp);
                if (drawingStatus)
                {
                    drawingStatus = checkPart(UserSettings_UDA._SP_partProperties, currentPart, sp);
                }
            }

            return(drawingStatus);
        }
Beispiel #6
0
        public static void Run(Tekla.Technology.Akit.IScript akit)
        {
            Model             model          = new Model();
            DrawingHandler    drawingHandler = new DrawingHandler();
            DrawingEnumerator drawingEnum    = drawingHandler.GetDrawingSelector().GetSelected();

            if (drawingHandler.GetActiveDrawing() == null)
            {
                while (drawingEnum.MoveNext())
                {
                    if (drawingEnum.Current is AssemblyDrawing)
                    {
                        AssemblyDrawing assemblyDrawing = drawingEnum.Current as AssemblyDrawing;
                        drawingHandler.SetActiveDrawing(assemblyDrawing, false);
                        DrawingObjectEnumerator drawingObjectEnum = drawingHandler.GetActiveDrawing().GetSheet().GetAllObjects();
                        while (drawingObjectEnum.MoveNext())
                        {
                            if (drawingObjectEnum.Current is Tekla.Structures.Drawing.Part)
                            {
                                Tekla.Structures.Drawing.Part part = drawingObjectEnum.Current as Tekla.Structures.Drawing.Part;
                                ArrayList array = new ArrayList();
                                array.Add(model.SelectModelObject(new Tekla.Structures.Identifier(part.ModelIdentifier.ID)));
                                Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector();
                                modelObjectSelector.Select(array);
                                ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects();
                                while (modelObjectEnum.MoveNext())
                                {
                                    if (modelObjectEnum.Current is Tekla.Structures.Model.Part)
                                    {
                                        Tekla.Structures.Model.Part     mpart    = modelObjectEnum.Current as Tekla.Structures.Model.Part;
                                        Tekla.Structures.Model.Assembly assembly = mpart.GetAssembly();
                                        Tekla.Structures.Model.Part     mainPart = (Tekla.Structures.Model.Part)assembly.GetMainPart();
                                        assemblyDrawing.Name = mainPart.Name;
                                        assemblyDrawing.Modify();
                                        assemblyDrawing.CommitChanges();
                                    }
                                }
                                modelObjectSelector.Select(new ArrayList());
                            }
                        }
                        drawingHandler.CloseActiveDrawing();
                    }
                }
            }
        }
        private static ArrayList findWrongParts(List <string> ignoreClasses, TSM.Assembly assembly)
        {
            TSM.Part  mainPart       = assembly.GetMainPart() as TSM.Part;
            ArrayList secondaryParts = new ArrayList(assembly.GetSecondaries());
            ArrayList wrongParts     = new ArrayList();

            ignoreClasses.Add(mainPart.Class);

            foreach (TSM.Part currentPart in secondaryParts)
            {
                if (ignoreClasses.Contains(currentPart.Class) == false)
                {
                    wrongParts.Add(currentPart);
                }
            }

            return(wrongParts);
        }
        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 void removeAssemblyPropertys(TSM.Assembly currentAssembly, Tekla.Technology.Akit.IScript akit)
        {
            ArrayList currentSelection = new ArrayList();

            currentSelection.Add(currentAssembly);

            TSM.UI.ModelObjectSelector selector = new TSM.UI.ModelObjectSelector();
            selector.Select(currentSelection);

            akit.Callback("acmd_display_selected_object_dialog", "", "View_01 window_1");
            TSM.Part currentMainPart = currentAssembly.GetMainPart() as TSM.Part;

            if (!currentMainPart.Material.MaterialString.StartsWith("C"))
            {
                akit.ValueChange("steelassembly_1", "AssemblyPrefix", "");
                akit.ValueChange("steelassembly_1", "AssemblyStartNumber", "");
                akit.ValueChange("steelassembly_1", "AssemblyName", "");
                akit.PushButton("modify_button", "steelassembly_1");
                akit.PushButton("OK_button", "steelassembly_1");
            }
            else
            {
                if (currentMainPart.CastUnitType == 0)
                {
                    akit.ValueChange("precastassembly_1", "AssemblyPrefix", "");
                    akit.ValueChange("precastassembly_1", "AssemblyStartNumber", "");
                    akit.ValueChange("precastassembly_1", "AssemblyName", "");
                    akit.PushButton("modify_button", "precastassembly_1");
                    akit.PushButton("OK_button", "precastassembly_1");
                }
                else
                {
                    akit.ValueChange("insituassembly_1", "AssemblyPrefix", "");
                    akit.ValueChange("insituassembly_1", "AssemblyStartNumber", "");
                    akit.ValueChange("insituassembly_1", "AssemblyName", "");
                    akit.PushButton("modify_button", "insituassembly_1");
                    akit.PushButton("OK_button", "insituassembly_1");
                }
            }
        }
Beispiel #10
0
        public string GetAssemblyNumbers()
        {
            Model model = new Model();

            Tekla.Structures.Model.UI.ModelObjectSelector selector = new Tekla.Structures.Model.UI.ModelObjectSelector();
            ModelObjectEnumerator enumerator = selector.GetSelectedObjects();

            SortedSet <string> list = new SortedSet <string>();

            string current = string.Empty;

            string assemblyNumber       = string.Empty;
            string assemblyPhase        = string.Empty;
            string assemblySerialNumber = string.Empty;
            string assemblyPrefix       = string.Empty;

            Phase phase = new Phase();

            while (enumerator.MoveNext())
            {
                Beam beam = enumerator.Current as Beam;

                if (beam != null)
                {
                    Tekla.Structures.Model.Assembly assembly = beam.GetAssembly() as Tekla.Structures.Model.Assembly;

                    assembly.GetReportProperty("ASSEMBLY_POS", ref assemblyNumber);
                    assembly.GetPhase(out phase);
                    assemblyPhase = phase.PhaseNumber.ToString();
                    assembly.GetReportProperty("ASSEMBLY_PREFIX", ref assemblyPrefix);

                    var arr = assemblyNumber.Split('/');

                    assemblySerialNumber = arr[1];

                    current = assemblySerialNumber;

                    list.Add(current);
                }

                ContourPlate contourPlate = enumerator.Current as ContourPlate;

                if (contourPlate != null)
                {
                    Tekla.Structures.Model.Assembly assemblyCPL = contourPlate.GetAssembly() as Tekla.Structures.Model.Assembly;

                    assemblyCPL.GetReportProperty("ASSEMBLY_POS", ref assemblyNumber);
                    assemblyCPL.GetPhase(out phase);
                    assemblyPhase = phase.PhaseNumber.ToString();
                    assemblyCPL.GetReportProperty("ASSEMBLY_PREFIX", ref assemblyPrefix);

                    var arr = assemblyNumber.Split('/');

                    assemblySerialNumber = arr[1];

                    current = assemblySerialNumber;

                    list.Add(current);
                }
            }

            string shorten = this.ReturnShortenName(list);

            string result = "El. " + shorten + "(" + assemblyPhase + "_" + assemblyPrefix + ")";

            return(result);
        }
        //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);
                    }
                }
            }
        }