{"id":1391,"date":"2016-01-18T20:28:12","date_gmt":"2016-01-18T20:28:12","guid":{"rendered":"http:\/\/elbsolutions.com\/projects\/?p=1391"},"modified":"2022-02-03T11:24:34","modified_gmt":"2022-02-03T17:24:34","slug":"getting-xyz-navisworks-insertion-point-automation-net-vba","status":"publish","type":"post","link":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/","title":{"rendered":"Getting XYZ or Navisworks Insertion Point through automation .net or VBA"},"content":{"rendered":"<p>Here are the steps and sample code I made to learn about getting the <strong>navisworks insertion point<\/strong> or<strong>\u00a0<\/strong>midpoint of a component. <a href=\"http:\/\/elbsolutions.com\/projects\/navisworks-com-api-a-little-old-and-really-cantakerous-but-i-finally-i-can-find-an-object-by-name\/\">I know how to find the component by its id<\/a> (I am using AutoPLANT component id), now I know how to find the midpoint of that\u00a0component or the location of that component.<\/p>\n<h2>Steps to find the navisworks insertion point<\/h2>\n<ul>\n<li><a href=\"http:\/\/adndevblog.typepad.com\/aec\/2012\/06\/accessing-the-file-units-and-location-information-using-navisworks-net-api.html\">Accessing the file units and location information using Navisworks .NET API<\/a><\/li>\n<li>A pdf primer on Navisworks basic objects and how those objects are related (key resource)<\/li>\n<li>I made some VBA to put pause points and look at objects as they went by. In short\n<ul>\n<li>start with a path object &#8211; in this code example &#8211; the currently selected objects (so select one to keep it easy!!!)<\/li>\n<li>Pause points\/Interest points are the Beep lines which might have been replaced with Debug.Print lines<\/li>\n<li>In our example, I am looking for AutoPLANT components with a unique id that would\u00a0similar to\u00a0&#8220;AT_HSHF31AB_2Q7&#8221; (the 2nd set of strings is the doc id and the last part is the unique AutoPLANT part id in that doc)<\/li>\n<li>look for through the code below for \u00a0*********** ANSWER *********** to get where we get the Navisworks Insertion or midpoint of our\u00a0component<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><!--more--><\/p>\n<h2>Code to find\u00a0the navisworks insertion point\u00a0&#8211; read the comments to follow along<\/h2>\n<pre class=\"brush: vb; title: ; notranslate\" title=\"\">\r\n\r\nSub FindSomething()\r\nDim nwObj As NavisworksAutomationAPI10.Document\r\nSet nwObj = GetObject(, &quot;Navisworks.Document.10&quot;) 'nw 2013\r\nDebug.Print &quot;Visible:&quot; &amp; nwObj.Visible\r\n\r\n\r\nnwObj.Visible = True\r\nnwObj.StayOpen ' critical!!!! See http:\/\/elbsolutions.com\/projects\/getobjectclassnamehere-only-works-the-first-time-why-a-look-into-the-rot-table-navisworks-and-other-apps-too-that-use-activex\/\r\n'nwObj.state.CurrentView = nwObj.state.SavedViews(1).anonview\r\n\r\nDim mstate As InwOpState\r\nSet mstate = nwObj.state\r\n\r\nDim bob As VarEnum\r\nDim b As Variant\r\nDim b1 As InwSelectionPathsColl\r\nDim myPath As InwOaPath\r\n\r\n\r\n\r\nDim N As Variant\r\nDim myNode As InwOaNode\r\nDim n1 As InwOaPartition\r\nDim bBox As InwLBox3f\r\n\r\nDim a As Variant\r\nDim a1 As InwOaPublishAttribute\r\nDim a2 As InwOaPropertyAttribute\r\nDim a3 As InwOaPropertyAttribute\r\nDim a4 As InwOaPropertyAttribute\r\n\r\nBeep 'Pause here\r\n\r\nFor Each b In mstate.CurrentSelection.Paths\r\nSet myPath = b\r\nDebug.Print &quot;ObjectName: &quot; &amp; myPath.ObjectName\r\n\r\n'The loop here was added near the end of the investigation so we can see how\r\n' myPath is assembled\/represented - in specific UserName\r\nFor Each N In myPath.Nodes\r\nSet myNode = N\r\nDebug.Print &quot;Class: &quot; &amp; myNode.ClassName &amp; &quot; ClassUserName:&quot; &amp; myNode.ClassUserName &amp; &quot; UserName: &quot; &amp; myNode.username\r\n'Beep 'Pause here\r\nNext\r\n\r\n\r\n'This is the orignal loop looking at attributes and other properties of the nodes in each path\r\nFor Each N In myPath.Nodes\r\nSet myNode = N\r\n\r\nSet bBox = myNode.GetBoundingBox(False, False)\r\nBeep ' pause here to take a look at myNode and bBox\r\n' the myNode nodes seem to transverse the heirarchy from the root downwards\r\n' down the path 'b'\r\n\r\nIf (VBA.Left(myNode.username, 3) = &quot;AT_&quot;) Then ' this line was added after I looked at the UserName property and it was the string I was interested in\r\nDebug.Print &quot;&quot;\r\nDebug.Print &quot;myPath.Nodes.ObjectName:&quot; &amp; N.ObjectName\r\nDebug.Print &quot;myPath.Nodes.ObjectName (isGeometry):&quot; &amp; myNode.IsGeometry\r\nDebug.Print &quot;myPath.Nodes.ObjectName (isGeometry):&quot; &amp; myNode.IsGeometry\r\n\r\nIf Not bBox.IsEmpty Then\r\n\r\n' Here is the bounding box's limits and average (mid point)\r\n' the mid point is the xyz location we are intereseted in.\r\n' ******** ANSWER ************\r\nDebug.Print &quot;Data1 min: &quot; &amp; bBox.min_pos.Data1 &amp; &quot; max: &quot; &amp; bBox.max_pos.Data1 &amp; &quot; avg: &quot; &amp; ((bBox.min_pos.Data1 + bBox.max_pos.Data1) \/ 2)\r\nDebug.Print &quot;Data2 min: &quot; &amp; bBox.min_pos.Data2 &amp; &quot; max: &quot; &amp; bBox.max_pos.Data2 &amp; &quot; avg: &quot; &amp; ((bBox.min_pos.Data2 + bBox.max_pos.Data2) \/ 2)\r\nDebug.Print &quot;Data3 min: &quot; &amp; bBox.min_pos.Data3 &amp; &quot; max: &quot; &amp; bBox.max_pos.Data3 &amp; &quot; avg: &quot; &amp; ((bBox.min_pos.Data3 + bBox.max_pos.Data3) \/ 2)\r\nEnd If\r\n\r\n\r\n'Set n1 = n\r\nIf N.ObjectName &lt;&gt; &quot;nwOaPath&quot; And N.ObjectName &lt;&gt; &quot;nwOaPartition&quot; Then\r\n\r\nBeep\r\nFor Each a In N.Attributes\r\nDebug.Print vbTab &amp; &quot;** attribute.ObjectName:&quot; &amp; a.ObjectName\r\n'Beep ' Pause Here\r\n\r\n' I think the info below is a red-herring for what I require\r\n\r\nSelect Case a.ObjectName\r\n\r\nCase &quot;nwOaPublishAttribute&quot;\r\nSet a1 = a\r\nDebug.Print &quot;author:&quot; &amp; a1.Author\r\nDebug.Print &quot;ClassName:&quot; &amp; a1.ClassName\r\nDebug.Print &quot;ClassUserName:&quot; &amp; a1.ClassUserName\r\nDebug.Print &quot;Comments:&quot; &amp; a1.Comments\r\nDebug.Print &quot;Copyright:&quot; &amp; a1.Copyright\r\n'Debug.Print &quot;ExpiryDate:&quot; &amp; CStr(a1.ExpiryDate)\r\nDebug.Print &quot;flags:&quot; &amp; a1.flags\r\nDebug.Print &quot;Keywords:&quot; &amp; a1.Keywords\r\nDebug.Print &quot;ObjectName:&quot; &amp; a1.ObjectName\r\nDebug.Print &quot;Subject:&quot; &amp; a1.Subject\r\nDebug.Print &quot;Title:&quot; &amp; a1.Title\r\nDebug.Print &quot;UserName:&quot; &amp; a1.username\r\nCase &quot;nwOaPartition&quot;\r\nBeep\r\nCase &quot;nwOaMaterial&quot;\r\nDim mat As InwOaMaterial\r\nSet mat = a\r\n\r\nCase Else\r\nDim apart As InwOaPartition\r\nDim apropa As InwOaPropertyAttribute\r\n\r\n' Set apropa = a\r\n\r\n' Set apart = a\r\n\r\nBeep\r\nEnd Select\r\n'Set a1 = a\r\n\r\nBeep\r\nNext\r\nBeep\r\nEnd If\r\nEnd If\r\nNext\r\n\r\n\r\nNext\r\nmstate.CurrentSelection.Paths\r\n\r\nBeep\r\n\r\nEnd Sub\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here are the steps and sample code I made to learn about getting the navisworks insertion point or\u00a0midpoint of a component. I know how to find the component by its id (I am using AutoPLANT component id), now I know how to find the midpoint of that\u00a0component or the location of that component. Steps to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1391","post","type-post","status-publish","format-standard","hentry","category-general"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Getting XYZ or Navisworks Insertion Point through automation .net or VBA - ELB Solutions.com Inc.<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Getting XYZ or Navisworks Insertion Point through automation .net or VBA - ELB Solutions.com Inc.\" \/>\n<meta property=\"og:description\" content=\"Here are the steps and sample code I made to learn about getting the navisworks insertion point or\u00a0midpoint of a component. I know how to find the component by its id (I am using AutoPLANT component id), now I know how to find the midpoint of that\u00a0component or the location of that component. Steps to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/\" \/>\n<meta property=\"og:site_name\" content=\"ELB Solutions.com Inc.\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-18T20:28:12+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-02-03T17:24:34+00:00\" \/>\n<meta name=\"author\" content=\"Etienne Bley\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Etienne Bley\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/\"},\"author\":{\"name\":\"Etienne Bley\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"headline\":\"Getting XYZ or Navisworks Insertion Point through automation .net or VBA\",\"datePublished\":\"2016-01-18T20:28:12+00:00\",\"dateModified\":\"2022-02-03T17:24:34+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/\"},\"wordCount\":886,\"articleSection\":[\"General\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/\",\"name\":\"Getting XYZ or Navisworks Insertion Point through automation .net or VBA - ELB Solutions.com Inc.\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\"},\"datePublished\":\"2016-01-18T20:28:12+00:00\",\"dateModified\":\"2022-02-03T17:24:34+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/getting-xyz-navisworks-insertion-point-automation-net-vba\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Getting XYZ or Navisworks Insertion Point through automation .net or VBA\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#website\",\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/\",\"name\":\"ELB Solutions.com Inc.\",\"description\":\"Bringing all your IT Pieces together\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/#\\\/schema\\\/person\\\/51e717c68f4f5917c63baf88f0896c39\",\"name\":\"Etienne Bley\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g\",\"caption\":\"Etienne Bley\"},\"url\":\"https:\\\/\\\/elbsolutions.com\\\/projects\\\/author\\\/etienne-bley\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Getting XYZ or Navisworks Insertion Point through automation .net or VBA - ELB Solutions.com Inc.","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":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/","og_locale":"en_US","og_type":"article","og_title":"Getting XYZ or Navisworks Insertion Point through automation .net or VBA - ELB Solutions.com Inc.","og_description":"Here are the steps and sample code I made to learn about getting the navisworks insertion point or\u00a0midpoint of a component. I know how to find the component by its id (I am using AutoPLANT component id), now I know how to find the midpoint of that\u00a0component or the location of that component. Steps to [&hellip;]","og_url":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/","og_site_name":"ELB Solutions.com Inc.","article_published_time":"2016-01-18T20:28:12+00:00","article_modified_time":"2022-02-03T17:24:34+00:00","author":"Etienne Bley","twitter_misc":{"Written by":"Etienne Bley","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/#article","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/"},"author":{"name":"Etienne Bley","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"headline":"Getting XYZ or Navisworks Insertion Point through automation .net or VBA","datePublished":"2016-01-18T20:28:12+00:00","dateModified":"2022-02-03T17:24:34+00:00","mainEntityOfPage":{"@id":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/"},"wordCount":886,"articleSection":["General"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/","url":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/","name":"Getting XYZ or Navisworks Insertion Point through automation .net or VBA - ELB Solutions.com Inc.","isPartOf":{"@id":"https:\/\/elbsolutions.com\/projects\/#website"},"datePublished":"2016-01-18T20:28:12+00:00","dateModified":"2022-02-03T17:24:34+00:00","author":{"@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39"},"breadcrumb":{"@id":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/elbsolutions.com\/projects\/getting-xyz-navisworks-insertion-point-automation-net-vba\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/elbsolutions.com\/projects\/"},{"@type":"ListItem","position":2,"name":"Getting XYZ or Navisworks Insertion Point through automation .net or VBA"}]},{"@type":"WebSite","@id":"https:\/\/elbsolutions.com\/projects\/#website","url":"https:\/\/elbsolutions.com\/projects\/","name":"ELB Solutions.com Inc.","description":"Bringing all your IT Pieces together","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/elbsolutions.com\/projects\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/elbsolutions.com\/projects\/#\/schema\/person\/51e717c68f4f5917c63baf88f0896c39","name":"Etienne Bley","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f8971dfb65b25b768415568f83247df4057f15d037137e386928a804e2c997b9?s=96&d=mm&r=g","caption":"Etienne Bley"},"url":"https:\/\/elbsolutions.com\/projects\/author\/etienne-bley\/"}]}},"_links":{"self":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1391","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/comments?post=1391"}],"version-history":[{"count":4,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1391\/revisions"}],"predecessor-version":[{"id":1397,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/posts\/1391\/revisions\/1397"}],"wp:attachment":[{"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/media?parent=1391"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/categories?post=1391"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elbsolutions.com\/projects\/wp-json\/wp\/v2\/tags?post=1391"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}