0 1 1 634259627525260000 0 8 2 true true 372a1d3c-85b7-4f5f-875e-8b4fdecf8346 150;150;0;0 150;0;150;0 Shaded bakeMostAttributes-802.ghx 633789623711874000 0 35 5 0.8 0 23 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel New 0.8 bake A panel for custom notes and String values 480e2b77-183d-41c6-bff1-16ed1479ba1c false true true 0 Version 2010 November 21 for GH 0.8.002 First toggle: bake. Don't forget to set it back to "False" when done. CAUTION with second toggle: it deletes all materials and erases the undo and redo history. The script tries not to add redundant materials, as only one name is given to each color combination. The document, though, can end up with a very long list of materials when we want to use many color variations: for example with gradients. This small component is given to fix this issue. Save, close Rhino and reopen the document after this command to be sure that it will work. true true true 0 0 false 255;0;0;0 255;255;255;255 19 19 311 131 19 19 311 131 19.25 19.5 false Courier New 8 false false ad483f40-dc72-40dc-844d-c9e462c7d19f Boolean Toggle false Boolean Toggle Delete materials Boolean (true/false) toggle 0dbb19f0-70b9-469e-9d98-88ecaec4f0d5 false true true 0 28 201 132 20 28 201 132 20 28 201.495 false 88c3f2b5-27f7-48a2-9528-1397fad62b93 DotNET C# Script (LEGACY) //Written by Giulio Piacentino //Version 2009 05 29 if(activate){ Print("After this component is activated, you need to save, close and reopen the document."); doc.m_material_table.SetCurrentMaterialIndex(-1); for(int i = (doc.m_material_table.MaterialCount() - 1); i > -1; i--){ if( doc.m_material_table.DeleteMaterial(i) ){ Print("Material at position " + i + " is deleted."); } else { Print("Material at position " + i + " is NOT deleted."); } } doc.ClearUndoRecords(); doc.ClearRedoRecords(); } else { Print("Inactive."); } 0 DotNET C# Script (LEGACY) DeleteAllMaterials A C#.NET scriptable component 964ab652-e1d9-4887-a02e-905a2511c689 true true true longest_list 115 -301 101 44 165 -299 24 40 177 -279 false 1 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable x Script Variable x true true 2 3ede854e-c753-40eb-84cb-b48008f14fd4 Output Print, Reflect and Error streams true false 8ec86459-bf01-4409-baee-174d0d2b13d0 Result A Output parameter A true false Variable x activate Script Variable x 6101bd0a-31ac-4f92-aaec-537e0923a12d true true true 1 4a92d040-2026-4396-9469-d1f59ef2c84e d60527f5-b5af-4ef6-8970-5f96fe412559 true false 117 -299 45 40 117 -299 45 40 141 -279 false Output out Print, Reflect and Error streams 68207113-a4d1-4014-8128-ca9e14ddccfb false true true 0 192 -299 22 20 192 -299 22 20 204.5 -289 false Result A A Output parameter A 7783b1ef-565e-44af-b61f-bff32f0eb281 true true true 0 192 -279 22 20 192 -279 22 20 204.5 -269 false 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values 400c4da9-fad7-4c85-9e43-1db34f296ccc false true true 1 68207113-a4d1-4014-8128-ca9e14ddccfb Double click to edit panel content… true true true 1 0 false 255;0;0;0 255;255;250;90 309 -379 256 200 309 -379 256 200 309 -379 false f19b8c33-dff2-4cc2-b95b-b4005ff3c10c Receiver true 1 Receiver Receiver A data receiver object. 4a92d040-2026-4396-9469-d1f59ef2c84e false true true 1 0dbb19f0-70b9-469e-9d98-88ecaec4f0d5 18 -291 50 24 18 -291 50 24 43.32018 -278.8672 false 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values 37b92760-de63-42d4-b310-820d57cae4be false true true 0 gradient object true true true 0 0 false 255;0;0;0 255;189;255;112 563 249 110 20 563 249 110 20 563.7087 249.7125 false Microsoft Sans Serif 10 false false e64c5fb1-845c-4ab1-8911-5f338516ba67 Series Series Series Create a series of numbers. 1f6e28d1-d19c-40f8-a899-a8383a0d79d4 true true true longest_list 406 373 63 64 426 375 24 60 438 405 false Start S First number in the series 96fc239f-6892-4703-ba93-3657d034c7ed false true true 0 1 408 375 15 20 408 375 15 20 417 385 false 1 Step N Step size for each successive number 91dfd763-ba60-4832-a47e-ec59045bb69a false true true 0 1 408 395 15 20 408 395 15 20 417 405 false 1 Count C Number of values in the series 0741c42f-0fb9-4850-914a-7f8e8093e6ac false true true 1 ab05a439-a34a-4409-a2d8-9aae73e100a8 1 408 415 15 20 408 415 15 20 417 425 false 10 Series S Series of numbers 58683c9f-973c-4136-8f4e-3e2e0aa1cc70 false true true 0 453 375 14 60 453 375 14 60 461.5 405 false 1817fd29-20ae-4503-b542-f0fb651e67d7 List Length List Length Lng Measure the length of a list. ca12d769-fa03-4965-8982-55bc4999880a true true true longest_list 303 333 67 28 328 335 24 24 340 347 false List list Base list bf2f7342-a819-4b17-9671-ad2a2be61bb3 true true true 1 1 6b037d4a-4ec0-4585-87de-e6002f4c29bc 305 335 20 24 305 335 20 24 316.5 347 false Length L Number of items in L ab05a439-a34a-4409-a2d8-9aae73e100a8 false true true 0 355 335 13 24 355 335 13 24 363 347 false ac2bc2cb-70fb-4dd5-9c78-7e1ea97fe278 Geometry Geometry Geo Represents a collection of 3D Geometry 6b037d4a-4ec0-4585-87de-e6002f4c29bc false true true 3 b8854c23-f557-41dd-aa32-1ecc29ad7dc9 4a78f261-47ec-45e5-abd9-8201e1d605c6 4dcf2785-f37c-4f70-a504-272ab0cf45e5 192 311 50 24 192 311 50 24 217.0938 323.9328 false 8529dbdf-9b6f-42e9-8e1f-c7a2bde56a70 Line Line Line Represents a collection of 3D Lines 4a78f261-47ec-45e5-abd9-8201e1d605c6 false true true 0 1 58 313 50 24 58 313 50 24 83.00008 325.6328 false 43.3476447770212 13.9920282104037 0 44.549964017751 1.90362028406286 0 6da9f120-3ad0-4b6e-9fe0-f8cde3a649b7 Gradient Gradient Gradient Represents a multiple colour gradient 13364512-6ec8-4ce9-91ec-8f33dcf9b3cc true true true longest_list false false 3 false 0 255;255;255;255 255;255;255;255 false 0.30710894688610785 255;255;0;115 255;255;0;115 false 1 255;123;0;55 255;123;0;55 563 366 250 64 590 371 211 54 563.5699 366.3352 false Lower limit L0 Lower limit of gradient range 9208ab97-7850-4c24-a70c-1c12618cf242 false true true 0 1 565 368 25 20 565 368 25 20 422.6324 552.9727 false 1 Upper limit L1 Upper limit of gradient range 61347300-cf99-43a7-8516-767076941c1b false true true 1 ab05a439-a34a-4409-a2d8-9aae73e100a8 1 565 388 25 20 565 388 25 20 422.6324 572.9727 false 1 Parameter t Parameter along gradient range 44972c2a-6f3d-4fca-beba-37eee8e67ac8 false true true 1 58683c9f-973c-4136-8f4e-3e2e0aa1cc70 3 565 408 25 20 565 408 25 20 422.6324 592.9727 false 0 0.5 1 Colour C Colour along gradient at parameter 429e49e4-9cde-4a6b-a83e-008565729a91 false true true 0 813 368 0 60 813 368 0 60 670.6324 552.9727 false c9482db6-bea9-448d-98ff-fed6d69a8efc Box Box Box Represents a collection of oriented Boxes b8854c23-f557-41dd-aa32-1ecc29ad7dc9 false true true 0 12 58 284 50 24 58 284 50 24 83.00008 296.1328 false 00000000-0000-0000-0000-000000000000 -24.1495289022378 -0.505896093519306 0 0 1 0 1 0 0 0 9.68642156522501 0 4.4029188932841 -5 0 00000000-0000-0000-0000-000000000000 -16.0481581385951 -4.20434796387794 0 1 0 0 0 1 0 0 4.93126916047819 0 9.68642156522501 0 5 00000000-0000-0000-0000-000000000000 -8.1229041306837 2.48808875391388 0 0 1 0 1 0 0 0 7.22078698498592 0 1.40893404585091 -7.22078698498592 0 00000000-0000-0000-0000-000000000000 -3.36775172593688 -6.66998254411704 0 1 0 0 0 1 0 0 3.52233511462728 0 9.86253832095638 0 5 00000000-0000-0000-0000-000000000000 3.14856823612358 1.60750497525706 0 1 0 0 0 1 0 0 3.69845187035864 0 7.39690374071728 0 5 00000000-0000-0000-0000-000000000000 9.13653793098995 6.53877413573525 0 0 1 0 1 0 0 0 8.10137076364273 0 2.99398484743318 -8.10137076364273 0 00000000-0000-0000-0000-000000000000 11.073822244035 -5.96551552119158 0 1 0 0 0 1 0 0 3.17010160316455 0 7.22078698498591 0 5 00000000-0000-0000-0000-000000000000 16.3573249159759 -1.73871338363885 0 1 0 0 0 1 0 0 3.52233511462727 0 10.9192388553446 0 5 00000000-0000-0000-0000-000000000000 22.697528122305 5.65819035707843 0 1 0 0 0 1 0 0 1.937284313045 0 6.3402032063291 0 6.3402032063291 00000000-0000-0000-0000-000000000000 23.2258783894991 -5.08493174253477 0 1 0 0 0 1 0 0 5.45961942767228 0 7.39690374071728 0 7.39690374071728 00000000-0000-0000-0000-000000000000 29.0377313286341 5.3059568456157 0 1 0 0 0 1 0 0 2.81786809170183 0 8.80583778656819 0 5 00000000-0000-0000-0000-000000000000 35.4713624936235 -5.51680778797399 0 1 0 0 0 1 0 0 4.90654240606542 0 11.3389813340449 0 5 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values c8382881-e5fc-4bb5-9499-6cef63b2fbc0 false true true 0 gradient layer true true true 1 0 false 255;0;0;0 255;255;250;255 679 330 134 20 679 330 134 20 679.8375 330.8625 false Courier New 9 false false 01cbd6e3-ccbe-4c24-baeb-46e10553e18b Concatenate Concatenate Concat Concatenate two Strings 4bb9f28d-14d0-4e68-8b00-2734e69d920a true true true longest_list 750 246 63 44 769 248 24 40 781 268 false Start A String to append to. e76b6485-18de-4d23-9208-448c6932f981 false true true 1 37b92760-de63-42d4-b310-820d57cae4be 752 248 14 20 752 248 14 20 760.5 258 false End B String to append. 8e851684-b918-4789-bf21-2077fca2cedd false true true 1 6edcf417-e244-4a12-ac6b-f493c48ca2a5 752 268 14 20 752 268 14 20 760.5 278 false Result R Resulting string consisting of A+B b6bc1da5-3e90-409e-85b5-995ca09aff55 false true true 0 796 248 15 40 796 248 15 40 805 268 false 2e3ab970-8545-46bb-836c-1c11e5610bce Integer Integer Int Represents a collection of Integer numbers 6edcf417-e244-4a12-ac6b-f493c48ca2a5 false true true 1 58683c9f-973c-4136-8f4e-3e2e0aa1cc70 563 279 50 24 563 279 50 24 588.2501 291.7 false f5e3456b-dcfc-4faa-ac4e-7804cb75ee6d C# Script //Inserts geometry into the Rhino document, with custom attributes //Written by Giulio Piacentino //Version written 2010 11 21 - for Grasshopper 0.8.002 if (activate) { if(obj == null) { Print("No object to bake"); return; } //Make new attribute to set name Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes(); //Set object name if(!string.IsNullOrEmpty(name)) { att.Name = name; } //Set color if(!color.IsEmpty) { att.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject; //Make the color type "by object" att.ObjectColor = color; att.PlotColorSource = Rhino.DocObjects.ObjectPlotColorSource.PlotColorFromObject; //Make the plot color type "by object" att.PlotColor = color; } //Set layer if(!string.IsNullOrEmpty(layer) && Rhino.DocObjects.Layer.IsValidName(layer)) { //Get the current layer index Rhino.DocObjects.Tables.LayerTable layerTable = doc.Layers; int layerIndex = layerTable.Find(layer, true); if(layerIndex < 0) //This layer does not exist, we add it { Rhino.DocObjects.Layer onlayer = new Rhino.DocObjects.Layer(); //Make a new layer onlayer.Name = layer; layerIndex = layerTable.Add(onlayer); //Add the layer to the layer table if (layerIndex > -1) //We manged to add layer! { att.LayerIndex = layerIndex; Print("Added new layer to the document at position " + layerIndex + " named " + layer + ". "); } else Print("Layer did not add. Try cleaning up your layers."); //This never happened to me. } else att.LayerIndex = layerIndex; //We simply add to the existing layer } //Set plotweight if(pWidth > 0) { att.PlotWeightSource = Rhino.DocObjects.ObjectPlotWeightSource.PlotWeightFromObject; att.PlotWeight = pWidth; } //Set material bool materialByName = !string.IsNullOrEmpty(material as string); Rhino.Display.DisplayMaterial inMaterial = material as Rhino.Display.DisplayMaterial; if(material is Color) { inMaterial = new Rhino.Display.DisplayMaterial((Color) material); } if(material != null && inMaterial == null && !materialByName) { if(!(material is string)) { try //We also resort to try with IConvertible { inMaterial = (Rhino.Display.DisplayMaterial) Convert.ChangeType(material, typeof(Rhino.Display.DisplayMaterial)); } catch(InvalidCastException) { } } } if(inMaterial != null || materialByName) { string matName; if(!materialByName) { matName = string.Format("A:{0}-D:{1}-E:{2}-S:{3},{4}-T:{5}", Format(inMaterial.Ambient), Format(inMaterial.Diffuse), Format(inMaterial.Emission), Format(inMaterial.Specular), inMaterial.Shine.ToString(), inMaterial.Transparency.ToString() ); } else { matName = (string) material; } int materialIndex = doc.Materials.Find(matName, true); if(materialIndex < 0 && !materialByName) //Material does not exist and we have its specs { materialIndex = doc.Materials.AddMaterial(); //Let's add it if(materialIndex > -1) { Print("Added new material at position " + materialIndex + " named \"" + matName + "\". "); Rhino.DocObjects.Material m = doc.Materials[materialIndex]; m.Name = matName; m.AmbientColor = inMaterial.Ambient; m.DiffuseColor = inMaterial.Diffuse; m.EmissionColor = inMaterial.Emission; //m.ReflectionColor = no equivalent m.SpecularColor = inMaterial.Specular; m.Shine = inMaterial.Shine; m.Transparency = inMaterial.Transparency; //m.TransparentColor = no equivalent m.CommitChanges(); att.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject; att.MaterialIndex = materialIndex; } else Print("Material did not add. Try cleaning up your materials."); //This never happened to me. } else if(materialIndex < 0 && materialByName) //Material does not exist and we do not have its specs. We do nothing { Print("Warning: material name not found. I cannot set the source to this material name. Add a material with name: " + matName); } else { //If this material exists, we do not replace it! att.MaterialSource = Rhino.DocObjects.ObjectMaterialSource.MaterialFromObject; att.MaterialIndex = materialIndex; } } //Set wire density if(wires == -1 || wires > 0) { att.WireDensity = wires; } //Bake to the right type of object switch(obj.ObjectType) { case Rhino.DocObjects.ObjectType.Brep: doc.Objects.AddBrep(obj as Brep, att); break; case Rhino.DocObjects.ObjectType.Curve: doc.Objects.AddCurve(obj as Curve, att); break; case Rhino.DocObjects.ObjectType.Point: doc.Objects.AddPoint((obj as Rhino.Geometry.Point).Location, att); break; case Rhino.DocObjects.ObjectType.Surface: doc.Objects.AddSurface(obj as Surface, att); break; case Rhino.DocObjects.ObjectType.Mesh: doc.Objects.AddMesh(obj as Mesh, att); break; case Rhino.DocObjects.ObjectType.Extrusion: typeof(Rhino.DocObjects.Tables.ObjectTable).InvokeMember("AddExtrusion", BindingFlags.Instance | BindingFlags.InvokeMethod, null, doc.Objects, new object[]{obj, att}); break; case Rhino.DocObjects.ObjectType.PointSet: doc.Objects.AddPointCloud(obj as Rhino.Geometry.PointCloud, att); //This is a speculative entry break; default: Print("The script does not know how to handle this type of geometry: " + obj.GetType().FullName); break; } Print("Added " + obj.GetType().Name); } else { Print("Inactive"); } static string Format(Color c) { return (new System.Text.StringBuilder("A")).Append(c.A.ToString()).Append("R").Append(c.R.ToString()).Append("G") .Append(c.G.ToString()).Append("B").Append(c.B.ToString()).ToString(); } 0 C# Script bakeAttributes A C#.NET scriptable component cf62cc99-e5b8-4129-9b14-deed1e9614a7 1 true true true longest_list 894 290 102 164 945 292 24 160 957 372 false 8 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable obj Script Variable obj true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable name Script Variable name true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable layer Script Variable layer true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable color Script Variable color true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable pWidth Script Variable pWidth true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable wires Script Variable wires true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable material Script Variable material true true 84fa917c-1ed8-4db3-8be1-7bdc4a6495a2 Variable activate Script Variable activate true true 1 3ede854e-c753-40eb-84cb-b48008f14fd4 Output Print, Reflect and Error streams true false Variable obj obj Script Variable obj 4f64a878-7261-4721-89ed-b0daa6051f9d true true true 1 6b037d4a-4ec0-4585-87de-e6002f4c29bc c37956f4-d39c-49c7-af71-1e87f8031b26 true true 896 292 46 20 896 292 46 20 920.5 302 false Variable name name Script Variable name b977804f-590a-455c-8ce6-c826f9be81da true true true 1 b6bc1da5-3e90-409e-85b5-995ca09aff55 9e93878a-f9c5-4f0a-8a70-584bf09f24bb true true 896 312 46 20 896 312 46 20 920.5 322 false Variable layer layer Script Variable layer 91e04191-62f1-43a2-ab69-8b94ed71d28c true true true 1 c8382881-e5fc-4bb5-9499-6cef63b2fbc0 9e93878a-f9c5-4f0a-8a70-584bf09f24bb true true 896 332 46 20 896 332 46 20 920.5 342 false Variable color color Script Variable color 38838974-c00b-42d2-adae-b19c8035fc1f true true true 1 429e49e4-9cde-4a6b-a83e-008565729a91 24b1d1a3-ab79-498c-9e44-c5b14607c4d3 true true 896 352 46 20 896 352 46 20 920.5 362 false Variable pWidth pWidth Script Variable pWidth 4af72111-5565-4141-bc9a-44509a78c9a4 true true true 0 19ff81a2-dc4f-4035-8de9-26224c561321 true true 896 372 46 20 896 372 46 20 920.5 382 false Variable wires wires Script Variable wires 0b772834-386d-4b26-abf5-292a1b9af044 true true true 0 48d01794-d3d8-4aef-990e-127168822244 true true 896 392 46 20 896 392 46 20 920.5 402 false Variable material material Script Variable material 9365412a-e015-4002-be8e-c985da9c8618 true true true 1 429e49e4-9cde-4a6b-a83e-008565729a91 6a184b65-baa3-42d1-a548-3915b401de53 true true 896 412 46 20 896 412 46 20 920.5 422 false Variable activate activate Script Variable activate 2b36dd0e-1f97-4e53-a375-c5f4ed312c9d true true true 2 1 7be45aab-5384-45c0-9bce-6518bfe1e82a d60527f5-b5af-4ef6-8970-5f96fe412559 true true 896 432 46 20 896 432 46 20 920.5 442 false Output out Print, Reflect and Error streams 50e82d56-7bc8-483f-aa59-64d14873a988 false true true 0 972 292 22 160 972 292 22 160 984.5 372 false 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values b9ab10dd-7daa-4b14-a3c3-f08891621dac false true true 1 50e82d56-7bc8-483f-aa59-64d14873a988 Double click to edit panel content… true true true 1 0 false 255;0;0;0 255;255;250;255 1015 253 218 234 1015 253 218 234 1015.364 253.2125 false fbac3e32-f100-4292-8692-77240a42fd1a Point Point Pt Represents a collection of 3D Points 4dcf2785-f37c-4f70-a504-272ab0cf45e5 false true true 0 1 59 343 50 24 59 343 50 24 84 355 false 45.8896259730429 -2.89407233367265 0 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values ac934f9d-df0a-4faa-9dbf-4384bec1bd8e false true true 0 true true true 1 0 false 255;0;0;0 116;255;250;255 25 199 143 27 25 199 143 27 25.25 199.4219 false 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values f5e78ffa-cffa-4d4f-ba01-91551e1a9042 false true true 0 true true true 1 0 false 255;0;0;0 75;255;250;255 24 164 165 31 24 164 165 31 24 164.5 false ad483f40-dc72-40dc-844d-c9e462c7d19f Boolean Toggle false Boolean Toggle BAKE with attributes Boolean (true/false) toggle 7be45aab-5384-45c0-9bce-6518bfe1e82a false true true 0 27 169 153 20 27 169 153 20 27 169.5125 false 2844fec5-142d-4381-bd5d-4cbcef6d6fed Sketch Sketch Sketch A series of doodles fcea394e-0861-43c8-851e-1c09db434a44 2 832 431 42.5 43.75 832 431 42.5 43.75 832 431 false 3 255;0;0;0 0 7 874.5 433.5 870.75 433.5 864.5 436 862 439.75 850.75 448.5 838.25 469.75 832 474.75 5 859.5 431 864.5 431 870.75 432.25 872 436 872 441 59e0b89a-e487-49f8-bab8-b5bab16be14c Panel Panel A panel for custom notes and String values 07a741e5-731d-43c2-b17f-8f2b2a9a7a0d false true true 0 Materials can be strings (text), colors or gh materials. - string: searches the document for a material with that name. Be sure the name is spelled the same! - color: a new material with diffuse to that color - material: a new material with all properties set true true true 0 0 false 255;0;0;0 255;255;250;255 516 481 308 133 516 481 308 133 516 481.9836 false