public CurrentSelectedObjects(string channelProfile, string channelClass, Model Model) { Model ThisModel = Model; //User interface for the model TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector(); // Model Object Enumerator (from Tekla.Structures.Model namespace) collection of selected objects ModelObjectEnumerator SelectedObjects = GetSelectedObjects.GetSelectedObjects(); // Change channel profile to value passed in constructor ChannelProfile = channelProfile; // Set class to value passed in constructor ChannelClass = channelClass; // go through objects in model objects enumerator MoveNext returns false at end of collection while (SelectedObjects.MoveNext()) { // cast as beam, model 'object' class is just an abstract class, we must call out beams specifically. Beam ThisBeam = SelectedObjects.Current as Beam; if (ThisBeam != null) { // Pass profile and class for beam from constructor ThisBeam.Profile.ProfileString = ChannelProfile; ThisBeam.Class = ChannelClass; //Apply new start point and end point ThisBeam.StartPoint = new T3D.Point(1000, 0, 0); ThisBeam.EndPoint = new T3D.Point(4000, 1000, 0); // Method to modify beam and apply changes ThisBeam.Modify(); } } }
public static void Run(Tekla.Technology.Akit.IScript akit) { MyModel.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); Tekla.Structures.Model.UI.ModelObjectSelector MS = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator Menum = MS.GetSelectedObjects(); List <Beam> AllPartList = EnumtoArray(Menum).OfType <Beam>().ToList(); List <int> AllPartListIds = AllPartList.Select(x => x.Identifier.ID).ToList(); List <Beam> BeamList = AllPartList.Where(x => x.Name == "BEAM").ToList(); int ConCount = 0; foreach (Beam bem in BeamList) { bem.Select(); // Start Side Beam StartBeam = GetPrimary(bem, AllPartListIds, "Start"); if (StartBeam != null && !IsConnectionApplied(bem, StartBeam)) { //MessageBox.Show(StartBeam.Identifier.ID.ToString()); ApplyConn(StartBeam, bem, "Start"); ConCount++; } Beam EndBeam = GetPrimary(bem, AllPartListIds, "End"); if (EndBeam != null && !IsConnectionApplied(bem, EndBeam)) { ApplyConn(EndBeam, bem, "End"); ConCount++; } } MessageBox.Show("Total Connection Applied : " + ConCount.ToString()); }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); TSMUI.ModelObjectSelector modelObjectSelector = new TSMUI.ModelObjectSelector(); ModelObjectEnumerator objectsToCopyEnum = modelObjectSelector.GetSelectedObjects(); ArrayList objectsToCopyArray = new ArrayList(); while (objectsToCopyEnum.MoveNext()) { objectsToCopyArray.Add(objectsToCopyEnum.Current); } Beam sourceBeam = PickBeam(); ArrayList modelObjectSelectorArray = new ArrayList(); modelObjectSelectorArray.Add(sourceBeam); modelObjectSelector.Select(modelObjectSelectorArray); modelObjectSelectorArray.Clear(); CopyToAnotherBeamByEndPoint(objectsToCopyArray, sourceBeam); } catch { } }
public static void Run(Tekla.Technology.Akit.IScript akit) { try { Model model = new Model(); ModelObjectEnumerator modelObjectEnum = model.GetModelObjectSelector().GetSelectedObjects(); System.Collections.ArrayList array = new System.Collections.ArrayList(); if (modelObjectEnum.GetSize() == 0) { Picker picker = new Picker(); Part part = (Part)picker.PickObject(Tekla.Structures.Model.UI.Picker.PickObjectEnum.PICK_ONE_PART); part.Insert(); array.Add(part); } else { while (modelObjectEnum.MoveNext()) { if (modelObjectEnum.Current is Part) { Part part = (Part)modelObjectEnum.Current; part.Insert(); array.Add(part); } } } model.CommitChanges(); Tekla.Structures.Model.UI.ModelObjectSelector modelobjsel = new Tekla.Structures.Model.UI.ModelObjectSelector(); modelobjsel.Select(array); } catch { } }
private static void selectInitialObjects(List <Assembly> selectedAssemblys) { ArrayList initialSelectedAssemblys = new ArrayList(selectedAssemblys); var selector = new TSM.UI.ModelObjectSelector(); selector.Select(initialSelectedAssemblys); }
private void Button1_Click(object sender, RoutedEventArgs e) { Model Model = new Model(); if (!Model.GetConnectionStatus()) { MessageBox.Show("Tekla is not open."); Environment.Exit(1); } string text = textbox1.Text; TSMUI.ModelObjectSelector MS = new TSMUI.ModelObjectSelector(); ArrayList ModelObjectLists = new ArrayList(); if (string.IsNullOrWhiteSpace(textbox1.Text)) { return; } else { List <string> guidList = text.Split(' ').ToList(); foreach (string guid in guidList) { Identifier ModelID = Model.GetIdentifierByGUID(guid); var rebar = Model.SelectModelObject(ModelID); if (rebar is RebarGroup) { ModelObjectLists.Add(rebar); } else { var Singlerebar = Model.SelectModelObject(ModelID) as SingleRebar; ModelObjectLists.Add(Singlerebar); } } } MS.Select(ModelObjectLists); Tekla.Structures.ModelInternal.Operation.dotStartAction("ZoomToSelected", ""); Model.CommitChanges(); ModelObjectEnumerator objects = new TSMUI.ModelObjectSelector().GetSelectedObjects(); if (objects.GetSize() < 1) { Tekla.Structures.Model.Operations.Operation.DisplayPrompt("No objects selected. Check if GUID is correct."); } }
private void connectParts() { List <BoltGroup> boltGroups = new List <BoltGroup>(); Picker picker = new Picker(); Tekla.Structures.Model.UI.ModelObjectSelector selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator enumerator = selector.GetSelectedObjects(); foreach (ModelObject modelObject in enumerator) { BoltGroup boltGroup = (BoltGroup)modelObject; boltGroups.Add(boltGroup); } foreach (BoltGroup group in boltGroups) { int partsBoltedBefore; int partsBoltedAfter; do { Solid solid = group.GetSolid(); partsBoltedBefore = group.GetOtherPartsToBolt().Count; Double boltLength = 0.0; Point maximumPoint = solid.MaximumPoint; Point minimumPoint = solid.MinimumPoint; Tekla.Structures.Model.ModelObjectSelector groupSelector = model.GetModelObjectSelector(); ModelObjectEnumerator collidingObjects = groupSelector.GetObjectsByBoundingBox(minimumPoint, maximumPoint); while (collidingObjects.MoveNext()) { Part part = collidingObjects.Current as Part; if (part != null) { group.AddOtherPartToBolt(part); } } group.BoltStandard = "4017-8.8"; group.Modify(); group.GetReportProperty("LENGTH", ref boltLength); if (group.BoltStandard == "4017-8.8" && boltLength % 10 != 0) { group.BoltStandard = "4014-8.8"; } group.Modify(); partsBoltedAfter = group.GetOtherPartsToBolt().Count; group.CutLength = boltLength + 20; } while (partsBoltedBefore != partsBoltedAfter); } model.CommitChanges(); }
public static void Run(Tekla.Technology.Akit.IScript akit) { ModelObjectEnumerator moe = new Tekla.Structures.Model.UI.ModelObjectSelector().GetSelectedObjects(); System.Collections.ArrayList hiddenFirsts = new System.Collections.ArrayList(); foreach (ModelObject m in moe) { if (m != null && m is RebarGroup && (m as RebarGroup).ExcludeType != RebarGroup.ExcludeTypeEnum.EXCLUDE_TYPE_NONE) { hiddenFirsts.Add(m); } } new Tekla.Structures.Model.UI.ModelObjectSelector().Select(hiddenFirsts); }
private void buttonExport_Click(object sender, EventArgs e) { var selection = new Picker() .PickObjects(Picker.PickObjectsEnum.PICK_N_OBJECTS, "Pick Objects") .ToAList <ModelObject>(); var selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); selector.Select(new ArrayList(selection), false); var modelPath = _model.GetInfo().ModelPath; var modelName = _model.GetInfo().ModelName.Split('.')[0]; ExportIFC($"{modelPath}\\IFC\\OUT_{modelName}"); }
public ThisDataToFile(bool allObjects, Model model) { this.AllObjects = allObjects; this.Model = model; ModelObjectEnumerator ModelObjectsToWriteOut = null; if (allObjects) { // Select all objects in the model that are beams and add to enumeration ModelObjectsToWriteOut = model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM); } else { // use model object selector to get selected objects TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector(); // Get selected objects in model and add to enumeration ModelObjectsToWriteOut = GetSelectedObjects.GetSelectedObjects(); } // get file name string FileName = "BeamsToTextFile"; // Write directly into model folder using System.IO namespace. string FinalFileName = Path.Combine(model.GetInfo().ModelPath, FileName); // use new StreamWriter from System.IO to write new text file in specified location using (StreamWriter FileWriter = new StreamWriter(FinalFileName)) { while (ModelObjectsToWriteOut.MoveNext()) { // Move through beams in collection Beam ThisBeam = ModelObjectsToWriteOut.Current as Beam; if (ThisBeam != null) { string DataLineForFile = "GUID: " + model.GetGUIDByIdentifier(ThisBeam.Identifier) + "," + "Profile: " + ThisBeam.Profile.ProfileString + "," + // Write beam profile "Material: " + ThisBeam.Material.MaterialString + "," + // write beam material "Class: " + ThisBeam.Class; // write beam class FileWriter.WriteLine(DataLineForFile); } } } // Inform user that file has been exported MessageBox.Show("File Exported"); Tekla.Structures.Model.Operations.Operation.DisplayPrompt("File Exported and Written to Model Folder"); }
private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { Identifier id = e.Node.Tag as Identifier; Beam beam = new Beam(); beam.Identifier = id; ArrayList mObjects = new ArrayList(); mObjects.Add(beam); UI.ModelObjectSelector selector = new UI.ModelObjectSelector(); preventModelSelectionEvent = true; selector.Select(mObjects); preventModelSelectionEvent = false; }
public static void Run(Tekla.Technology.Akit.IScript akit) { /* * The main task for this script is to find reinforcement groups with nasty spacing values like 200.15 or 150.48. Tekla rounds up or down some small accurate numbers, * the key is to found such interval to make this script work. */ var reportName = "DecimalSpacingGroups"; var reportFolder = string.Empty; Tekla.Structures.TeklaStructuresSettings.GetAdvancedOption("XS_REPORT_OUTPUT_DIRECTORY", ref reportFolder); var path = new Model().GetInfo().ModelPath + reportFolder.Replace(".\\", "\\") + "\\" + reportName + "_" + Environment.UserName + ".xsr"; ModelObjectEnumerator moe = new Tekla.Structures.Model.UI.ModelObjectSelector().GetSelectedObjects(); System.Collections.ArrayList decimalgroups = new System.Collections.ArrayList(); var pb = new Tekla.Structures.Model.Operations.Operation.ProgressBar(); int i = 0; foreach (BaseRebarGroup m in moe) { pb.Display(100, "Processing data", "Please wait", "Cancel", "0%"); if (m != null) { foreach (double spacing in m.Spacings) { if (spacing % 1 > 0.009) // this should be changed like: >0.009999999999999999 & <0.999999999999999999 but it needs some tests { decimalgroups.Add(m); } } } var percentage = (i++) * 100 / moe.GetSize(); pb.SetProgress(percentage.ToString() + "%", percentage); } pb.Close(); using (System.IO.StreamWriter sw = new StreamWriter(path)) { foreach (ModelObject m in decimalgroups) { sw.WriteLine(string.Format("guid: {0}", m.Identifier.GUID.ToString().ToUpper())); } } Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Operation finished"); Tekla.Structures.Model.Operations.Operation.DisplayReport(path); }
private List<ModelObjectEnumerator> GetObjectsToCheck(bool checkAll) { Model model = new Model(); List<ModelObjectEnumerator> list = new List<ModelObjectEnumerator>(); if (checkAll) { list.Add(model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM)); list.Add(model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.CONTOURPLATE)); list.Add(model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.POLYBEAM)); } else { Tekla.Structures.Model.UI.ModelObjectSelector modelObjectSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); ModelObjectEnumerator selectedObjects = modelObjectSelector.GetSelectedObjects(); list.Add(selectedObjects); } return list; }
private static void exportCurrentAssembly(Assembly assembly) { ArrayList currentAssemblySelect = new ArrayList(); currentAssemblySelect.Add(assembly); var selector = new TSM.UI.ModelObjectSelector(); selector.Select(currentAssemblySelect); try { string name = getFileName(assembly); exportIFC(name); } catch { MessageBox.Show("Element sisaldab keelatuid märke"); } }
private void SelectModelObjectsInUi(List <int> ids) { var modelObjects = new ArrayList(); ids.ForEach(id => { var modelObject = _model.SelectModelObject(new Identifier(id)); if (modelObject == null) { return; } modelObjects.Add(modelObject); }); var selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); selector.Select(modelObjects); }
private void Button_ModifySelected_Click(object sender, RoutedEventArgs e) { TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector(); ModelObjectEnumerator SelectedObjects = GetSelectedObjects.GetSelectedObjects(); while (SelectedObjects.MoveNext()) { Beam ThisBeam = SelectedObjects.Current as Beam; if (ThisBeam != null) { ThisBeam.Profile.ProfileString = "I20_8239_89"; ThisBeam.Class = "6"; ThisBeam.StartPoint = new T3D.Point(0, 1000, 0); ThisBeam.EndPoint = new T3D.Point(4000, 1000, 0); ThisBeam.Modify(); } } Model.CommitChanges(); }
private static void assemblyManager(Assembly currentAssembly, Tekla.Technology.Akit.IScript akit) { ArrayList currentSelection = new ArrayList(); currentSelection.Add(currentAssembly); var ModelSelector = new TSM.UI.ModelObjectSelector(); ModelSelector.Select(currentSelection); removeAssemblyPropertys(currentAssembly, akit); ArrayList subs = currentAssembly.GetSubAssemblies(); foreach (Assembly sub in subs) { assemblyManager(sub, akit); } }
private static void exportCurrentAssembly(Assembly assembly) { ArrayList currentAssemblySelect = new ArrayList(); currentAssemblySelect.Add(assembly); var selector = new TSM.UI.ModelObjectSelector(); selector.Select(currentAssemblySelect); try { string name = getFileName(assembly); exportIFC(name); } catch { MessageBox.Show("Element sisaldab keelatuid märke"); } }
private void treeView2_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { _activeTree = treeView2; contextMenuStrip1.Show(new Point(e.X + this.Location.X + this.treeView2.Bounds.X + 50, e.Y + this.Location.Y + this.treeView2.Bounds.Y)); } else { Identifier id = new Identifier(Convert.ToInt32(e.Node.Name)); //e.Node.Tag as Identifier; Beam beam = new Beam(); beam.Identifier = id; ArrayList mObjects = new ArrayList(); mObjects.Add(beam); UI.ModelObjectSelector selector = new UI.ModelObjectSelector(); preventModelSelectionEvent = true; selector.Select(mObjects); preventModelSelectionEvent = false; } }
public Dictionary <string, Assembly> GetAssemblysFromParts() { /// <summary> /// Returns assemblies from parts that have been pre-selected in the model. /// </summary> //1.)make object selector Class: Tekla.Structures.Model.UI.ModelObjectSelector selectedObjectsSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); //2.)copy selected Object Enumeration to ModelObjectEnumerator: ModelObjectEnumerator selectedParts = selectedObjectsSelector.GetSelectedObjects(); //3.)get all selected single Parts: List <Part> parts = new List <Part>(); while (selectedParts.MoveNext()) { Part ThisAssembly = selectedParts.Current as Part; if (ThisAssembly != null) { parts.Add(ThisAssembly); } } //4.)make a dictinary with all assemblies from the single parts key= AssemblyPos Nr. // delete duplicates by try-catch: Dictionary <string, Assembly> assemblies = new Dictionary <string, Assembly>(); foreach (var p in parts) { string s = ""; p.GetAssembly().GetReportProperty("ASSEMBLY_POS", ref s); try { assemblies.Add(s, p.GetAssembly()); } catch { } } return(assemblies); }
public static void Run(Tekla.Technology.Akit.IScript akit) { var reportName = "ReportFromSelected"; var reportFolder = string.Empty; Tekla.Structures.TeklaStructuresSettings.GetAdvancedOption("XS_REPORT_OUTPUT_DIRECTORY", ref reportFolder); var path = new Model().GetInfo().ModelPath + reportFolder.Replace(".\\", "\\") + "\\" + reportName + "_" + Environment.UserName + ".xsr"; ModelObjectEnumerator moe = new Tekla.Structures.Model.UI.ModelObjectSelector().GetSelectedObjects(); using (System.IO.StreamWriter sw = new StreamWriter(path)) { foreach (ModelObject m in moe) { if (m != null) { sw.WriteLine(string.Format("guid: {0}", m.Identifier.GUID.ToString().ToUpper())); } } } Tekla.Structures.Model.Operations.Operation.DisplayPrompt("Operation finished"); Tekla.Structures.Model.Operations.Operation.DisplayReport(path); }
private void WriteDataFile(bool AllObjects) { ModelObjectEnumerator ModelObjectsToWriteOut = null; if (AllObjects) { ModelObjectsToWriteOut = Model.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM); } else { TSMUI.ModelObjectSelector GetSelectedObjects = new TSMUI.ModelObjectSelector(); ModelObjectsToWriteOut = GetSelectedObjects.GetSelectedObjects(); } string FileName = "BeamToTextFile.txt"; string FinalFileName = System.IO.Path.Combine(Model.GetInfo().ModelPath, FileName); using (StreamWriter FileWriter = new StreamWriter(FinalFileName)) { while (ModelObjectsToWriteOut.MoveNext()) { Beam ThisBeam = ModelObjectsToWriteOut.Current as Beam; if (ThisBeam != null) { string DataLineForFile = Model.GetGUIDByIdentifier(ThisBeam.Identifier) + ", " + ThisBeam.Profile.ProfileString + ", " + ThisBeam.Material.MaterialString + ", " + ThisBeam.Class; FileWriter.WriteLine(DataLineForFile); } } } MessageBox.Show("File Exported"); Tekla.Structures.Model.Operations.Operation.DisplayPrompt("File Exported and written to Model Folder"); }
private void button1_Click(object sender, EventArgs e) { #region connection to Tekla Structures and basic model path, version information Model Model1 = new Model(); string modelname = Model1.GetInfo().ModelName; string modelpath = Model1.GetInfo().ModelPath; string configuration = ModuleManager.Configuration.ToString(); string TSversion = TeklaStructuresInfo.GetCurrentProgramVersion(); string tB = textBox1.Text; char ch = '*'; List <Beam> ListBeamPlate = new List <Beam>(); // List Beam List <ContourPlate> ListPlate = new List <ContourPlate>(); //List Plate List <PolyBeam> ListPolyBeam = new List <PolyBeam>(); //List Poly Beam ArrayList AllParts = new ArrayList(); #endregion string CNC_Files = textBox2.Text; if (!Directory.Exists(modelpath + @"\" + CNC_Files)) { Directory.CreateDirectory(modelpath + @"\" + CNC_Files); } //Выбор деталей Picker Picker = new Picker(); try { //Перечесляем выбранные детали ModelObjectEnumerator input = Picker.PickObjects(Picker.PickObjectsEnum.PICK_N_PARTS, "Выберите детали"); IEnumerator enumerator = input.GetEnumerator(); //добовляем в масив while (enumerator.MoveNext()) { Beam beam = enumerator.Current as Beam; ContourPlate contourPlate = enumerator.Current as ContourPlate; PolyBeam polyBeam = enumerator.Current as PolyBeam; if (beam != null) { ListBeamPlate.Add(beam); } if (contourPlate != null) { ListPlate.Add(contourPlate); } if (polyBeam != null) { ListPolyBeam.Add(polyBeam); } } #region // ArrayList ObjectsToSelect = new ArrayList(); // Part part = enumerator.Current as Part; // ObjectsToSelect.Add(part); // string partProfileF = part.Profile.ProfileString; // char ch = '*'; //int partProfileF2 = partProfileF.IndexOf(ch); //ArrayList pathPartA = new ArrayList(); //try { string partProfileF3 = partProfileF.Remove(partProfileF.IndexOf('*'), partProfileF.Length - partProfileF.IndexOf('*')); pathPartA.Add(partProfileF3); } //catch { string partProfileF3 = partProfileF; pathPartA.Add(partProfileF3); } // string partProfileF1 = pathPartA[0].ToString(); // int indexOf = partProfileF.IndexOf("PL"); // string partMaterial = part.Material.MaterialString; // Tekla.Structures.Model.UI.ModelObjectSelector MS = new Tekla.Structures.Model.UI.ModelObjectSelector(); // MS.Select(ObjectsToSelect); // if (indexOf == 0) // { // if (!Directory.Exists(modelpath + @"\" + CNC_Files + @"\" + partProfileF1 + "_" + partMaterial)) // { // Directory.CreateDirectory(modelpath + @"\" + CNC_Files + @"\" + partProfileF1 + "_" + partMaterial); // } // string pathPart = modelpath + @"\" + CNC_Files + @"\" + partProfileF1 + "_" + partMaterial + @"\"; // Operation.CreateNCFilesFromSelected("DSTV for plates", pathPart); // Operation.DisplayPrompt("ok"); // } // } #endregion } catch { Operation.DisplayPrompt("что то пошло не так..."); } // находим в пластины замоделенной балке int countPlateBeamT = 0; List <MyPlate> PlateBeamT = new List <MyPlate>(); foreach (Beam beam in ListBeamPlate) { string PB = beam.Profile.ProfileString; if (PB.StartsWith(tB)) { string PP1 = PB.Substring(0, PB.LastIndexOf(ch)); string PP2 = beam.Material.MaterialString; MyPlate myPlate = new MyPlate { PlateProfile = PP1, PlateMaterial = PP2 }; PlateBeamT.Add(myPlate); countPlateBeamT++; } } foreach (PolyBeam beam in ListPolyBeam) { string PB = beam.Profile.ProfileString; if (PB.StartsWith(tB)) { string PP1 = PB.Substring(0, PB.LastIndexOf(ch)); string PP2 = beam.Material.MaterialString; MyPlate myPlate = new MyPlate { PlateProfile = PP1, PlateMaterial = PP2 }; PlateBeamT.Add(myPlate); countPlateBeamT++; } } int countPlatePlate = 0; foreach (ContourPlate contourPlate in ListPlate) { string PP1 = contourPlate.Profile.ProfileString; string PP2 = contourPlate.Material.MaterialString; MyPlate myPlate = new MyPlate { PlateProfile = PP1, PlateMaterial = PP2 }; PlateBeamT.Add(myPlate); countPlatePlate++; } //Объединение list<> List <MyPlate> filterMP = new List <MyPlate>(); List <MyPlate> filterMP2 = new List <MyPlate>(); List <MyPlate> filterMP2Sorted = new List <MyPlate>(); // итоговый список var dist = PlateBeamT.Distinct(new MyPlateComparer()); foreach (MyPlate s in dist) { try { string PP = s.PlateProfile.Substring(0, s.PlateProfile.LastIndexOf(".")); string PM = s.PlateMaterial; MyPlate myPlate = new MyPlate { PlateProfile = PP, PlateMaterial = PM, }; filterMP.Add(myPlate); } catch { string PP = s.PlateProfile; string PM = s.PlateMaterial; MyPlate myPlate = new MyPlate { PlateProfile = PP, PlateMaterial = PM, }; filterMP.Add(myPlate); } } var dist2 = filterMP.Distinct(new MyPlateComparer()); foreach (MyPlate d in dist2) { filterMP2.Add(d); } var SortedfMP2 = from u in filterMP2 orderby u.PlateMaterial, u.PlateProfile select u; foreach (MyPlate u in SortedfMP2) { filterMP2Sorted.Add(u); } //выбор деталей по толщине и марке стали for (int i = 0; i < filterMP2Sorted.Count; i++) { try { ArrayList y1 = new ArrayList(); var x1 = from plate in ListPlate where plate.Profile.ProfileString == filterMP2Sorted[i].PlateProfile where plate.Material.MaterialString == filterMP2Sorted[i].PlateMaterial select plate; var x2 = from plateB in ListBeamPlate where plateB.Profile.ProfileString.StartsWith(filterMP2Sorted[i].PlateProfile) where plateB.Material.MaterialString == filterMP2Sorted[i].PlateMaterial select plateB; var x3 = from plateB in ListPolyBeam where plateB.Profile.ProfileString.StartsWith(filterMP2Sorted[i].PlateProfile) where plateB.Material.MaterialString == filterMP2Sorted[i].PlateMaterial select plateB; foreach (ContourPlate plate in x1) { y1.Add(plate); } foreach (Beam beam in x2) { y1.Add(beam); } foreach (PolyBeam polyBeam in x3) { y1.Add(polyBeam); } Tekla.Structures.Model.UI.ModelObjectSelector MS = new Tekla.Structures.Model.UI.ModelObjectSelector(); MS.Select(y1); if (!Directory.Exists(modelpath + @"\" + CNC_Files + @"\" + filterMP2Sorted[i].PlateProfile + "_" + filterMP2Sorted[i].PlateMaterial)) { Directory.CreateDirectory(modelpath + @"\" + CNC_Files + @"\" + filterMP2Sorted[i].PlateProfile + "_" + filterMP2Sorted[i].PlateMaterial); } string pathPart = modelpath + @"\" + CNC_Files + @"\" + filterMP2Sorted[i].PlateProfile + "_" + filterMP2Sorted[i].PlateMaterial + @"\"; Operation.CreateNCFilesFromSelected("DSTV for plates", pathPart); } catch { Operation.DisplayPrompt("что то пошло не так...."); } } Tekla.Structures.Model.UI.ModelObjectSelector MS1 = new Tekla.Structures.Model.UI.ModelObjectSelector(); MS1.Select(AllParts); Operation.DisplayPrompt("Готово... //work by Wiz//"); }
public RebarsSelector() { ModelObjectEnumerator.AutoFetch = true; selector = new Tekla.Structures.Model.UI.ModelObjectSelector(); picker = new Picker(); }
private void button1_Click(object sender, EventArgs e) { TransformationPlane current = Model.GetWorkPlaneHandler().GetCurrentTransformationPlane(); //Глобальная плоскость try { Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(new TransformationPlane()); ModelObjectEnumerator selectedModelObjects = new Tekla.Structures.Model.UI.ModelObjectSelector().GetSelectedObjects(); GADrawing MyDrawing = null; while (selectedModelObjects.MoveNext()) { Tekla.Structures.Geometry3d.CoordinateSystem ModelObjectCoordSys; string ModelObjectName; GetCoordinateSystemAndNameOfSelectedObject(selectedModelObjects, out ModelObjectCoordSys, out ModelObjectName); //создание нового общего чертежа string DrawingName = "PartBasicViews" + (selectedModelObjects.Current as Tekla.Structures.Model.ModelObject).Identifier; MyDrawing = new 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 Tekla.Structures.Model.Part) { Parts.Add(selectedModelObjects.Current.Identifier); } else if (selectedModelObjects.Current is Tekla.Structures.Model.Assembly) { Parts = GetAssemblyParts(selectedModelObjects.Current as Tekla.Structures.Model.Assembly); } else if (selectedModelObjects.Current is Tekla.Structures.Model.BaseComponent) { Parts = GetComponentParts(selectedModelObjects.Current as Tekla.Structures.Model.BaseComponent); } CreateViews(ModelObjectCoordSys, ModelObjectName, MyDrawing, Parts); MyDrawing.PlaceViews(); DrawingHandler.CloseActiveDrawing(true); //Сохранение и закрытие активного окна } if (MyDrawing != null && openDrawings.Checked) { DrawingHandler.SetActiveDrawing(MyDrawing); } Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current); //возврат исходной плоскости } catch (Exception exception) { Model.GetWorkPlaneHandler().SetCurrentTransformationPlane(current); MessageBox.Show(exception.ToString()); } }
private static ModelObjectEnumerator getSelectedObjects() { var selector = new TSM.UI.ModelObjectSelector(); ModelObjectEnumerator selectionEnum = selector.GetSelectedObjects(); return selectionEnum; }
private void GetSelected() { if (!checkBoxLockTrees.Checked) { treeView1.Nodes.Clear(); treeView2.Nodes.Clear(); HideTree2(); toolStripButtonCure.Visible = false; int index = 0; UI.ModelObjectSelector selector = new UI.ModelObjectSelector(); ModelObjectEnumerator selectedEnum = selector.GetSelectedObjects(); while (index < 2 && selectedEnum.MoveNext()) { Assembly assembly = null; try { assembly = selectedEnum.Current as Assembly; } catch { } if (assembly != null) { if (index == 0) { FillTree(assembly, treeView1); } else { FillTree(assembly, treeView2); ShowTree2(); toolStripButtonCure.Visible = false; } } index++; } } else { UI.ModelObjectSelector selector = new UI.ModelObjectSelector(); ModelObjectEnumerator selectedEnum = selector.GetSelectedObjects(); if (selectedEnum.MoveNext()) { Identifier identifier = (selectedEnum.Current as ModelObject).Identifier; TreeNode[] nodes1 = treeView1.Nodes.Find(identifier.ID.ToString(), true); TreeNode[] nodes2 = treeView2.Nodes.Find(identifier.ID.ToString(), true); if (nodes1 != null && nodes1.Length > 0) { treeView1.SelectedNode = nodes1[0]; treeView1.Focus(); } else if (nodes2 != null && nodes2.Length > 0) { treeView2.SelectedNode = nodes2[0]; treeView2.Focus(); } } } }
private static void selectInitialObjects(List<Assembly> selectedAssemblys) { ArrayList initialSelectedAssemblys = new ArrayList(selectedAssemblys); var selector = new TSM.UI.ModelObjectSelector(); selector.Select(initialSelectedAssemblys); }
public void Run(String args) { XmlTextWriter myXmlTextWriter = null; int Count = 0; int AssemblyId = 0; long TotalTime = 0; long ElapsedTime = 0; long StartTicks = DateTime.Now.Ticks; try { ArrayList listOfPieces = new ArrayList(); Model myModel = new Model(); ModelObjectEnumerator myEnum = new TSMUI.ModelObjectSelector().GetSelectedObjects(); myXmlTextWriter = new XmlTextWriter(args, null); myXmlTextWriter.Formatting = Formatting.Indented; myXmlTextWriter.WriteStartDocument(false); myXmlTextWriter.WriteComment("This file is just a sample output from Tekla Structures"); myXmlTextWriter.WriteStartElement("project"); StartTicks = DateTime.Now.Ticks; while (myEnum.MoveNext()) { Part myPart = myEnum.Current as Part; if ((myPart != null) && (myPart.GetReportProperty("ASSEMBLY.ID", ref AssemblyId)) && !listOfPieces.Contains(AssemblyId.ToString())) { WritePiece(myXmlTextWriter, myPart, myModel); listOfPieces.Add(AssemblyId.ToString()); ++Count; ElapsedTime = (DateTime.Now.Ticks - StartTicks) / 10000; Console.WriteLine("{0} : {1} ({2} msecs)", Count, AssemblyId.ToString(), ElapsedTime); TotalTime += ElapsedTime; StartTicks = DateTime.Now.Ticks; } } myXmlTextWriter.WriteEndElement(); myXmlTextWriter.Flush(); myXmlTextWriter.Close(); ElapsedTime = (DateTime.Now.Ticks - StartTicks) / 10000; Console.WriteLine("Writing xml-file : {0} msecs", ElapsedTime); TotalTime += ElapsedTime; } catch (Exception Ex) { Console.WriteLine("Exceptioni : {0}", Ex.ToString()); } finally { Console.WriteLine(); Console.WriteLine("Totally {0} pieces exported.", Count); Console.WriteLine("Totla time spent : {0} seconds", (float)TotalTime / 1000); Console.WriteLine("Processing of the file {0} complete.", args); Console.WriteLine("\nPress enter ..."); Console.Read(); if (myXmlTextWriter != null) { myXmlTextWriter.Close(); } } }
private void btn_Get_Assembly_Click(object sender, EventArgs e) { TSMUI.Picker thisPicker = new TSMUI.Picker(); Part pickedPart = null; try { pickedPart = thisPicker.PickObject(TSMUI.Picker.PickObjectEnum.PICK_ONE_PART) as Part; } catch { pickedPart = null; } if (pickedPart != null) { Assembly thisAssembly = pickedPart.GetAssembly(); ModelObject mainObject = thisAssembly.GetMainPart(); Part mainPart = mainObject as Part; if (mainPart != null) { mainPart.Class = "2"; mainPart.Modify(); // Don't grab from assembly because it doesn't have one... mainPart.GetCoordinateSystem(); // Set the mainPart of the assembly. // thisAssembly.setMainPart(pickedPart); } else { Assembly mainAssembly = mainObject as Assembly; if (mainAssembly != null) { // You got an assembly... } } // This doesn't do anything, don't use it ModelObjectEnumerator partsOnAssembly = thisAssembly.GetChildren(); int childrenObjects = partsOnAssembly.GetSize(); // Gets Parts ArrayList partsList = thisAssembly.GetSecondaries(); foreach (Part thisPart in partsList) { thisPart.Class = "6"; thisPart.Modify(); } // Neat way to highlight / select objects in the model. TSMUI.ModelObjectSelector selector = new TSMUI.ModelObjectSelector(); selector.Select(partsList); // Gets Sub Assemblies int subAssemblies = thisAssembly.GetSubAssemblies().Count; Tekla.Structures.Model.Operations.Operation.DisplayPrompt(childrenObjects + " Children Objects"); currentModel.CommitChanges(); } }
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); } }
public void Process() { var model = new Tekla.Structures.Model.Model(); var modelObjSelector = new Tekla.Structures.Model.UI.ModelObjectSelector(); var selectedObj = modelObjSelector.GetSelectedObjects(); var objlist = new List <Beam>(); while (selectedObj.MoveNext()) { Tekla.Structures.Model.Part thisPart = selectedObj.Current as Tekla.Structures.Model.Part; if (thisPart != null) { var objBeam = thisPart as Beam; objlist.Add(objBeam); } } List <ConnectionInfo> conInfo = new List <ConnectionInfo>(); var pairlist = new List <CollectionPair>(); foreach (var item in objlist) { var currentitem = item; var items = objlist.Where (layer => Math.Round(layer.StartPoint.Z, 1) == Math.Round(currentitem.StartPoint.Z, 1) || ( Math.Round(layer.StartPoint.Z, 1) >= Math.Round(currentitem.StartPoint.Z, 1) && Math.Round(layer.StartPoint.Z, 1) <= Math.Round(currentitem.EndPoint.Z, 1) ) || ( Math.Round(layer.EndPoint.Z, 1) >= Math.Round(currentitem.StartPoint.Z, 1) && Math.Round(layer.EndPoint.Z, 1) <= Math.Round(currentitem.EndPoint.Z, 1) ) ).ToList(); foreach (var subitem in items) { if (pairlist.Exists( c => (c.Primary == currentitem.Identifier.ToString() && c.Secondary == subitem.Identifier.ToString()) || (c.Primary == subitem.Identifier.ToString() && c.Secondary == currentitem.Identifier.ToString()) )) { continue; } if (currentitem.Identifier != subitem.Identifier) { ConnectionInfo info = new ConnectionInfo(); Line line1 = new Line(currentitem); Line line2 = new Line(subitem); var linechecker = new LineChecker(line1, line2); if (linechecker.ValidConnection) { info.Primary = linechecker.GetPrimary(); info.PrimaryId = info.Primary.Id; info.Secondary = linechecker.GetSecondary(); info.SecondaryProfile = GetSecondaryBeamProfile(info.Secondary.ObjSource); info.PrimaryType = info.Primary.ObjSource.Type.ToString(); info.XIntersection = (double)linechecker.X_Coord; info.YIntersection = (double)linechecker.Y1_Coord; info.Level = info.Secondary.ObjSource.StartPoint.Z.RoundDown(3); Beam primary = info.Primary.ObjSource; Beam secondary = info.Secondary.ObjSource; conInfo.Add(info); // create pair of collection // identify primary and secondary objects // iterate pair of collection var pairs = new CollectionPair() { Profile = (linechecker.GetSecondary().Id == currentitem.Identifier.ID) ? currentitem.Profile.ProfileString : subitem.Profile.ProfileString, Primary = linechecker.GetPrimary().Id.ToString(), Secondary = linechecker.GetSecondary().Id.ToString() }; pairlist.Add(pairs); } } } } ProcessCollection(conInfo); Console.WriteLine("+++++++++++++++++++++++++++++"); Console.WriteLine("Beam To Beam-Web Connection"); Console.WriteLine(); foreach (var i in BeamToBeamWebColl) { Console.WriteLine($"IsSingleConnection: {i.IsSingleConnection}"); Console.Write($"{((Beam)i.PrimaryObject).Identifier.ID}"); if (i.IsSingleConnection) { Console.Write($">>{((Beam)i.SecondaryObject).Identifier.ID}"); } else { //Console.WriteLine($"Secondary ids:"); foreach (var l in i.SecondaryObjects) { var o = l as Beam; Console.Write($">>{o.Identifier.ID}"); } } Console.WriteLine(); Console.WriteLine("-------------------"); Console.WriteLine(); } Console.WriteLine("+++++++++++++++++++++++++++++"); Console.WriteLine("Beam To Column-Web Connection"); Console.WriteLine(); foreach (var i in BeamToColumnWebColl) { Console.WriteLine($"IsSingleConnection: {i.IsSingleConnection}"); Console.Write($"{((Beam)i.PrimaryObject).Identifier.ID}"); if (i.IsSingleConnection) { Console.Write($">>{((Beam)i.SecondaryObject).Identifier.ID}"); } else { //Console.WriteLine($"Secondary ids:"); foreach (var l in i.SecondaryObjects) { var o = l as Beam; Console.Write($">>{o.Identifier.ID}"); } } Console.WriteLine(); Console.WriteLine("-------------------"); Console.WriteLine(); } Console.WriteLine("+++++++++++++++++++++++++++++"); Console.WriteLine("Beam To Column-Flange Connection"); Console.WriteLine(); foreach (var i in BeamToColumnFlangeColl) { Console.WriteLine($"IsSingleConnection: {i.IsSingleConnection}"); Console.Write($"{((Beam)i.PrimaryObject).Identifier.ID}"); if (i.IsSingleConnection) { Console.Write($">>{((Beam)i.SecondaryObject).Identifier.ID}"); } else { //Console.WriteLine($"Secondary ids:"); foreach (var l in i.SecondaryObjects) { var o = l as Beam; Console.Write($">>{o.Identifier.ID}"); } } Console.WriteLine(); Console.WriteLine("-------------------"); Console.WriteLine(); } model.CommitChanges(); //Console.ReadKey(); }