Small evolving of previous example. Here list of required atributes is set by text mask, elements is separated by semicolon, result pushed to table view. In this way it sems much more nice and useful for quick inquire model parts. And it works with all kind of model objects. Even model itself.
Sometimes required start-to-end numbering. Clear and consistent list of numbers for each drawing. There are many different ways to solve issue this kind. As for me, I prefer to use a small and useful script.
What we will do is to set for each selected drawing in drawings list a number, one by one these will get a straight list of numbers.
So first we have to get access to a list of selected drawings. Then move through each element, and add a number. Isn’t pretty simple it? Listing of script is also small and useful, so you could rearrange it for your needs.
using TSD = Tekla.Structures.Drawing;
using System.Windows.Forms; //used for messageBox.show()public class Script
public static void Run(Tekla.Technology.Akit.IScript akit)
MessageBox.Show("Total number of drawings: " + CAD_NumberSelectedDrawings().ToString());
static int CAD_NumberSelectedDrawings()
int i = 0; //register number countervar CurrentDrawingHandler = new TSD.DrawingHandler(); // get current drawing handlervar drawingsEnum = CurrentDrawingHandler.GetDrawingSelector().GetSelected(); //list of selected drawingswhile(drawingsEnum.MoveNext()) //going through it one by one
var _drawing = drawingsEnum.Current as TSD.Drawing; //particular drawing
//and finally set number as "DRAWING.USERDEFINED.Page" UDA property.
_drawing.SetUserProperty("Page", i.ToString()); //change "Page" to name of your UDA
If you need access to selected drawings in list of Tekla Drawings – next piece of code will be useful
var CurrentDrawingHandler = new TSD.DrawingHandler(); //Get handler - seems easy.
var drawingsEnum = CurrentDrawingHandler.GetDrawingSelector().GetSelected(); //Get a list of selected drawings
while(drawingsEnum.MoveNext()) //goest through that list
var _drawing = drawingsEnum.Current as TSD.Drawing; //here is a particular drawing which we coudl work width
string some_string = string.Empty;
_drawing .GetUserProperty("Default", ref some_string );//let's do sometring, get some UDA for example.
MessageBox.Show(some_string ); //And show it
Issue – Tekla BIM sight provided all information, but weight of each particular model is actually big (because it’s IFC file actually, see more).
However, Tekla provides also Tekla Web View application which using xml format to show 3d model – it’s 5-10 times smaller and works faster, but there is no way to export presentation of required bolts.
After Playing with TeklaAPI and Tekla Web View xml format push me to update information of web view with related bolts.
Seems that this could be Cheapest and fastest way to share model with colleagues.
I Really like 2D array component for Tekla Structures, not only because it was done by me, but because from time to time it brings surprises. This pictures provided as conclusion after additional implementation in custom project. All geometry on these pictures done by 2D array component and default cutting component. Which means – all what you see is just two components. Bellow a little bit more interesting examples.
One of the main advantages of Tekla Structure is ability to get full necessary info about any part of model in couple clicks. I really appreciate this thing but all default tools has some disadvantages.
For example default Inquire return complete info about selected Entity, but about only one item per time, and only after user request. Custom Inquire – from Tools menu – is mach more flexible, but also – only one item, and there is no way to get UDA.
Organizer tool from the same menu – is pretty cool. But at the same time it’s pretty slow, and could freeze model for couple minutes.
Reports, is awesome, but not interactive at all and require special skills and time to get used to with Template Editor.
Let’s make our own custom Inquire, and it’s qute easy with C# and Tekla Open API.
In one of previous articles was provided Tekla API Envents example from Tekla OpenAPI reference. Why not to make macro based on this feature?
Tekla structures include Tekla API, and we could use it for various cases which could impact engineering process at different stages. Here provided smart solution which allows to delete polygon cuts from plates filter by it’s maximum size.
It’s just an example of how complicated task could be easily solved with Tekla API.
Try to imagine a thousands of plates with various tiny holes spreader through these. These should be drilled by CNC machine tool, but each hole done as a tiny rounded plate, which ruins our plans for automatic drill. Hence we need to remove these, but there is no way to delete it all at once. Cause at the same time major holes also done by plate cuts. Clearing these plates from holes one by one manually – could take a day. Instead of that with API list of various issues of such type could be solved in a minutes.
Using Events in C# is a good way to make your application more sensitive and add interactivity abilities to your solutions. These allows you to reply at changes in Tekla Model or Drawing, as soon as they arrived. But in other side Events is pretty complicated for understanding and it not so easy to apply in your solution. So for better understanding of mechanism of Events you should understand of how delegates work.
Tekla Structures allows to record whole user activity to macro script, and then you could play it again and again. This allows to save time on some routine. And if we take in case that Tekla Structures developers loves menus, and submenus, and sub-submenus, and buttons, and… all this stuff. With bunch of parameters, and applying /modifying… so save some clicks would be great idea, and macros really cool thing for this.
If you carefully study the Tekla API, then pretty soon you will notice that the functionality which is listed at Reference Documentations does not exhaust the whole possibilities of Tekla Structures. If you have access to the Tekla Extranet, in the appropriate forums, you can see that it is indeed the case. However a way to use all the functions exists. It consists in working with Tekla Macro Scripts. Continue reading “How to use Tekla Macro Scripts with Tekla API”→