Bake to Tekla

i wanna to used this to create more than 100 parts,
so i need to right click more than 100times to bake to tekla .
if it’s possibly to have a single battery to realize automatically bake to tekla

11F.3dm (525.2 KB)
test1.gh (10.0 KB)
GrasshopperTeklaLink.gha (865.5 KB)

I tried several times but failed。THK ALL!!

Hi,

I would duplicate the input line 100 times using the Duplicate Data component to generate 100 columns on top of each other. Then the Bake to Tekla command would bake all those at once and you’d have 100 parts that are independent of the GH definition.

If you really want to simulate clicking the command 100 times you could do it with a C# component. There’s this example definition in the FAQ that can serve as a basis:

The definition contains, among other things, a C# component that can be used to trigger a command from the context menu of another component. That script could probably be modified to trigger the command a 100 times in a row.

Cheers,

Sebastian

Probably there is a problem with my description. It should be more than 100 special cross sections of different shapes.
and some of the cross sections have holes.
so ,i have to do like this:
1.choice curves
2.putin text
3.enable the battery
4.bake to tekla.
5.stop the battery
6.clean the curves and name
7.repeat 1th.

now i have short it
1.choice cruves+name(use a battery for category. including the position)
2.start/stop button(c# control the create coloum+create profile battery)
3. bake to tekla.

Not sure if the last part means you have solved it, but I’ll expand a bit on the process:

Use lists or trees for the inputs of the Create Profile component (Outline, Name - note that potential holes need to be in a tree structure as there can be many of them in each profile). That way you create all the profiles at once.

Then use a list of equal length for the Curve input of the Column component (potentially duplicating the input line in case they should have the same axis). This would generate all the parts using different profiles at once, and they can then be baked at once.

Cheers,

-b

i got the human plugin,but it didn’t work well.

I have try this code ,but something wrong about the input type,maybe


test2.gh (12.9 KB)

I’ve thought about this idea before, but there’s a troublesome problem. Judge more than 100 curves and judge those are holes and those are outer contours.

In the end, I decided to choose one by one. It’s a little troublesome this way, but follow my steps, if it can be automatic baketotekla ,this will be more fast

Hi, this was the component I’m referring to, that code checks the context menu of the connected component in the Component input and triggers the command in Command input (if found):

-b

2 Likes

I will try it,THK!!

using System;
using System.Collections;
using System.Collections.Generic;

using Rhino;
using Rhino.Geometry;

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using System.Linq;
//using Tekla.Structures;
//using Tekla.Structures.Model;
//using Tekla.Structures.Drawing;
//using Tekla.Structures.Catalogs;
//using Tekla.Structures.Plugins;
//using Tekla.Structures.Ui.WpfKit;
using GTLink.Tools;
using GTLink;
using GTLink.Components;


/// <summary>
/// This class will be instantiated on demand by the Script component.
/// </summary>
public class Script_Instance : GH_ScriptInstance
{
#region Utility functions
  /// <summary>Print a String to the [Out] Parameter of the Script component.</summary>
  /// <param name="text">String to print.</param>
  private void Print(string text) { /* Implementation hidden. */ }
  /// <summary>Print a formatted String to the [Out] Parameter of the Script component.</summary>
  /// <param name="format">String format.</param>
  /// <param name="args">Formatting parameters.</param>
  private void Print(string format, params object[] args) { /* Implementation hidden. */ }
  /// <summary>Print useful information about an object instance to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj) { /* Implementation hidden. */ }
  /// <summary>Print the signatures of all the overloads of a specific method to the [Out] Parameter of the Script component. </summary>
  /// <param name="obj">Object instance to parse.</param>
  private void Reflect(object obj, string method_name) { /* Implementation hidden. */ }
#endregion

#region Members
  /// <summary>Gets the current Rhino document.</summary>
  private readonly RhinoDoc RhinoDocument;
  /// <summary>Gets the Grasshopper document that owns this script.</summary>
  private readonly GH_Document GrasshopperDocument;
  /// <summary>Gets the Grasshopper script component that owns this script.</summary>
  private readonly IGH_Component Component;
  /// <summary>
  /// Gets the current iteration count. The first call to RunScript() is associated with Iteration==0.
  /// Any subsequent call within the same solution will increment the Iteration count.
  /// </summary>
  private readonly int Iteration;
#endregion

  /// <summary>
  /// This procedure contains the user code. Input parameters are provided as regular arguments,
  /// Output parameters as ref arguments. You don't have to assign output parameters,
  /// they will have a default value.
  /// </summary>
  private void RunScript(object x)
  {
    CreateModelObjectComponent xx = new CreateModelObjectComponent(x);
    xx.BakeToTekla();

  }

  // <Custom additional code> 

  // </Custom additional code> 
}

when i finish create the beam,i type this code ,but failed

CreateModelObjectComponent xx = (CreateModelObjectComponent)x;

but failed

Hi, I take it your input x is a Tekla.Structures.Model.Beam, which can’t be converted to a CreateModelObjectComponent (that’s a Grasshopper component type). So you’d need to obtain the source component that created the Beam to be able to call any methods like BakeToTekla. And if you do that, you should keep in mind that the GH link isn’t built as an API so not sure how it will behave in this context.

Check the code in my previous post again on how to obtain the source component that’s connected to your scripting component, e.g. the Create Beam component. Copying it here below for convenience:

  private void RunScript(DataTree<System.Object> Component, string Command)
  {
    var commandStart = Command.Trim().ToUpper();

    var comp = this.Component;
    var input = comp.Params.Input[comp.Params.IndexOfInputParam("Component")];

    var menuItemsToClick = new List<ToolStripMenuItem>();

    foreach (var source in input.Sources)
    {
      var menu = new ToolStripDropDown();

      var sourceComponent = comp.OnPingDocument().FindComponent(source.Attributes.GetTopLevel.DocObject.InstanceGuid);
      if (sourceComponent != null)
      {
        (sourceComponent as IGH_Component).AppendMenuItems(menu);
      }
      else if (source is IGH_Param)
      {
        (source as IGH_Param).AppendMenuItems(menu);
      }

      foreach (var item in menu.Items)
      {
        if (item is ToolStripMenuItem && (item as ToolStripMenuItem).Text.ToUpper().StartsWith(commandStart))
        {
          menuItemsToClick.Add(item as ToolStripMenuItem);
          break; // only add the first match
        }
      }
    }

    _solutionEndHandle = delegate (System.Object sender, GH_SolutionEventArgs e)
      {
        // first get rid of our handler again
        GrasshopperDocument.SolutionEnd -= _solutionEndHandle;

        RhinoApp.InvokeOnUiThread((MethodInvoker)
          (
          () =>
          {
          foreach (var item in menuItemsToClick)
            item.PerformClick();
          }
          )
          );
      };

    comp.OnPingDocument().SolutionEnd += _solutionEndHandle;

    Print("Command executed");
  }

  // <Custom additional code> 

  private GH_Document.SolutionEndEventHandler _solutionEndHandle;

Cheers,

-b

2 Likes

WONDERFUL JOB,THK!!
in addition,the inputted Command (string) must be the exact content you see, it doesn’t have to be BakeToTekla.(maybe your version is translated)

1 Like

another way to create crosssection is finished



and another question comes out ,the holes not comes out…
how to send the data of holes to the tekla compnent

and it seem like i have to change every tekla compnent derection,it never match the positon of rhino view

I GOT IT , every hole,outline name ,should be a tree,not list

2 Likes

@ Sebastian Lindholm

good morning ! In Create Profile component can we have toggle function to run the component
cos each time when i open the script it keeps creating the profiles (right now am disabling the component ) if the profile is existing it should have a warning message so we don’t have to over write the profiles

regards
rajeev