using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Model;
namespace RopesProject
{
class Program
{
static void Main(string[] args)
{
Model model = new Model();
if (model.GetConnectionStatus())
{
// let's get some beams
// we have to do this rigormarole because the Tekla Open API is not very good
List<ModelObject> modelObjects = getModelObjects(model);
List<Beam> beams = modelObjects.Select(obj => obj as Beam).Where(beam => beam != null).ToList();
// there are various ways you can get beams / objects:
// (i) programatically, as above, or perhaps
// (ii) by user selection
// this can be done from the model, or from drawings
if (beams.Count > 0)
{
Beam beam = beams.First(); // the first one
ModelObjectEnumerator bolts = beam.GetBolts();
while (bolts.MoveNext())
{
BoltGroup boltGroup = bolts.Current as BoltGroup;
if (boltGroup != null)
{
// now we want the bolt information some examples:
Console.WriteLine(boltGroup.BoltSize);
Console.WriteLine(boltGroup.BoltStandard);
Console.WriteLine(boltGroup.BoltPositions.Count);
Console.WriteLine(boltGroup.Length);
}
}
}
model.CommitChanges();
}
}
private static List<ModelObject> getModelObjects(Model model)
{
ModelObjectEnumerator enumerator = model.GetModelObjectSelector().GetAllObjects();
List<ModelObject> modelObjects = new List<ModelObject>();
while (enumerator.MoveNext())
{
ModelObject modelObject = enumerator.Current as ModelObject;
if (modelObject != null)
{
modelObjects.Add(modelObject);
}
}
return modelObjects;
}
}
}
Created
April 28, 2021 23:03
-
-
Save benkoshy/dfa4c48d29537c3de62deda2196b4745 to your computer and use it in GitHub Desktop.
Tekla Open API - Demonstrates a hello world example of how to get bolt information from a part
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment