-
-
Save benkoshy/4097904b109645fc1acc1303d628504a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Ok here's the challenge. | |
// The Tekla API is full of quirks that make absolutely no sense. | |
// This is one of them. | |
// Challenge: to everyday, write in just one CLASS attribute which corresponds to an enumeration. | |
// Hopefully this will be of use to someone. It will save you from remembering and/or looking up the relevant enumeration. | |
// there are a billion more quirks in the API. | |
// So I wonder in 100 days whether I will have smashed this out? Only time will tell. | |
// Wish me luck! | |
// Mr Dale Nichols suggested the code so I must attribute it. | |
// I hope to build it up. | |
public static class ReportPropertyExtensions | |
{ | |
public enum Variables | |
{ | |
CLASS_ATTR, | |
FINISH | |
} | |
public static string GetReportProperty(this TSM.Part part, Variables variable) | |
{ | |
string value = ""; | |
part.GetReportProperty(variable.ToString(), ref value); | |
return value; | |
} | |
} | |
// usage... | |
private void demo() | |
{ | |
ModelObjectEnumerator modelObjectEnum = modelObjectSelector.GetSelectedObjects(); | |
while (modelObjectEnum.MoveNext()) | |
{ | |
if (modelObjectEnum.Current is TSM.Part) | |
{ | |
TSM.Part part = (TSM.Part)modelObjectEnum.Current; | |
Console.WriteLine(part.GetReportProperty(Extensions.Variables.CLASS_ATTR)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment