{"id":2055,"date":"2014-03-22T11:46:21","date_gmt":"2014-03-22T10:46:21","guid":{"rendered":"https:\/\/www.modelical.com\/?p=474"},"modified":"2022-03-21T12:53:07","modified_gmt":"2022-03-21T11:53:07","slug":"pack-rhino-objects-one-block-per-layer-scripting","status":"publish","type":"post","link":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/","title":{"rendered":"Pack Rhino Objects"},"content":{"rendered":"<h2>One Block Per Layer &#8211; RhinoScripting<\/h2>\n<p>Yesterday evening,we were exporting a Rhino model (containing mainly meshes) to SketchUp. We used DWG as translation format and the resulting model was a soup of triangles, so we thought it would be a good idea to pack every layer in our Rhino model into a block so SketchUp would convert each block into a component.\n<\/p>\n<p>This would isolate the edges of each object from those in other layers and make selection more convenient. \u00a0Instead of spending 10 minutes packing each of the 20 layers our file had, we thought we could write a script to do so for us. In the end it took us more than expected as my RhinoScripting is a bit (maybe a lot) rusty.<\/p>\n<p>Here is the code, you can copy and paste it in a new file or, if feeling lazy, just <a title=\"Layers2Blocks - ZIP File\" href=\"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/03\/Layers2Blocks.zip\">download the file.<\/a><\/p>\n<pre class=\"lang:vb decode:true\">Option Explicit\r\n'Script written by Roberto Molinos @robertomolinos\r\n'Script copylefted by Modelical \/\/ free to use, improve and share\r\n'Script version Friday, 21 March 2014 19:58:18\r\n\r\nCall Layers2Blocks()\r\nSub Layers2Blocks()\r\n\r\n\tDim strFile\r\n\tDim arrLayers, strLayer, strBlock\r\n\tDim arrSelected, arrPoint\r\n\r\n\t' Get names of all layers\r\n\tarrLayers = Rhino.LayerNames\r\n\r\n\t' Disable redrawing\r\n\tRhino.EnableRedraw False\r\n\r\n\t' Process each layer\r\n\tFor Each strLayer In arrLayers\r\n\r\n\t\t' Unselect all  \r\n\t\tRhino.Command \"_-SelNone\", 0\r\n\r\n\t\t' Select all objects on layer. Surround layer name\r\n\t\t' with double-quotes in case it includes spaces.\r\n\t\tRhino.Command \"_-SelLayer \" &amp; Chr(34) &amp; strLayer &amp; Chr(34), 0\r\n\r\n\t\t' Make sure some objects were selected\r\n\t\tarrSelected = Rhino.SelectedObjects\r\n\t\tIf IsArray(arrSelected) Then\r\n\r\n\t\t\t'Create insertion point at 0,0,0\r\n\t\t\tarrPoint = Array(0, 0, 0)\r\n\t\t\t'Set current layer so block is created on the same one\r\n\t\t\tCall Rhino.CurrentLayer(strLayer)\r\n                        'Create block\r\n\t\t\tstrBlock = Rhino.AddBlock(arrSelected, arrPoint, strLayer, True)\r\n\t\t\t'Delete objects as they are now in the block\r\n\t\t\tCall Rhino.DeleteObjects(arrSelected)\r\n                        'Insert the block\r\n\t\t\tCall Rhino.InsertBlock(strBlock, arrPoint)\r\n\r\n\t\tEnd If\r\n\t\t' Unselect all\r\n\t\tRhino.Command \"_-SelNone\", 0\r\n\tNext\r\n\r\n\t' Unselect all\r\n\tRhino.Command \"_-SelNone\", 0\r\n\r\n\t' Enable redrawing\r\n\tRhino.EnableRedraw True\r\nEnd Sub<\/pre>\n<p>This post was inspired by a similiar one in the <a title=\"Export Layer Objects\" href=\"http:\/\/wiki.mcneel.com\/developer\/scriptsamples\/exportlayerobjects\">McNeel Wiki &#8211; ExportLayerObjects<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>One Block Per Layer &#8211; RhinoScripting Yesterday evening,we were exporting a Rhino model (containing mainly meshes) to SketchUp. We used DWG as translation format and the resulting model was a soup of triangles, so we thought it would be a good idea to pack every layer in our Rhino model into a block so SketchUp [&hellip;]<\/p>\n","protected":false},"author":64,"featured_media":27193,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[4],"tags":[649],"class_list":["post-2055","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guidelines","tag-technology-rhino"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>[:en]Pack Rhino Objects - Modelical [:es]Paquete de Objetos Rhino - RhinoScripting - Modelical[:]<\/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:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[:en]Pack Rhino Objects - Modelical [:es]Paquete de Objetos Rhino - RhinoScripting - Modelical[:]\" \/>\n<meta property=\"og:description\" content=\"One Block Per Layer &#8211; RhinoScripting Yesterday evening,we were exporting a Rhino model (containing mainly meshes) to SketchUp. We used DWG as translation format and the resulting model was a soup of triangles, so we thought it would be a good idea to pack every layer in our Rhino model into a block so SketchUp [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/\" \/>\n<meta property=\"og:site_name\" content=\"Modelical\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Modelical\/\" \/>\n<meta property=\"article:published_time\" content=\"2014-03-22T10:46:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-03-21T11:53:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.modelical.com\/wp-content\/uploads\/Posts_39_Rhinoceros.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"375\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Roberto Molinos\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@modelical\" \/>\n<meta name=\"twitter:site\" content=\"@modelical\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Roberto Molinos\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/\"},\"author\":{\"name\":\"Roberto Molinos\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#\\\/schema\\\/person\\\/3ad52fd99e6b5b98a59ef24c76a7c2d5\"},\"headline\":\"Pack Rhino Objects\",\"datePublished\":\"2014-03-22T10:46:21+00:00\",\"dateModified\":\"2022-03-21T11:53:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/\"},\"wordCount\":163,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/Rhinoceros-400x250-1.jpg\",\"keywords\":[\"Tec Rhino\"],\"articleSection\":[\"Guidelines\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/\",\"url\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/\",\"name\":\"[:en]Pack Rhino Objects - Modelical [:es]Paquete de Objetos Rhino - RhinoScripting - Modelical[:]\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/Rhinoceros-400x250-1.jpg\",\"datePublished\":\"2014-03-22T10:46:21+00:00\",\"dateModified\":\"2022-03-21T11:53:07+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#\\\/schema\\\/person\\\/3ad52fd99e6b5b98a59ef24c76a7c2d5\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/pack-rhino-objects-one-block-per-layer-scripting\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/Rhinoceros-400x250-1.jpg\",\"contentUrl\":\"https:\\\/\\\/www.modelical.com\\\/wp-content\\\/uploads\\\/2014\\\/03\\\/Rhinoceros-400x250-1.jpg\",\"width\":400,\"height\":250},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#website\",\"url\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/\",\"name\":\"Modelical\",\"description\":\"We build information\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/#\\\/schema\\\/person\\\/3ad52fd99e6b5b98a59ef24c76a7c2d5\",\"name\":\"Roberto Molinos\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro\",\"caption\":\"Roberto Molinos\"},\"sameAs\":[\"https:\\\/\\\/www.modelical.com\"],\"url\":\"https:\\\/\\\/www.modelical.com\\\/en\\\/author\\\/roberto\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[:en]Pack Rhino Objects - Modelical [:es]Paquete de Objetos Rhino - RhinoScripting - Modelical[:]","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:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/","og_locale":"en_US","og_type":"article","og_title":"[:en]Pack Rhino Objects - Modelical [:es]Paquete de Objetos Rhino - RhinoScripting - Modelical[:]","og_description":"One Block Per Layer &#8211; RhinoScripting Yesterday evening,we were exporting a Rhino model (containing mainly meshes) to SketchUp. We used DWG as translation format and the resulting model was a soup of triangles, so we thought it would be a good idea to pack every layer in our Rhino model into a block so SketchUp [&hellip;]","og_url":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/","og_site_name":"Modelical","article_publisher":"https:\/\/www.facebook.com\/Modelical\/","article_published_time":"2014-03-22T10:46:21+00:00","article_modified_time":"2022-03-21T11:53:07+00:00","og_image":[{"width":600,"height":375,"url":"https:\/\/www.modelical.com\/wp-content\/uploads\/Posts_39_Rhinoceros.jpg","type":"image\/jpeg"}],"author":"Roberto Molinos","twitter_card":"summary_large_image","twitter_creator":"@modelical","twitter_site":"@modelical","twitter_misc":{"Written by":"Roberto Molinos","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/#article","isPartOf":{"@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/"},"author":{"name":"Roberto Molinos","@id":"https:\/\/www.modelical.com\/en\/#\/schema\/person\/3ad52fd99e6b5b98a59ef24c76a7c2d5"},"headline":"Pack Rhino Objects","datePublished":"2014-03-22T10:46:21+00:00","dateModified":"2022-03-21T11:53:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/"},"wordCount":163,"commentCount":0,"image":{"@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/#primaryimage"},"thumbnailUrl":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/03\/Rhinoceros-400x250-1.jpg","keywords":["Tec Rhino"],"articleSection":["Guidelines"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/","url":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/","name":"[:en]Pack Rhino Objects - Modelical [:es]Paquete de Objetos Rhino - RhinoScripting - Modelical[:]","isPartOf":{"@id":"https:\/\/www.modelical.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/#primaryimage"},"image":{"@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/#primaryimage"},"thumbnailUrl":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/03\/Rhinoceros-400x250-1.jpg","datePublished":"2014-03-22T10:46:21+00:00","dateModified":"2022-03-21T11:53:07+00:00","author":{"@id":"https:\/\/www.modelical.com\/en\/#\/schema\/person\/3ad52fd99e6b5b98a59ef24c76a7c2d5"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.modelical.com\/en\/pack-rhino-objects-one-block-per-layer-scripting\/#primaryimage","url":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/03\/Rhinoceros-400x250-1.jpg","contentUrl":"https:\/\/www.modelical.com\/wp-content\/uploads\/2014\/03\/Rhinoceros-400x250-1.jpg","width":400,"height":250},{"@type":"WebSite","@id":"https:\/\/www.modelical.com\/en\/#website","url":"https:\/\/www.modelical.com\/en\/","name":"Modelical","description":"We build information","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.modelical.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.modelical.com\/en\/#\/schema\/person\/3ad52fd99e6b5b98a59ef24c76a7c2d5","name":"Roberto Molinos","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro","url":"https:\/\/secure.gravatar.com\/avatar\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9346c12c96cb942be9bb8b2454e296662a1baa0b4cd461ab315ae9a5185b0db6?s=96&d=initials&r=g&initials=ro","caption":"Roberto Molinos"},"sameAs":["https:\/\/www.modelical.com"],"url":"https:\/\/www.modelical.com\/en\/author\/roberto\/"}]}},"_links":{"self":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/posts\/2055","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/users\/64"}],"replies":[{"embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/comments?post=2055"}],"version-history":[{"count":0,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/posts\/2055\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/media\/27193"}],"wp:attachment":[{"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/media?parent=2055"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/categories?post=2055"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modelical.com\/en\/wp-json\/wp\/v2\/tags?post=2055"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}