/// <summary> /// Creates a new component in a project. /// </summary> /// <param name="componentUri">The URI for the selected component.</param> /// <param name="componentInput">A class containing the essential information about the component.</param> /// <returns>The updated component.</returns> /// <exception cref="WebServiceException">The caller is not logged in and does not have permission to edit components.</exception> public Component UpdateComponent(Uri componentUri, ComponentInput componentInput) { var helper = new ComponentInputWithProjectKey(null, componentInput); var json = ComponentInputWithProjectKeyJsonGenerator.Generate(helper); return(client.Put <Component>(componentUri.ToString(), json)); }
protected ComponentInput(ComponentInput componentInput) { Name = componentInput.Name; Description = componentInput.Description; LeadUserName = componentInput.LeadUserName; AssigneeType = componentInput.AssigneeType; }
private static bool exportIFC(string outputFileName) { ComponentInput ComponentInput = new ComponentInput(); ComponentInput.AddOneInputPosition(new Point(0, 0, 0)); Component Comp = new Component(ComponentInput); Comp.Name = "ExportIFC"; Comp.Number = BaseComponent.PLUGIN_OBJECT_NUMBER; // Parameters Comp.SetAttribute("OutputFile", outputFileName); Comp.SetAttribute("Format", 0); Comp.SetAttribute("ExportType", 1); Comp.SetAttribute("AdditionalPSets", "BMcDIFCConfig"); Comp.SetAttribute("CreateAll", 0); // 0 to export only selected objects // Advanced Comp.SetAttribute("Assemblies", 1); Comp.SetAttribute("Bolts", 1); Comp.SetAttribute("Welds", 0); Comp.SetAttribute("SurfaceTreatments", 1); Comp.SetAttribute("BaseQuantities", 1); Comp.SetAttribute("GridExport", 1); Comp.SetAttribute("ReinforcingBars", 1); Comp.SetAttribute("PourObjects", 1); Comp.SetAttribute("LayersNameAsPart", 1); Comp.SetAttribute("PLprofileToPlate", 0); Comp.SetAttribute("ExcludeSnglPrtAsmb", 0); //Comp.SetAttribute("LocsFromOrganizer", 0); // dafuq return Comp.Insert(); }
/// <summary> /// Creates a new component in a project. /// </summary> /// <param name="projectKey">The key for the project in which to create the new component.</param> /// <param name="componentInput">A class containing the essential information about the component.</param> /// <returns>The newly created component.</returns> /// <exception cref="WebServiceException">The caller is not logged in and does not have permission to create components in the project.</exception> public Component CreateComponent(string projectKey, ComponentInput componentInput) { var helper = new ComponentInputWithProjectKey(projectKey, componentInput); var json = ComponentInputWithProjectKeyJsonGenerator.Generate(helper); return(client.Post <Component>(baseComponentUri.ToString(), json)); }
public static dynamic GetTSObject(ComponentInput dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
/// <summary> /// Event handler for the <see cref="PickingTool.PickSessionEnded"/> event. /// </summary> /// <param name="sender">The sender object.</param> /// <param name="eventArgs">The event argument for the handler.</param> private void OnPickEnded(object sender, EventArgs eventArgs) { var input = new ComponentInput(); input.AddInputPolygon(new Polygon { Points = new ArrayList(this.pickedPoints) }); this.CommitComponentInput(input); }
/// <summary> /// Modifies the input. /// </summary> /// <param name="points">The points.</param> private void ModifyInput(List <Point> points) { this.Graphics.Clear(); var originalInput = this.Component.GetComponentInput(); if (originalInput == null) { return; } var input = new ComponentInput(); var index = 0; foreach (var inputItem in originalInput) { if (!(inputItem is InputItem item)) { continue; } switch (item.GetInputType()) { case InputItem.InputTypeEnum.INPUT_1_OBJECT: input.AddInputObject(item.GetData() as ModelObject); break; case InputItem.InputTypeEnum.INPUT_N_OBJECTS: input.AddInputObjects(item.GetData() as ArrayList); break; case InputItem.InputTypeEnum.INPUT_1_POINT: input.AddOneInputPosition(points[index]); index++; break; case InputItem.InputTypeEnum.INPUT_2_POINTS: input.AddTwoInputPositions(points[index], points[index + 1]); index += 2; break; case InputItem.InputTypeEnum.INPUT_POLYGON: var polygon = new Polygon(); foreach (var point in points) { polygon.Points.Add(new Point(point)); } input.AddInputPolygon(polygon); break; default: break; } } this.ModifyComponentInput(input); }
private void InsertComponentRecipes(List <RecipeImport> recipes) { using (var context = CreateContext()) { foreach (var recipeImport in recipes) { var component = context.Components.First(i => i.Name == recipeImport.ComponentName); var machineType = context.MachineTypes.First(i => i.Name == recipeImport.MachineType); var recipe = new Recipe { Name = component.Name, ComponentId = component.Id, MachineType = machineType.Id, NumberProduced = recipeImport.NumberProduced, TimeToCreate = recipeImport.TimeToCreate, UseByDefault = recipeImport.Default, IsBuilding = false }; context.Recipes.Add(recipe); context.SaveChanges(); foreach (var input in recipeImport.Inputs) { var inputComponent = context.Components.First(i => i.Name == input.ComponentName); var componentInput = new ComponentInput { AmountNeeded = input.Count, InputComponentId = inputComponent.Id, RecipeId = recipe.Id }; context.ComponentInputs.Add(componentInput); } context.SaveChanges(); foreach (var additionalOutput in recipeImport.AdditionalOutput) { var outputComponent = context.Components.First(i => i.Name == additionalOutput.ComponentName); var output = new AdditionalOutput { Amount = additionalOutput.Count, ComponentId = outputComponent.Id, RecipeId = recipe.Id }; context.AdditionalOutputs.Add(output); } context.SaveChanges(); } } }
/// <summary> /// Event handler for the <see cref="PickingTool.PickSessionEnded"/> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="eventArgs">The event argument for the handler.</param> private void OnPickSessionEnded(object sender, EventArgs eventArgs) { var input = new ComponentInput(); input.AddInputPolygon(new Polygon { Points = new ArrayList(this.pickedPoints) }); this.Component.SetAttribute(TransitionSectionPluginPropertyNames.RectangleWidth, this.widthValueBox.Value); this.Component.SetAttribute(TransitionSectionPluginPropertyNames.RectangleHeight, this.heightValueBox.Value); this.Component.SetAttribute(TransitionSectionPluginPropertyNames.CircleRadius, this.radiusValueBox.Value); this.CommitComponentInput(input); }
public override void Insert() { component.Number = -100000; component.Name = this.name; component.LoadAttributesFromFile(this.attributeFile); ComponentInput I = new ComponentInput(); I.AddInputObject(column); component.SetComponentInput(I); component.Insert(); this.ID = component.Identifier.ID; }
/// <summary> /// /// </summary> public override void Insert() { component.Number = -100000; component.Name = this.name; component.LoadAttributesFromFile(this.attributeFile); ComponentInput I = new ComponentInput(); I.AddOneInputPosition(startPoint); I.AddOneInputPosition(endPoint); component.SetComponentInput(I); component.Insert(); this.ID = component.Identifier.ID; }
private void button1_Click(object sender, EventArgs e) { // Model mod = new Model(); string[] Phases = new string[] { "IFC_10", "IFC_20", "IFC_30", "IFC_31", "IFC_32", "IFC_40", "IFC_41", "IFC_50", "IFC_60", "IFC_70", "IFC_80", "IFC_90" }; foreach (string phase in Phases) { ComponentInput ComponentInput = new ComponentInput(); ComponentInput.AddOneInputPosition(new Point(0, 0, 0)); var exportPlugin = new Tekla.Structures.Model.Component(ComponentInput) { Name = "ExportIFC", Number = BaseComponent.PLUGIN_OBJECT_NUMBER }; exportPlugin.LoadAttributesFromFile("standard"); exportPlugin.SetAttribute("OutputFile", phase); exportPlugin.Insert(); } }
private static bool exportIFC(string outputFileName) { ComponentInput ComponentInput = new ComponentInput(); ComponentInput.AddOneInputPosition(new Point(0, 0, 0)); Component Comp = new Component(ComponentInput); Comp.Name = "ExportIFC"; Comp.Number = BaseComponent.PLUGIN_OBJECT_NUMBER; // Parameters Comp.SetAttribute("OutputFile", outputFileName); Comp.SetAttribute("Format", 0); Comp.SetAttribute("ExportType", 1); Comp.SetAttribute("AdditionalPSets", "BMcDIFCConfig"); Comp.SetAttribute("CreateAll", 0); // 0 to export only selected objects // Advanced Comp.SetAttribute("Assemblies", 1); Comp.SetAttribute("Bolts", 1); Comp.SetAttribute("Welds", 0); Comp.SetAttribute("SurfaceTreatments", 1); Comp.SetAttribute("BaseQuantities", 1); Comp.SetAttribute("GridExport", 1); Comp.SetAttribute("ReinforcingBars", 1); Comp.SetAttribute("PourObjects", 1); Comp.SetAttribute("LayersNameAsPart", 1); Comp.SetAttribute("PLprofileToPlate", 0); Comp.SetAttribute("ExcludeSnglPrtAsmb", 0); //Comp.SetAttribute("LocsFromOrganizer", 0); // dafuq return(Comp.Insert()); }
public static void ExportIFC(string outputFileName) { var componentInput = new ComponentInput(); componentInput.AddOneInputPosition(new Point(0, 0, 0)); var comp = new Component(componentInput) { Name = "ExportIFC", Number = BaseComponent.PLUGIN_OBJECT_NUMBER }; // Parameters comp.SetAttribute("OutputFile", outputFileName); comp.SetAttribute("Format", 0); comp.SetAttribute("ExportType", 1); //comp.SetAttribute("AdditionalPSets", ""); comp.SetAttribute("CreateAll", 0); // 0 to export only selected objects // Advanced comp.SetAttribute("Assemblies", 1); comp.SetAttribute("Bolts", 1); comp.SetAttribute("Welds", 0); comp.SetAttribute("SurfaceTreatments", 1); comp.SetAttribute("BaseQuantities", 1); comp.SetAttribute("GridExport", 1); comp.SetAttribute("ReinforcingBars", 1); comp.SetAttribute("PourObjects", 1); comp.SetAttribute("LayersNameAsPart", 1); comp.SetAttribute("PLprofileToPlate", 0); comp.SetAttribute("ExcludeSnglPrtAsmb", 0); comp.SetAttribute("LocsFromOrganizer", 0); comp.Insert(); }
private void InsertComponents(ModelObject mObj, List <TSM.Component> components) { TransformationPlane originalTransformationplane = null; WorkPlaneHandler wHandler = null; try { wHandler = model.GetWorkPlaneHandler(); originalTransformationplane = wHandler.GetCurrentTransformationPlane(); ComponentInput compInput = new ComponentInput(); Part fatherpart = mObj as Part; Assembly assembly = fatherpart.GetAssembly(); // Get the transformationplane from objects coordinate systems vectors and because objects coordinate system is not the same XY plane as of models, // so cross product needs to be made for the Y-axis TransformationPlane fatherpartsTransformationPlane = new TransformationPlane(fatherpart.GetCoordinateSystem().Origin, fatherpart.GetCoordinateSystem().AxisX, Vector.Cross(fatherpart.GetCoordinateSystem().AxisY, fatherpart.GetCoordinateSystem().AxisX)); lock (wHandler) { wHandler.SetCurrentTransformationPlane(fatherpartsTransformationPlane); } double minX = fatherpart.GetSolid().MinimumPoint.X; double minY = fatherpart.GetSolid().MinimumPoint.Y; double minZ = fatherpart.GetSolid().MinimumPoint.Z; double maxX = fatherpart.GetSolid().MaximumPoint.X; double maxY = fatherpart.GetSolid().MaximumPoint.Y; double maxZ = fatherpart.GetSolid().MaximumPoint.Z; bool changeDirection = false; if (data.Direction == "y-") { double temp = maxY; maxY = minY; minY = temp; changeDirection = true; } Solid s = fatherpart.GetSolid(); FaceEnumerator fEnum = s.GetFaceEnumerator(); StringBuilder sb = new StringBuilder(); while (fEnum.MoveNext()) { } Point p1 = null; Point p2 = null; List <Point> cutPartPoints = new List <Point>() { new Point(), new Point(), new Point(), new Point() }; ContourPlate cutpart = null; for (int i = 0; i < components.Count; i++) { cutpart = new ContourPlate(); cutpart.Name = "Leikkaus"; cutpart.Position.Depth = Position.DepthEnum.MIDDLE; cutpart.Position.Plane = Position.PlaneEnum.MIDDLE; cutpart.Class = BooleanPart.BooleanOperativeClassName; cutpart.Material.MaterialString = "Reikä"; cutpart.Profile.ProfileString = "PL135"; BooleanPart bPart = new BooleanPart(); compInput = new ComponentInput(); double[] variables; switch (i) { case 0: p1 = new Point(maxX - data.LeftShoeDist, 0, minZ); p2 = new Point(maxX - data.LeftShoeDist, maxY, minZ); variables = WallShoeUtils.GetComponentVariables(components[i]); if (variables[0] != 0) { AddWallShoeCut(variables, p1, minY, maxY, changeDirection, fatherpart); } break; case 1: p1 = new Point(minX + data.RightShoeDist, 0, minZ); p2 = new Point(minX + data.RightShoeDist, maxY, minZ); variables = WallShoeUtils.GetComponentVariables(components[i]); if (variables[0] != 0) { AddWallShoeCut(variables, p1, minY, maxY, changeDirection, fatherpart); } break; case 2: p1 = new Point(maxX - data.LeftBoltDist, 0, maxZ + data.LeftBoltOffset); p2 = new Point(maxX - data.LeftBoltDist, maxY, maxZ + data.LeftBoltOffset); break; case 3: p1 = new Point(minX + data.RightBoltDist, 0, maxZ + data.RightBoltOffset); sb.AppendLine(data.RightBoltDist + " " + data.RightBoltOffset); p2 = new Point(minX + data.RightBoltDist, maxY, maxZ + data.RightBoltOffset); break; } compInput.AddOneInputPosition(p1); compInput.AddOneInputPosition(p2); components[i].SetComponentInput(compInput); if (!components[i].Insert()) { TSM.Operations.Operation.DisplayPrompt("Komponentin " + i + " asettaminen epäonnistui!"); WriteLog("Komponentin " + i + " asettaminen epäonnistui!"); } } foreach (TSM.Component c in components) { assembly.Add(c); assembly.Modify(); } } catch (Exception ex) { WriteLog(ex.Message + "\n" + ex.StackTrace); } finally { lock (wHandler) { wHandler.SetCurrentTransformationPlane(originalTransformationplane); } } }
public ComponentInputWithProjectKey(string projectKey, ComponentInput componentInput) : base(componentInput) { ProjectKey = projectKey; }
private void InsertComponents(ModelObject mObj, List <TSM.Component> components) { TransformationPlane originalTransformationplane = null; try { lock (wHandler) { originalTransformationplane = wHandler.GetCurrentTransformationPlane(); } ComponentInput compInput = new ComponentInput(); Part fatherpart = mObj as Part; Assembly assembly = fatherpart.GetAssembly(); // Get the transformationplane from objects coordinate systems vectors and because objects coordinate system is not the same XY plane as of models, // so cross product needs to be made for the Y-axis TransformationPlane fatherpartsTransformationPlane = new TransformationPlane(fatherpart.GetCoordinateSystem().Origin, fatherpart.GetCoordinateSystem().AxisX, Vector.Cross(fatherpart.GetCoordinateSystem().AxisY, fatherpart.GetCoordinateSystem().AxisX)); lock (wHandler) { wHandler.SetCurrentTransformationPlane(fatherpartsTransformationPlane); } double minX = fatherpart.GetSolid().MinimumPoint.X; double minY = fatherpart.GetSolid().MinimumPoint.Y; double minZ = fatherpart.GetSolid().MinimumPoint.Z; double maxX = fatherpart.GetSolid().MaximumPoint.X; double maxY = fatherpart.GetSolid().MaximumPoint.Y; double maxZ = fatherpart.GetSolid().MaximumPoint.Z; Solid s = fatherpart.GetSolid(); FaceEnumerator fEnum = s.GetFaceEnumerator(); StringBuilder sb = new StringBuilder(); while (fEnum.MoveNext()) { sb.AppendLine(fEnum.Current.Normal.ToString()); } Point p1 = null; Point p2 = null; List <Point> cutPartPoints = new List <Point>() { new Point(), new Point(), new Point(), new Point() }; ContourPlate cutpart = null; for (int i = 0; i < components.Count; i++) { cutpart = new ContourPlate(); cutpart.Name = "Leikkaus"; cutpart.Position.Depth = Position.DepthEnum.MIDDLE; cutpart.Position.Plane = Position.PlaneEnum.MIDDLE; cutpart.Class = BooleanPart.BooleanOperativeClassName; cutpart.Material.MaterialString = "Reikä"; cutpart.Profile.ProfileString = "PL135"; BooleanPart bPart = new BooleanPart(); compInput = new ComponentInput(); switch (i) { case 0: p1 = new Point(minX + 300, 0, minZ); p2 = new Point(minX + 300, maxY, minZ); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 40), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 161.68), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 161.68 + (Math.Tan(9.88 * Math.PI / 180) * ((maxY - minY) / 2 + 52))), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 40), null)); cutpart.Insert(); bPart.Father = fatherpart; bPart.SetOperativePart(cutpart); if (!bPart.Insert()) { SetInfoText("Leikkauksen (1) tekeminen epäonnistui!"); } cutpart.Delete(); break; case 1: p1 = new Point(maxX - 300, 0, minZ); p2 = new Point(maxX - 300, maxY, minZ); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 40), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, p1.Y - 52, p1.Z + 161.68), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 161.68 + (Math.Tan(9.88 * Math.PI / 180) * ((maxY - minY) / 2 + 52))), null)); cutpart.AddContourPoint(new ContourPoint(new Point(p1.X, maxY, p1.Z + 40), null)); cutpart.Insert(); bPart.Father = fatherpart; bPart.SetOperativePart(cutpart); if (!bPart.Insert()) { SetInfoText("Leikkauksen (2) tekeminen epäonnistui!"); } cutpart.Delete(); break; case 2: p1 = new Point(minX + 300, 0, maxZ + 135); p2 = new Point(minX + 300, maxY, maxZ + 135); break; case 3: p1 = new Point(maxX - 300, 0, maxZ + 135); p2 = new Point(maxX - 300, maxY, maxZ + 135); break; } compInput.AddOneInputPosition(p1); compInput.AddOneInputPosition(p2); components[i].SetComponentInput(compInput); if (!components[i].Insert()) { SetInfoText("Komponentin laittaminen epäonnistui!"); } } foreach (TSM.Component c in components) { assembly.Add(c); assembly.Modify(); } } catch (Exception ex) { ExceptionOccured(ex.Message, ex.StackTrace); SetInfoText("Komponentin asettamisessa tapahtui virhe!"); } finally { lock (wHandler) { wHandler.SetCurrentTransformationPlane(originalTransformationplane); } } }