Every now and again we obtain a request from our readership to tackle a problem. If it is of general interest to the public and given our commitments we do sometimes oblige. Here is one such interesting problem. We will tackle this in three parts, and will focus on part 1 in this blog post.
- Get every SinglePartDrawing which name starts with “HEA/IPE/CC”
- Calculate the distance of every bolt distance from the start of the corresponding Single Part.
- Write the name of the Single Part and every bolt distance to Excel.
- Refactor the code.
The first part is easy enough – and the code is pretty self-explanatory. We want to iterate through all the drawings and filter for the specific drawings that we are after.
Here is the code:
In the next part, we will look at obtaining the relevant parts that we want and calculating the bolt distances from the start and end points. And finally, we will look at refactoring the code, because it is a little slow, and also from a maintainability point of view.
- I was simply following the instructions of the question without inquiring too far into its purpose. If you actually want to extract NC information via the API – Tekla can very easily do this. But that was not the scope of this particular task – it was to deliver a very specific and peculiar set of requirements to a particular reader, but it is a topic which will be of general import to the public.