Number list of drawings in Tekla Structures Macro.

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.

namespace Tekla.Technology.Akit.UserScript
{
    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 counter
            var CurrentDrawingHandler = new TSD.DrawingHandler(); // get current drawing handler
            var drawingsEnum = CurrentDrawingHandler.GetDrawingSelector().GetSelected(); //list of selected drawings
            while(drawingsEnum.MoveNext()) //going through it one by one
            {
                var _drawing = drawingsEnum.Current as TSD.Drawing;  //particular drawing
		i++;
		//and finally set number as "DRAWING.USERDEFINED.Page" UDA property.
		_drawing.SetUserProperty("Page", i.ToString()); //change "Page" to name of your UDA
            }
	return i;
        }
    }
}

How to use Tekla Macro Scripts with Tekla API

Tekla Macro Scripts - using in c# application or script
Quick view scale switch app example

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”