{"id":211,"date":"2017-05-26T10:19:48","date_gmt":"2017-05-26T10:19:48","guid":{"rendered":"http:\/\/cadsupport.ru\/en\/?p=211"},"modified":"2018-02-07T13:39:40","modified_gmt":"2018-02-07T13:39:40","slug":"tekla-custom-inquiry-macro-script","status":"publish","type":"post","link":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/","title":{"rendered":"Tekla Custom Inquiry macro script"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-215\" style=\"margin: 10px;\" src=\"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool-300x255.png\" alt=\"Tekla Structures custom inquire tool\" width=\"300\" height=\"255\" srcset=\"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool-300x255.png 300w, http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool.png 350w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/>One of the main advantages of\u00a0Tekla Structure is ability to get full necessary info about any part of model in couple clicks. I really appreciate this\u00a0thing but all default tools has some disadvantages.<\/p>\n<p>For example default <em>Inquire<\/em> return complete info about selected Entity, but about only one item per time, and only after user request. <em>Custom Inquire<\/em> &#8211; from <strong>Tools<\/strong> menu &#8211; is mach more flexible, but also &#8211; only one item, and \u00a0there is no way to get UDA.<\/p>\n<p>Organizer tool from the same menu &#8211; is pretty cool. But at the same time it&#8217;s pretty slow, and could freeze model for couple minutes.<\/p>\n<p>Reports, is awesome, but not interactive at all and require special skills and time to get used to with Template Editor.<\/p>\n<p>Let&#8217;s make our own custom Inquire, and it&#8217;s qute easy with C# and Tekla Open API.<\/p>\n<p>In one of previous articles was provided <a href=\"http:\/\/cadsupport.ru\/en\/how_to_events_tekla_structures_open_api\/\">Tekla API Envents example<\/a> from Tekla OpenAPI reference. Why not to make macro based on this feature?<\/p>\n<p>All what we have to do is:<\/p>\n<ul>\n<li>Make a form<\/li>\n<li>Sign this form on Tekla Event<\/li>\n<li>Grab data from Tekla each time when event appears<\/li>\n<li>Show it to user, in on a form<\/li>\n<li>Pack all this thing\u00a0in Tekla MacroScript<\/li>\n<\/ul>\n<p>Simple, and this macro could be downloaded under cut:<!--more--><\/p>\n<p><a href=\"http:\/\/cadsupport.ru\/en\/upload\/CADSUPPORT_CustomInquireTool.cs\">http:\/\/cadsupport.ru\/en\/upload\/CADSUPPORT_CustomInquireTool.cs<\/a><\/p>\n<p>If you do not now where to put it, and how to run\u00a0you could look here:\u00a0<a href=\"http:\/\/cadsupport.ru\/en\/work-tekla-structures-macro-scripts\/\">how to work with tekla structure macro script<\/a><\/p>\n<p>So now lets take a look on script it self. It&#8217;s based on example which was provided before in article about\u00a0<strong><a href=\"http:\/\/cadsupport.ru\/en\/how_to_events_tekla_structures_open_api\/\">Tekla Events<\/a><\/strong><\/p>\n<h2>Tekla Custom Inquire main method<\/h2>\n<p>Most interesting part of a scripts is represented in <em>Events_SelectionChangeEvent()<\/em> method. Here we grab all selected items from model in <em>manyO<\/em> enumerator. Then going through each element, and if this Entity suitable for us get some properties.<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"csharpcode\">        <span class=\"kwrd\">void<\/span> Events_SelectionChangeEvent()\r\n        {\r\n            <span class=\"kwrd\">lock<\/span> (_selectionEventHandlerLock)\r\n            {\r\n                Tekla.Structures.Model.UI.ModelObjectSelector selected = <span class=\"kwrd\">new<\/span> Tekla.Structures.Model.UI.ModelObjectSelector();\r\n                Tekla.Structures.Model.ModelObjectEnumerator manyO = (selected.GetSelectedObjects() <span class=\"kwrd\">as<\/span> ModelObjectEnumerator);\r\n                <span class=\"kwrd\">string<\/span> txt = <span class=\"kwrd\">string<\/span>.Empty;\r\n                while (manyO.MoveNext())\r\n                {\r\n                    <span class=\"kwrd\">string<\/span> GUID = <span class=\"kwrd\">string<\/span>.Empty;\r\n                    <span class=\"kwrd\">string<\/span> POS = <span class=\"kwrd\">string<\/span>.Empty;\r\n                    <span class=\"kwrd\">string<\/span> UDA = <span class=\"kwrd\">string<\/span>.Empty; \r\n                    <span class=\"kwrd\">if<\/span> ((manyO.Current <span class=\"kwrd\">as<\/span> Part) != <span class=\"kwrd\">null<\/span>) <span class=\"rem\">\/\/change for Assembly, Bolt, or whatever. <\/span>\r\n                    {\r\n                        <span class=\"kwrd\">var<\/span> pp = (manyO.Current <span class=\"kwrd\">as<\/span> Part); \r\n                            pp.GetReportProperty(<span class=\"str\">\"ASSEMBLY.GUID\"<\/span>, <span class=\"kwrd\">ref<\/span> GUID);\r\n                            pp.GetReportProperty(<span class=\"str\">\"ASSEMBLY_POS\"<\/span>, <span class=\"kwrd\">ref<\/span> POS);\r\n                            pp.GetReportProperty(<span class=\"str\">\"ASSEMBLY.MAINPART.USERDEFINED.SOME_UDA\"<\/span>, <span class=\"kwrd\">ref<\/span> UDA);\r\n                        txt += GUID + <span class=\"str\">\"; \"<\/span> + POS +<span class=\"str\">\"; \"<\/span>+UDA+Environment.NewLine; \r\n                    }\r\n                    <span class=\"kwrd\">else<\/span> <span class=\"kwrd\">if<\/span> ((manyO.Current <span class=\"kwrd\">as<\/span> Assembly)!= <span class=\"kwrd\">null<\/span>)\r\n                        {\r\n                        <span class=\"kwrd\">var<\/span> pp = (manyO.Current <span class=\"kwrd\">as<\/span> Assembly); \r\n                            pp.GetReportProperty(<span class=\"str\">\"GUID\"<\/span>, <span class=\"kwrd\">ref<\/span> GUID);\r\n                            pp.GetReportProperty(<span class=\"str\">\"ASSEMBLY_POS\"<\/span>, <span class=\"kwrd\">ref<\/span> POS);\r\n                            pp.GetReportProperty(<span class=\"str\">\"MAINPART.USERDEFINED.SOME_UDA\"<\/span>, <span class=\"kwrd\">ref<\/span> UDA);\r\n                            txt += GUID + <span class=\"str\">\"; \"<\/span> + POS +<span class=\"str\">\"; \"<\/span>+UDA+Environment.NewLine; \r\n                        }\r\n                }\r\n                SetText(txt.ToString());\/\/this method push result to form in separate thread\r\n            }\r\n        }<\/pre>\n<p>Additional example of code<br \/>\n<!-- code formatted by http:\/\/manoli.net\/csharpformat\/ --><\/p>\n<pre class=\"csharpcode\"><span class=\"rem\">\/\/ here we can check any object which inherite ModelObject interface bolts, welds, beams, assembly, etc<\/span>\r\n                <span class=\"kwrd\">if<\/span> ((manyO.Current <span class=\"kwrd\">as<\/span> ModelObject) != <span class=\"kwrd\">null<\/span>)\r\n                {\r\n                    <span class=\"kwrd\">var<\/span> pp = manyO.Current <span class=\"kwrd\">as<\/span> ModelObject;\r\n                        <span class=\"kwrd\">string<\/span> GUID = <span class=\"kwrd\">string<\/span>.Empty;\r\n                        <span class=\"kwrd\">string<\/span> POS = <span class=\"kwrd\">string<\/span>.Empty;\r\n                        <span class=\"kwrd\">string<\/span> UDA = <span class=\"kwrd\">string<\/span>.Empty;\r\n                        <span class=\"kwrd\">string<\/span> DP = <span class=\"kwrd\">string<\/span>.Empty;\r\n                        pp.GetReportProperty(<span class=\"str\">\"GUID\"<\/span>, <span class=\"kwrd\">ref<\/span> GUID);\r\n                        pp.GetReportProperty(<span class=\"str\">\"STANDARD\"<\/span>, <span class=\"kwrd\">ref<\/span> POS);\r\n                        pp.GetReportProperty(<span class=\"str\">\"ASSEMBLY.MAINPART.USERDEFINED.UDA\"<\/span>, <span class=\"kwrd\">ref<\/span> UDA);\r\n                        txt += GUID + <span class=\"str\">\"\\t \"<\/span> + POS + <span class=\"str\">\"\\t \"<\/span> + UDA + Environment.NewLine;\r\n                }<\/pre>\n<h2>More articles about Tekla OpenAPI and Macro<\/h2>\n<ul>\n<li><a href=\"http:\/\/cadsupport.ru\/en\/tekla-api-delete-cuts\/\">How to delete cuts from pats with tekla Api<\/a><\/li>\n<li><a href=\"http:\/\/cadsupport.ru\/en\/how_to_events_tekla_structures_open_api\/\">How to work with Events in Tekla Structures<\/a><\/li>\n<li><a href=\"http:\/\/cadsupport.ru\/en\/work-tekla-structures-macro-scripts\/\">How to work with Tekla Structures Macro scripts<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>One of the main advantages of\u00a0Tekla Structure is ability to get full necessary info about any part of model in couple clicks. I really appreciate this\u00a0thing 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. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,5],"tags":[16,17,38,28,21,25],"class_list":["post-211","post","type-post","status-publish","format-standard","hentry","category-programing","category-tekla","tag-macro","tag-programming","tag-tek","tag-tekla","tag-tekla-script","tag-teklaapi"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Tekla Custom Inquiry macro script - CadSupport<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Tekla Custom Inquiry macro script - CadSupport\" \/>\n<meta property=\"og:description\" content=\"One of the main advantages of\u00a0Tekla Structure is ability to get full necessary info about any part of model in couple clicks. I really appreciate this\u00a0thing 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. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/\" \/>\n<meta property=\"og:site_name\" content=\"CadSupport\" \/>\n<meta property=\"article:published_time\" content=\"2017-05-26T10:19:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-02-07T13:39:40+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool-300x255.png\" \/>\n<meta name=\"author\" content=\"DonJad\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DonJad\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/\",\"url\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/\",\"name\":\"Tekla Custom Inquiry macro script - CadSupport\",\"isPartOf\":{\"@id\":\"http:\/\/cadsupport.ru\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#primaryimage\"},\"image\":{\"@id\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#primaryimage\"},\"thumbnailUrl\":\"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool-300x255.png\",\"datePublished\":\"2017-05-26T10:19:48+00:00\",\"dateModified\":\"2018-02-07T13:39:40+00:00\",\"author\":{\"@id\":\"http:\/\/cadsupport.ru\/en\/#\/schema\/person\/b57bc479c7822ae8efbc5a5b624a3b8a\"},\"breadcrumb\":{\"@id\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#primaryimage\",\"url\":\"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool.png\",\"contentUrl\":\"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool.png\",\"width\":350,\"height\":298,\"caption\":\"Tekla Structures custom inquire tool\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/cadsupport.ru\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Tekla Custom Inquiry macro script\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/cadsupport.ru\/en\/#website\",\"url\":\"http:\/\/cadsupport.ru\/en\/\",\"name\":\"CadSupport\",\"description\":\"smart solutions for engineering duties\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/cadsupport.ru\/en\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/cadsupport.ru\/en\/#\/schema\/person\/b57bc479c7822ae8efbc5a5b624a3b8a\",\"name\":\"DonJad\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/cadsupport.ru\/en\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b22cdec01f0612764c8b311b89954151bfb042524440d622849757864e132a55?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b22cdec01f0612764c8b311b89954151bfb042524440d622849757864e132a55?s=96&d=mm&r=g\",\"caption\":\"DonJad\"},\"url\":\"http:\/\/cadsupport.ru\/en\/author\/donjad\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Tekla Custom Inquiry macro script - CadSupport","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/","og_locale":"en_US","og_type":"article","og_title":"Tekla Custom Inquiry macro script - CadSupport","og_description":"One of the main advantages of\u00a0Tekla Structure is ability to get full necessary info about any part of model in couple clicks. I really appreciate this\u00a0thing 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. [&hellip;]","og_url":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/","og_site_name":"CadSupport","article_published_time":"2017-05-26T10:19:48+00:00","article_modified_time":"2018-02-07T13:39:40+00:00","og_image":[{"url":"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool-300x255.png"}],"author":"DonJad","twitter_card":"summary_large_image","twitter_misc":{"Written by":"DonJad","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/","url":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/","name":"Tekla Custom Inquiry macro script - CadSupport","isPartOf":{"@id":"http:\/\/cadsupport.ru\/en\/#website"},"primaryImageOfPage":{"@id":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#primaryimage"},"image":{"@id":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#primaryimage"},"thumbnailUrl":"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool-300x255.png","datePublished":"2017-05-26T10:19:48+00:00","dateModified":"2018-02-07T13:39:40+00:00","author":{"@id":"http:\/\/cadsupport.ru\/en\/#\/schema\/person\/b57bc479c7822ae8efbc5a5b624a3b8a"},"breadcrumb":{"@id":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#primaryimage","url":"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool.png","contentUrl":"http:\/\/cadsupport.ru\/en\/wp-content\/uploads\/2017\/05\/Tekla_structures_cadsupport_custom_inquire_tool.png","width":350,"height":298,"caption":"Tekla Structures custom inquire tool"},{"@type":"BreadcrumbList","@id":"http:\/\/cadsupport.ru\/en\/tekla-custom-inquiry-macro-script\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/cadsupport.ru\/en\/"},{"@type":"ListItem","position":2,"name":"Tekla Custom Inquiry macro script"}]},{"@type":"WebSite","@id":"http:\/\/cadsupport.ru\/en\/#website","url":"http:\/\/cadsupport.ru\/en\/","name":"CadSupport","description":"smart solutions for engineering duties","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/cadsupport.ru\/en\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/cadsupport.ru\/en\/#\/schema\/person\/b57bc479c7822ae8efbc5a5b624a3b8a","name":"DonJad","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/cadsupport.ru\/en\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b22cdec01f0612764c8b311b89954151bfb042524440d622849757864e132a55?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b22cdec01f0612764c8b311b89954151bfb042524440d622849757864e132a55?s=96&d=mm&r=g","caption":"DonJad"},"url":"http:\/\/cadsupport.ru\/en\/author\/donjad\/"}]}},"_links":{"self":[{"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/posts\/211","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":11,"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":315,"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/posts\/211\/revisions\/315"}],"wp:attachment":[{"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cadsupport.ru\/en\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}