-
0
1
1
- 634326905881931610
-
0
8
4
- true
- true
- 8e4f0b03-ef7e-4ef6-8e44-95d0538a3976
-
100;150;0;0
-
100;0;120;0
- Shaded
- Master Baker.ghx
- 634326905209013122
- 0
-
-304
-357
- 0.1677722
- 0
- 78
- c552a431-af5b-46a9-a8a4-0fcbc27ef596
- Group
-
150;255;0;0
- 5
- 2
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- b0948cde-6be5-4dd8-894e-ecb6b141b18d
- Group
- A group of Grasshopper objects
- b5b715f2-34a6-43e8-a1fa-7d3fae0ebccf
- c552a431-af5b-46a9-a8a4-0fcbc27ef596
- Group
-
150;170;135;255
- 1
- 14
- 50f99541-e3db-4599-9c85-1155736900b3
- 66acd7b6-21fd-44de-aaea-c5b39a0cd31f
- d84f23f4-b287-449b-97e7-7e580d118115
- 7486b30f-56fa-43e4-8001-e223011ede11
- 56b648c4-176f-4392-b134-d49f8ad3ea55
- 0f5e119c-78f1-4f8f-8ae8-e6f0a309f9d0
- 987406d4-6499-484f-a1f9-05a2311b2fab
- 5c6c367b-468e-4081-8a32-aaa3832b3676
- 83d30e8f-aa7b-4883-94bc-d254fc1a7676
- 315b8cf7-4a5a-40d9-9216-bef6c2268bb0
- b8e4582f-b1e0-47cf-963c-dac2f9f7b626
- 424f40d5-b9e6-4c08-83d5-7390264580f8
- b68800ec-8698-4212-9aa2-a974c87e3b82
- 41173647-3808-49db-8e6e-cd700aa06091
- Group
- A group of Grasshopper objects
- c41aeabe-82ba-4f1d-8691-1417e4d91153
- c552a431-af5b-46a9-a8a4-0fcbc27ef596
- Group
-
150;170;135;255
- 1
- 43
- 620e5a58-cb8e-4f74-9287-c0493a0d8eab
- c27d2ede-09e8-40c5-abff-bdd2f6445b01
- bd50fcc0-29bb-43c6-93a9-e4de2650af8e
- 473f3e05-7536-4f46-b74f-f832f872c15e
- e05b036f-7d25-4d01-9570-c19a96a404dd
- 928af6a5-d99b-4d6c-ada5-e5dceb3d7bdc
- 720353f6-28e7-4e7d-94f4-8d0f35a98eb8
- de872491-34df-4509-9eb7-e7fb986e676d
- 68391333-7a60-40e7-b6b7-bd5289e268ec
- 2f6abb4f-7f17-4ad5-823f-493262be727b
- 4d31e383-578b-4819-8a66-df96d72ac028
- 9d982286-ecc7-4e2e-b7c0-73f4956cca24
- 9b59c60c-0437-4b92-bc81-74c77bd29825
- 7a8743af-7703-4353-89b5-5d4960a25726
- fd9da6b4-4454-41a3-a85e-4773b6ba66ac
- 79dc8fff-fdb4-4b70-8862-222d0d606c2e
- a149e729-d7ac-4229-bdaf-f856bb16e96f
- 59423f8d-e805-47a1-a021-ca3844be5973
- 6cfd3ed6-e0d3-4ca4-8ddc-ed163be81726
- df74d7b6-73a9-4206-8ea4-74ab55b850b2
- f2020fb0-08fe-4615-b4b7-91f75766c09f
- 8f09fdaf-4f8e-4287-9c6b-ce9ce7ea287d
- ef720a92-2b29-488c-85e9-018af860b0e3
- b0dda8a2-d27f-4548-ab8d-7cdd59b42ddc
- 492cb074-3485-4b71-9a41-9be14741ad9e
- f1fa3812-22b9-431f-8363-5637d7d535c6
- 2cc5f34b-bbea-4848-bd37-0c29d7416af4
- 34f449cf-57c3-400c-a275-8f8ec2d94124
- 43c21ab1-0a71-45bd-9c72-b30324a486ae
- c6a31b3f-fb55-4152-883a-3938636e2393
- f3fd6cf3-815f-479a-bf82-2f9106222bcb
- 94ab8ae8-d6dc-4b70-8ce9-e2908382dd0c
- b9bd6f59-4a28-41bf-8783-416a8b29ecf2
- 37ee275a-4e2a-4763-a084-4e4314009f8f
- 9ca281fd-65a8-4b83-a006-cff8c755a8ff
- dd761715-0443-4c6a-88c8-57dea2c6c135
- eebbb032-344f-4736-baef-db0cfa6e4962
- e1993cb5-dffe-404e-b98d-206fe16e8fad
- e1b9ce0a-720c-40a7-918f-5cd8e470a2d1
- b165fb69-2a76-4a63-bfec-9b10c89eb632
- 61ace05f-2965-4c4a-a329-5e079ee8f7a5
- 8ea2aa4b-bd8f-4365-b903-eb1eaf3c5bfa
- a8c49c2d-5339-4f06-89f1-faa3e7f92585
- Group
- A group of Grasshopper objects
- 991f003f-8911-4d7a-acab-75cb3fa82aa6
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 620e5a58-cb8e-4f74-9287-c0493a0d8eab
- false
- true
- true
- 0
- FJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7268
3820
149
20
-
7268
3820
149
20
-
7268.99
3820.212
- false
- Microsoft Sans Serif
- 10
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 50f99541-e3db-4599-9c85-1155736900b3
- false
- true
- true
- 0
- Flower
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4172
242
20
-
6425
4172
242
20
-
6425.146
4172.941
- false
- Courier New
- 9
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- c27d2ede-09e8-40c5-abff-bdd2f6445b01
- true
- true
- true
- longest_list
-
7446
3817
63
60
-
7465
3819
24
56
-
7477
3847
- false
- Start
- A
- String to append to.
- 163e149c-ffe4-4eb0-85b7-54272e639a66
- false
- true
- true
- 1
- 620e5a58-cb8e-4f74-9287-c0493a0d8eab
-
7448
3819
14
28
-
7448
3819
14
28
-
7456.5
3833
- false
- End
- B
- String to append.
- 714f0aa7-6fa2-4f32-9222-33b46b3da7b7
- false
- true
- true
- 0
-
7448
3847
14
28
-
7448
3847
14
28
-
7456.5
3861
- false
- Result
- R
- Resulting string consisting of A+B
- 13468fe6-b8ed-4887-b7e1-4c05f69b5f27
- false
- true
- true
- 0
-
7492
3819
15
56
-
7492
3819
15
56
-
7501
3847
- 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
- bd50fcc0-29bb-43c6-93a9-e4de2650af8e
- 1
- true
- true
- true
- longest_list
-
7590
3776
102
164
-
7641
3778
24
160
-
7653
3858
- 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
- 3c3ba1a1-d115-4622-b597-54f592027152
- true
- true
- true
- 1
- 720353f6-28e7-4e7d-94f4-8d0f35a98eb8
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
3778
46
20
-
7592
3778
46
20
-
7616.5
3788
- false
- Variable name
- name
- Script Variable name
- 5b8b3bc6-0655-4b5f-b482-a8096a047503
- true
- true
- true
- 1
- 13468fe6-b8ed-4887-b7e1-4c05f69b5f27
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
3798
46
20
-
7592
3798
46
20
-
7616.5
3808
- false
- Variable layer
- layer
- Script Variable layer
- 677aee12-024d-44b8-8c92-adfea1e7d349
- true
- true
- true
- 1
- 50f99541-e3db-4599-9c85-1155736900b3
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
3818
46
20
-
7592
3818
46
20
-
7616.5
3828
- false
- Variable color
- color
- Script Variable color
- 49b9b8b7-3d01-4e29-b481-a410be3749e3
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
3838
46
20
-
7592
3838
46
20
-
7616.5
3848
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 89e14059-7771-4de8-8041-8e6491869839
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
3858
46
20
-
7592
3858
46
20
-
7616.5
3868
- false
- Variable wires
- wires
- Script Variable wires
- 464d937d-e547-44aa-9a87-69eb9b13a09d
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
3878
46
20
-
7592
3878
46
20
-
7616.5
3888
- false
- Variable material
- material
- Script Variable material
- 33043ed2-2575-4a3d-9eb2-cc5679c77ef9
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
3898
46
20
-
7592
3898
46
20
-
7616.5
3908
- false
- Variable activate
- activate
- Script Variable activate
- 4af465f0-8ec7-4781-af44-36598a279c0b
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
3918
46
20
-
7592
3918
46
20
-
7616.5
3928
- false
- Output
- out
- Print, Reflect and Error streams
- 9b1045e2-c916-422d-9167-60128318f394
- false
- true
- true
- 0
-
7668
3778
22
160
-
7668
3778
22
160
-
7680.5
3858
- false
- ad483f40-dc72-40dc-844d-c9e462c7d19f
- Boolean Toggle
- false
- Boolean Toggle
- BAKE with attributes
- Boolean (true/false) toggle
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- false
- true
- true
- 0
-
6487
5154
153
20
-
6487
5154
153
20
-
6487.428
5154.23
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 473f3e05-7536-4f46-b74f-f832f872c15e
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7268
4018
149
20
-
7268
4018
149
20
-
7268.989
4018.168
- false
- Microsoft Sans Serif
- 10
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 66acd7b6-21fd-44de-aaea-c5b39a0cd31f
- false
- true
- true
- 0
- Ring
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4231
242
20
-
6425
4231
242
20
-
6425.1
4231.056
- false
- Courier New
- 9
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- e05b036f-7d25-4d01-9570-c19a96a404dd
- true
- true
- true
- longest_list
-
7446
4014
63
60
-
7465
4016
24
56
-
7477
4044
- false
- Start
- A
- String to append to.
- 20c97ee8-16a0-4ff1-abb9-98356d548590
- false
- true
- true
- 1
- 473f3e05-7536-4f46-b74f-f832f872c15e
-
7448
4016
14
28
-
7448
4016
14
28
-
7456.5
4030
- false
- End
- B
- String to append.
- b99907de-21bb-4068-b137-afc19eb16eb2
- false
- true
- true
- 0
-
7448
4044
14
28
-
7448
4044
14
28
-
7456.5
4058
- false
- Result
- R
- Resulting string consisting of A+B
- 5c1ecbb3-efd8-4819-98e7-02f17a967fcc
- false
- true
- true
- 0
-
7492
4016
15
56
-
7492
4016
15
56
-
7501
4044
- 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
- 928af6a5-d99b-4d6c-ada5-e5dceb3d7bdc
- 1
- true
- true
- true
- longest_list
-
7590
3973
102
164
-
7641
3975
24
160
-
7653
4055
- 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
- 6fb695d9-82ac-4540-b512-af90dbe3ec0a
- true
- true
- true
- 1
- 79826c56-f326-42e1-a2c6-4137d7fded6d
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
3975
46
20
-
7592
3975
46
20
-
7616.5
3985
- false
- Variable name
- name
- Script Variable name
- 0833f98a-cbf0-4eda-adc6-4898f85c7a88
- true
- true
- true
- 1
- 5c1ecbb3-efd8-4819-98e7-02f17a967fcc
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
3995
46
20
-
7592
3995
46
20
-
7616.5
4005
- false
- Variable layer
- layer
- Script Variable layer
- 34e8c6e7-1c37-44ca-823b-32b0f07feede
- true
- true
- true
- 1
- 66acd7b6-21fd-44de-aaea-c5b39a0cd31f
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
4015
46
20
-
7592
4015
46
20
-
7616.5
4025
- false
- Variable color
- color
- Script Variable color
- a17baf27-296d-4881-be2e-5232f5bf3a51
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
4035
46
20
-
7592
4035
46
20
-
7616.5
4045
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 192aee3e-a134-49e1-9547-0733453dfb0c
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
4055
46
20
-
7592
4055
46
20
-
7616.5
4065
- false
- Variable wires
- wires
- Script Variable wires
- 7930da59-4269-4645-af31-43ebff2f8db8
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
4075
46
20
-
7592
4075
46
20
-
7616.5
4085
- false
- Variable material
- material
- Script Variable material
- e93de804-7000-45d4-a253-596a350e7bf9
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
4095
46
20
-
7592
4095
46
20
-
7616.5
4105
- false
- Variable activate
- activate
- Script Variable activate
- 179cd346-f82d-4f77-bb3d-85bad7c3cb5e
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
4115
46
20
-
7592
4115
46
20
-
7616.5
4125
- false
- Output
- out
- Print, Reflect and Error streams
- d0d2bfd2-b387-4620-82ea-5266d884f60b
- false
- true
- true
- 0
-
7668
3975
22
160
-
7668
3975
22
160
-
7680.5
4055
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Flower Brep
- Represents a collection of generic data
- 720353f6-28e7-4e7d-94f4-8d0f35a98eb8
- false
- true
- true
- 2
- 0
-
7428
3778
77
20
-
7428
3778
77
20
-
7467.349
3788.039
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- d84f23f4-b287-449b-97e7-7e580d118115
- false
- true
- true
- 0
- TubeSolids
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4289
242
20
-
6425
4289
242
20
-
6425.553
4289.099
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 7486b30f-56fa-43e4-8001-e223011ede11
- false
- true
- true
- 0
- TubeCenterlines
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4348
242
20
-
6425
4348
242
20
-
6425.553
4348.329
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 56b648c4-176f-4392-b134-d49f8ad3ea55
- false
- true
- true
- 0
- MoireSolids
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4406
242
20
-
6425
4406
242
20
-
6425.303
4406.31
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 0f5e119c-78f1-4f8f-8ae8-e6f0a309f9d0
- false
- true
- true
- 0
- MoireCenterlines
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4464
242
20
-
6425
4464
242
20
-
6425.553
4464.79
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 987406d4-6499-484f-a1f9-05a2311b2fab
- false
- true
- true
- 0
- RibSolids
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4523
242
20
-
6425
4523
242
20
-
6425.303
4523.771
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 5c6c367b-468e-4081-8a32-aaa3832b3676
- false
- true
- true
- 0
- RibCenterlines
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4582
242
20
-
6425
4582
242
20
-
6425.303
4582.251
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 83d30e8f-aa7b-4883-94bc-d254fc1a7676
- false
- true
- true
- 0
- NodeLBL
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4640
242
20
-
6425
4640
242
20
-
6425.553
4640.231
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 315b8cf7-4a5a-40d9-9216-bef6c2268bb0
- false
- true
- true
- 0
- RibLBL
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4699
242
20
-
6425
4699
242
20
-
6425.053
4699.212
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- b8e4582f-b1e0-47cf-963c-dac2f9f7b626
- false
- true
- true
- 0
- MoireLBL
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4757
242
20
-
6425
4757
242
20
-
6425.053
4757.192
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 424f40d5-b9e6-4c08-83d5-7390264580f8
- false
- true
- true
- 0
- TubeLBL
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4815
242
20
-
6425
4815
242
20
-
6425.303
4815.923
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- b68800ec-8698-4212-9aa2-a974c87e3b82
- false
- true
- true
- 0
- FlowerLBL
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4874
242
20
-
6425
4874
242
20
-
6425.553
4874.403
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 41173647-3808-49db-8e6e-cd700aa06091
- false
- true
- true
- 0
- RingLBL
- true
- true
- true
- 1
- 0
- false
-
255;0;0;0
-
255;255;250;255
-
6425
4932
242
20
-
6425
4932
242
20
-
6425.053
4932.153
- false
- Courier New
- 9
- false
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- de872491-34df-4509-9eb7-e7fb986e676d
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
4808
149
20
-
7269
4808
149
20
-
7269.177
4808.579
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- 68391333-7a60-40e7-b6b7-bd5289e268ec
- true
- true
- true
- longest_list
-
7446
4803
63
60
-
7465
4805
24
56
-
7477
4833
- false
- Start
- A
- String to append to.
- b3cd6ec6-710e-4880-8e14-f479be669624
- false
- true
- true
- 1
- de872491-34df-4509-9eb7-e7fb986e676d
-
7448
4805
14
28
-
7448
4805
14
28
-
7456.5
4819
- false
- End
- B
- String to append.
- a66e765c-3f97-4531-a780-e56f266494ae
- false
- true
- true
- 0
-
7448
4833
14
28
-
7448
4833
14
28
-
7456.5
4847
- false
- Result
- R
- Resulting string consisting of A+B
- 2daa9ecb-68f3-44cd-a892-dc762a96d069
- false
- true
- true
- 0
-
7492
4805
15
56
-
7492
4805
15
56
-
7501
4833
- 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
- 2f6abb4f-7f17-4ad5-823f-493262be727b
- 1
- true
- true
- true
- longest_list
-
7590
4762
102
164
-
7641
4764
24
160
-
7653
4844
- 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
- 836f0987-a32c-4c6d-88a2-397ed4631842
- true
- true
- true
- 1
- 5f6ef152-1722-4e0e-b9ac-239528b7cbb4
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
4764
46
20
-
7592
4764
46
20
-
7616.5
4774
- false
- Variable name
- name
- Script Variable name
- fbd47b82-209c-488b-8d34-5ae3d4132630
- true
- true
- true
- 1
- 2daa9ecb-68f3-44cd-a892-dc762a96d069
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
4784
46
20
-
7592
4784
46
20
-
7616.5
4794
- false
- Variable layer
- layer
- Script Variable layer
- c63738df-13f7-48e1-a184-e84ef2263464
- true
- true
- true
- 1
- 0f5e119c-78f1-4f8f-8ae8-e6f0a309f9d0
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
4804
46
20
-
7592
4804
46
20
-
7616.5
4814
- false
- Variable color
- color
- Script Variable color
- f4556dea-9205-4756-ad70-5599dfb7fede
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
4824
46
20
-
7592
4824
46
20
-
7616.5
4834
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- dfd81b3e-cff4-4e77-9935-7a3537eb5f3c
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
4844
46
20
-
7592
4844
46
20
-
7616.5
4854
- false
- Variable wires
- wires
- Script Variable wires
- ec5fe19b-082a-46a8-b6c8-9f9ee6dcbe14
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
4864
46
20
-
7592
4864
46
20
-
7616.5
4874
- false
- Variable material
- material
- Script Variable material
- 0ca40c5b-1f7f-4019-8b38-dbaee0a7018a
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
4884
46
20
-
7592
4884
46
20
-
7616.5
4894
- false
- Variable activate
- activate
- Script Variable activate
- cedd0b61-687b-4ebe-8eb8-35040cdfd4f5
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
4904
46
20
-
7592
4904
46
20
-
7616.5
4914
- false
- Output
- out
- Print, Reflect and Error streams
- d7d2a868-587c-4b9e-9f32-5fd2de374d5b
- false
- true
- true
- 0
-
7668
4764
22
160
-
7668
4764
22
160
-
7680.5
4844
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 4d31e383-578b-4819-8a66-df96d72ac028
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
4610
149
20
-
7269
4610
149
20
-
7269.989
4610.879
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- 9d982286-ecc7-4e2e-b7c0-73f4956cca24
- true
- true
- true
- longest_list
-
7447
4606
63
60
-
7466
4608
24
56
-
7478
4636
- false
- Start
- A
- String to append to.
- c3bc7c52-6bbb-44be-b94c-54fa04d95e82
- false
- true
- true
- 1
- 4d31e383-578b-4819-8a66-df96d72ac028
-
7449
4608
14
28
-
7449
4608
14
28
-
7457.5
4622
- false
- End
- B
- String to append.
- 106f8b4e-61b7-4abf-9f3a-19635e8c9f40
- false
- true
- true
- 0
-
7449
4636
14
28
-
7449
4636
14
28
-
7457.5
4650
- false
- Result
- R
- Resulting string consisting of A+B
- 9aa323ae-2b39-49e7-8d03-6914949cfa5c
- false
- true
- true
- 0
-
7493
4608
15
56
-
7493
4608
15
56
-
7502
4636
- 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
- 9b59c60c-0437-4b92-bc81-74c77bd29825
- 1
- true
- true
- true
- longest_list
-
7591
4565
102
164
-
7642
4567
24
160
-
7654
4647
- 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
- 3461533d-533b-4890-96cc-74c55bd514bb
- true
- true
- true
- 1
- bd57fc10-b338-4303-b12a-b0940361c111
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7593
4567
46
20
-
7593
4567
46
20
-
7617.5
4577
- false
- Variable name
- name
- Script Variable name
- 7dac2fbb-f5cc-49eb-a713-8c8d1fe453c6
- true
- true
- true
- 1
- 9aa323ae-2b39-49e7-8d03-6914949cfa5c
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
4587
46
20
-
7593
4587
46
20
-
7617.5
4597
- false
- Variable layer
- layer
- Script Variable layer
- 58ae913b-eece-4ab5-9324-f3a2218aab45
- true
- true
- true
- 1
- 56b648c4-176f-4392-b134-d49f8ad3ea55
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
4607
46
20
-
7593
4607
46
20
-
7617.5
4617
- false
- Variable color
- color
- Script Variable color
- 36af9cde-0b39-47f6-9bc8-817b344d73c5
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7593
4627
46
20
-
7593
4627
46
20
-
7617.5
4637
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 6bc11fe1-1047-4ef6-97dd-5421e3213c62
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7593
4647
46
20
-
7593
4647
46
20
-
7617.5
4657
- false
- Variable wires
- wires
- Script Variable wires
- 529fbbc4-ec7d-4ff9-b896-a0b8e36c2572
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7593
4667
46
20
-
7593
4667
46
20
-
7617.5
4677
- false
- Variable material
- material
- Script Variable material
- ad00548b-1779-4863-a72e-1090143e0733
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7593
4687
46
20
-
7593
4687
46
20
-
7617.5
4697
- false
- Variable activate
- activate
- Script Variable activate
- 4eb8ec16-4bb6-4fd1-b035-e09e401b2b16
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7593
4707
46
20
-
7593
4707
46
20
-
7617.5
4717
- false
- Output
- out
- Print, Reflect and Error streams
- e0e3accc-fc2f-437a-8e08-32ddb8efc7df
- false
- true
- true
- 0
-
7669
4567
22
160
-
7669
4567
22
160
-
7681.5
4647
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 7a8743af-7703-4353-89b5-5d4960a25726
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
4413
149
20
-
7269
4413
149
20
-
7269.176
4413.691
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- fd9da6b4-4454-41a3-a85e-4773b6ba66ac
- true
- true
- true
- longest_list
-
7446
4409
63
60
-
7465
4411
24
56
-
7477
4439
- false
- Start
- A
- String to append to.
- a67abcb3-183b-4591-bb1c-f9c84e13634b
- false
- true
- true
- 1
- 7a8743af-7703-4353-89b5-5d4960a25726
-
7448
4411
14
28
-
7448
4411
14
28
-
7456.5
4425
- false
- End
- B
- String to append.
- 4fb5b0af-38b9-41ab-ac66-f5a0ada47e38
- false
- true
- true
- 0
-
7448
4439
14
28
-
7448
4439
14
28
-
7456.5
4453
- false
- Result
- R
- Resulting string consisting of A+B
- 00a2d7a0-f226-4e4c-9161-ae705c3b8b8e
- false
- true
- true
- 0
-
7492
4411
15
56
-
7492
4411
15
56
-
7501
4439
- 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
- 79dc8fff-fdb4-4b70-8862-222d0d606c2e
- 1
- true
- true
- true
- longest_list
-
7590
4368
102
164
-
7641
4370
24
160
-
7653
4450
- 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
- a91f56ed-2bcd-4ef4-b86b-77b5f9ef67b1
- true
- true
- true
- 1
- bc7aeaab-0899-44c1-8281-72c7df7979bb
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
4370
46
20
-
7592
4370
46
20
-
7616.5
4380
- false
- Variable name
- name
- Script Variable name
- bb1f2c20-ce23-4033-a1ea-6867cd4c1a38
- true
- true
- true
- 1
- 00a2d7a0-f226-4e4c-9161-ae705c3b8b8e
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
4390
46
20
-
7592
4390
46
20
-
7616.5
4400
- false
- Variable layer
- layer
- Script Variable layer
- 083ae6cd-2a3f-4d5b-892f-a086eafcabde
- true
- true
- true
- 1
- 7486b30f-56fa-43e4-8001-e223011ede11
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
4410
46
20
-
7592
4410
46
20
-
7616.5
4420
- false
- Variable color
- color
- Script Variable color
- f21da3e8-0549-4975-8a75-30ea62828bf3
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
4430
46
20
-
7592
4430
46
20
-
7616.5
4440
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- d1c5d7ce-46d3-4cac-967d-24d2e69d3f0c
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
4450
46
20
-
7592
4450
46
20
-
7616.5
4460
- false
- Variable wires
- wires
- Script Variable wires
- e4ff7211-74f7-4fa7-9615-36ae9a3ef7ff
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
4470
46
20
-
7592
4470
46
20
-
7616.5
4480
- false
- Variable material
- material
- Script Variable material
- 4e804bf4-2f32-44c4-a3d2-e4675f0a9518
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
4490
46
20
-
7592
4490
46
20
-
7616.5
4500
- false
- Variable activate
- activate
- Script Variable activate
- 5856b41a-e815-4c34-8635-6ba9845e4492
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
4510
46
20
-
7592
4510
46
20
-
7616.5
4520
- false
- Output
- out
- Print, Reflect and Error streams
- 62387f3f-b5da-4e47-acc9-5b2e07965f6a
- false
- true
- true
- 0
-
7668
4370
22
160
-
7668
4370
22
160
-
7680.5
4450
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- a149e729-d7ac-4229-bdaf-f856bb16e96f
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
4215
149
20
-
7269
4215
149
20
-
7269.989
4215.991
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- 59423f8d-e805-47a1-a021-ca3844be5973
- true
- true
- true
- longest_list
-
7447
4211
63
60
-
7466
4213
24
56
-
7478
4241
- false
- Start
- A
- String to append to.
- b8b36587-7e74-4c7b-b002-b75a39e64bd8
- false
- true
- true
- 1
- a149e729-d7ac-4229-bdaf-f856bb16e96f
-
7449
4213
14
28
-
7449
4213
14
28
-
7457.5
4227
- false
- End
- B
- String to append.
- 0d492033-8588-4f71-8ee5-e6d5cbaf143f
- false
- true
- true
- 0
-
7449
4241
14
28
-
7449
4241
14
28
-
7457.5
4255
- false
- Result
- R
- Resulting string consisting of A+B
- b762b54a-b828-45aa-a003-ceacb4974152
- false
- true
- true
- 0
-
7493
4213
15
56
-
7493
4213
15
56
-
7502
4241
- 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
- 6cfd3ed6-e0d3-4ca4-8ddc-ed163be81726
- 1
- true
- true
- true
- longest_list
-
7591
4170
102
164
-
7642
4172
24
160
-
7654
4252
- 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
- 52229e53-34bb-4953-9511-d7e2200ffb30
- true
- true
- true
- 1
- 98e3818a-74f8-46f1-901d-1e6929eb1a02
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7593
4172
46
20
-
7593
4172
46
20
-
7617.5
4182
- false
- Variable name
- name
- Script Variable name
- ef4d1dd5-9f57-43c6-a4a8-c4703d5c7309
- true
- true
- true
- 1
- b762b54a-b828-45aa-a003-ceacb4974152
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
4192
46
20
-
7593
4192
46
20
-
7617.5
4202
- false
- Variable layer
- layer
- Script Variable layer
- 81132024-fcec-4c56-b1ca-f3c682d56b3c
- true
- true
- true
- 1
- d84f23f4-b287-449b-97e7-7e580d118115
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
4212
46
20
-
7593
4212
46
20
-
7617.5
4222
- false
- Variable color
- color
- Script Variable color
- a7f99471-1e5e-4f73-a670-521269816e4a
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7593
4232
46
20
-
7593
4232
46
20
-
7617.5
4242
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 5135ec08-866a-454e-9e72-f3474a01feec
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7593
4252
46
20
-
7593
4252
46
20
-
7617.5
4262
- false
- Variable wires
- wires
- Script Variable wires
- 471ae55b-4404-47cf-b0c8-36b5c98f3627
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7593
4272
46
20
-
7593
4272
46
20
-
7617.5
4282
- false
- Variable material
- material
- Script Variable material
- 7594d439-a4c3-49cc-a723-af6355b9e0bc
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7593
4292
46
20
-
7593
4292
46
20
-
7617.5
4302
- false
- Variable activate
- activate
- Script Variable activate
- 75dfae91-a98b-44f1-a05c-c8274a885029
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7593
4312
46
20
-
7593
4312
46
20
-
7617.5
4322
- false
- Output
- out
- Print, Reflect and Error streams
- a079245f-a89a-4865-8d8f-217a311d02b1
- false
- true
- true
- 0
-
7669
4172
22
160
-
7669
4172
22
160
-
7681.5
4252
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- df74d7b6-73a9-4206-8ea4-74ab55b850b2
- false
- true
- true
- 0
- FJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7268
5006
149
20
-
7268
5006
149
20
-
7268.989
5006.507
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- f2020fb0-08fe-4615-b4b7-91f75766c09f
- true
- true
- true
- longest_list
-
7446
5001
63
60
-
7465
5003
24
56
-
7477
5031
- false
- Start
- A
- String to append to.
- c78e6202-b016-40d9-9294-dd7f9327674b
- false
- true
- true
- 1
- df74d7b6-73a9-4206-8ea4-74ab55b850b2
-
7448
5003
14
28
-
7448
5003
14
28
-
7456.5
5017
- false
- End
- B
- String to append.
- a755f40f-453c-4fbd-9a8b-2a9c35f74c1e
- false
- true
- true
- 0
-
7448
5031
14
28
-
7448
5031
14
28
-
7456.5
5045
- false
- Result
- R
- Resulting string consisting of A+B
- 062c9154-8b16-4848-a9a8-33f3c35097e7
- false
- true
- true
- 0
-
7492
5003
15
56
-
7492
5003
15
56
-
7501
5031
- 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
- 8f09fdaf-4f8e-4287-9c6b-ce9ce7ea287d
- 1
- true
- true
- true
- longest_list
-
7590
4960
102
164
-
7641
4962
24
160
-
7653
5042
- 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
- 9978240b-9474-4e39-a85c-e8b543fe41bb
- true
- true
- true
- 1
- 6f075257-50e0-4886-b1f4-e3c31507b85f
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
4962
46
20
-
7592
4962
46
20
-
7616.5
4972
- false
- Variable name
- name
- Script Variable name
- 4eead81b-e2af-48d7-ac76-f9778508cd24
- true
- true
- true
- 1
- 062c9154-8b16-4848-a9a8-33f3c35097e7
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
4982
46
20
-
7592
4982
46
20
-
7616.5
4992
- false
- Variable layer
- layer
- Script Variable layer
- 7361a1ec-2cdc-44e7-a02e-1c1dc25b8b61
- true
- true
- true
- 1
- 987406d4-6499-484f-a1f9-05a2311b2fab
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5002
46
20
-
7592
5002
46
20
-
7616.5
5012
- false
- Variable color
- color
- Script Variable color
- 09327c2e-c1e0-41fd-8c82-a52c5eb43d97
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
5022
46
20
-
7592
5022
46
20
-
7616.5
5032
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 7634cadc-2e03-4232-9e1a-bfc81e7a9a65
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
5042
46
20
-
7592
5042
46
20
-
7616.5
5052
- false
- Variable wires
- wires
- Script Variable wires
- 62d98dad-9032-4925-b8d8-d430374cb59c
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
5062
46
20
-
7592
5062
46
20
-
7616.5
5072
- false
- Variable material
- material
- Script Variable material
- 373c6d80-1395-4914-a093-f2246940bf94
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
5082
46
20
-
7592
5082
46
20
-
7616.5
5092
- false
- Variable activate
- activate
- Script Variable activate
- fec9ca4e-8c1e-4048-b4f0-f20012ace18e
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
5102
46
20
-
7592
5102
46
20
-
7616.5
5112
- false
- Output
- out
- Print, Reflect and Error streams
- d02e5ef0-b550-4e34-8f86-a5223e5f09b2
- false
- true
- true
- 0
-
7668
4962
22
160
-
7668
4962
22
160
-
7680.5
5042
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- ef720a92-2b29-488c-85e9-018af860b0e3
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7268
5204
149
20
-
7268
5204
149
20
-
7268.989
5204.464
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- b0dda8a2-d27f-4548-ab8d-7cdd59b42ddc
- true
- true
- true
- longest_list
-
7446
5198
63
60
-
7465
5200
24
56
-
7477
5228
- false
- Start
- A
- String to append to.
- 0ebdfde3-4dc8-4b9c-9ed4-cc60c95cd84a
- false
- true
- true
- 1
- ef720a92-2b29-488c-85e9-018af860b0e3
-
7448
5200
14
28
-
7448
5200
14
28
-
7456.5
5214
- false
- End
- B
- String to append.
- e135e728-9f12-4f0d-8395-757b13bd74c5
- false
- true
- true
- 0
-
7448
5228
14
28
-
7448
5228
14
28
-
7456.5
5242
- false
- Result
- R
- Resulting string consisting of A+B
- 15e38ddb-23b4-4c1a-8599-5b9b178d4cf3
- false
- true
- true
- 0
-
7492
5200
15
56
-
7492
5200
15
56
-
7501
5228
- 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
- 492cb074-3485-4b71-9a41-9be14741ad9e
- 1
- true
- true
- true
- longest_list
-
7590
5157
102
164
-
7641
5159
24
160
-
7653
5239
- 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
- 880583e8-2df8-4077-a098-0a203715d04b
- true
- true
- true
- 1
- 67d9470f-4344-4096-b984-d40a16dc5390
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
5159
46
20
-
7592
5159
46
20
-
7616.5
5169
- false
- Variable name
- name
- Script Variable name
- ce52301f-1262-470a-ad32-bf4963794342
- true
- true
- true
- 1
- 15e38ddb-23b4-4c1a-8599-5b9b178d4cf3
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5179
46
20
-
7592
5179
46
20
-
7616.5
5189
- false
- Variable layer
- layer
- Script Variable layer
- 52255f04-9b22-4f07-b6fd-3a040c351b65
- true
- true
- true
- 1
- 5c6c367b-468e-4081-8a32-aaa3832b3676
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5199
46
20
-
7592
5199
46
20
-
7616.5
5209
- false
- Variable color
- color
- Script Variable color
- 5ef03d9f-9269-4048-a212-59ebacc9e550
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
5219
46
20
-
7592
5219
46
20
-
7616.5
5229
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- b5ab48be-d3f3-4ab5-aa8f-9e572e5f3583
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
5239
46
20
-
7592
5239
46
20
-
7616.5
5249
- false
- Variable wires
- wires
- Script Variable wires
- c3b061d6-3277-44c2-8a9d-8cb083459c35
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
5259
46
20
-
7592
5259
46
20
-
7616.5
5269
- false
- Variable material
- material
- Script Variable material
- 80836393-f126-4be4-9d3f-9b4a90503136
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
5279
46
20
-
7592
5279
46
20
-
7616.5
5289
- false
- Variable activate
- activate
- Script Variable activate
- 94f5ac42-3845-469b-8865-053c84946069
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
5299
46
20
-
7592
5299
46
20
-
7616.5
5309
- false
- Output
- out
- Print, Reflect and Error streams
- 8c878fa8-15f6-459e-89fe-0aa84f0ea413
- false
- true
- true
- 0
-
7668
5159
22
160
-
7668
5159
22
160
-
7680.5
5239
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- f1fa3812-22b9-431f-8363-5637d7d535c6
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
5994
149
20
-
7269
5994
149
20
-
7269.176
5994.874
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- 2cc5f34b-bbea-4848-bd37-0c29d7416af4
- true
- true
- true
- longest_list
-
7446
5988
63
60
-
7465
5990
24
56
-
7477
6018
- false
- Start
- A
- String to append to.
- 2fbcc46e-046a-4af8-9290-50d6cefdb0b8
- false
- true
- true
- 1
- f1fa3812-22b9-431f-8363-5637d7d535c6
-
7448
5990
14
28
-
7448
5990
14
28
-
7456.5
6004
- false
- End
- B
- String to append.
- bc2d2559-51b5-494a-8f10-6f70cb037cc5
- false
- true
- true
- 0
-
7448
6018
14
28
-
7448
6018
14
28
-
7456.5
6032
- false
- Result
- R
- Resulting string consisting of A+B
- e7ad86f3-4b54-4a45-8e60-76618e689b14
- false
- true
- true
- 0
-
7492
5990
15
56
-
7492
5990
15
56
-
7501
6018
- 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
- 34f449cf-57c3-400c-a275-8f8ec2d94124
- 1
- true
- true
- true
- longest_list
-
7590
5947
102
164
-
7641
5949
24
160
-
7653
6029
- 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
- 2c07443f-6c62-45a8-945c-b3eed525f753
- true
- true
- true
- 1
- 861fc06e-5dc4-4362-b1bc-39768f0917ea
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
5949
46
20
-
7592
5949
46
20
-
7616.5
5959
- false
- Variable name
- name
- Script Variable name
- 814fe014-8d36-4e01-95f6-b037eabae156
- true
- true
- true
- 1
- e7ad86f3-4b54-4a45-8e60-76618e689b14
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5969
46
20
-
7592
5969
46
20
-
7616.5
5979
- false
- Variable layer
- layer
- Script Variable layer
- f909d649-6eb1-42da-b2df-2381a385560f
- true
- true
- true
- 1
- 424f40d5-b9e6-4c08-83d5-7390264580f8
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5989
46
20
-
7592
5989
46
20
-
7616.5
5999
- false
- Variable color
- color
- Script Variable color
- 54de2e15-cf85-4916-a722-4d9b03b74481
- true
- true
- true
- 1
- ca3739b7-ecac-4d29-ad43-97804c0f3602
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
6009
46
20
-
7592
6009
46
20
-
7616.5
6019
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- ec2d218d-af6b-4891-8ea1-8ef62c39de8e
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
6029
46
20
-
7592
6029
46
20
-
7616.5
6039
- false
- Variable wires
- wires
- Script Variable wires
- 059e90d3-eb9b-46a4-ae99-c44aedd588b3
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
6049
46
20
-
7592
6049
46
20
-
7616.5
6059
- false
- Variable material
- material
- Script Variable material
- 3fcfa4a9-90ce-45e5-8703-6cec5bf8a02f
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
6069
46
20
-
7592
6069
46
20
-
7616.5
6079
- false
- Variable activate
- activate
- Script Variable activate
- cd24ddb6-93bd-4c6e-9bd6-bd6318ed8eba
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
6089
46
20
-
7592
6089
46
20
-
7616.5
6099
- false
- Output
- out
- Print, Reflect and Error streams
- 18092a4c-8d81-4742-b32e-07ad214069a8
- false
- true
- true
- 0
-
7668
5949
22
160
-
7668
5949
22
160
-
7680.5
6029
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 43c21ab1-0a71-45bd-9c72-b30324a486ae
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
5797
149
20
-
7269
5797
149
20
-
7269.989
5797.174
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- c6a31b3f-fb55-4152-883a-3938636e2393
- true
- true
- true
- longest_list
-
7447
5790
63
60
-
7466
5792
24
56
-
7478
5820
- false
- Start
- A
- String to append to.
- 705224f8-ca39-4b0f-8ebe-8a31cf43be68
- false
- true
- true
- 1
- 43c21ab1-0a71-45bd-9c72-b30324a486ae
-
7449
5792
14
28
-
7449
5792
14
28
-
7457.5
5806
- false
- End
- B
- String to append.
- f34f86b8-ca21-4abd-9ad5-6e53d28839dc
- false
- true
- true
- 0
-
7449
5820
14
28
-
7449
5820
14
28
-
7457.5
5834
- false
- Result
- R
- Resulting string consisting of A+B
- 23b934ad-75d3-41b9-b5fd-e738ce57de3f
- false
- true
- true
- 0
-
7493
5792
15
56
-
7493
5792
15
56
-
7502
5820
- 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
- f3fd6cf3-815f-479a-bf82-2f9106222bcb
- 1
- true
- true
- true
- longest_list
-
7591
5749
102
164
-
7642
5751
24
160
-
7654
5831
- 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
- eed74e69-e919-43ef-9472-0ff805fffa17
- true
- true
- true
- 1
- a326c95e-d9d4-4586-a8a2-41ee1ef4e133
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7593
5751
46
20
-
7593
5751
46
20
-
7617.5
5761
- false
- Variable name
- name
- Script Variable name
- 09f1b12c-9871-4bd7-b349-33298db4a7dd
- true
- true
- true
- 1
- 23b934ad-75d3-41b9-b5fd-e738ce57de3f
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
5771
46
20
-
7593
5771
46
20
-
7617.5
5781
- false
- Variable layer
- layer
- Script Variable layer
- 7dc4faa1-02a7-420e-b952-67543bf56aee
- true
- true
- true
- 1
- b8e4582f-b1e0-47cf-963c-dac2f9f7b626
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
5791
46
20
-
7593
5791
46
20
-
7617.5
5801
- false
- Variable color
- color
- Script Variable color
- 4751313f-9af2-4727-9914-7c81d7a6a358
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7593
5811
46
20
-
7593
5811
46
20
-
7617.5
5821
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- fa363d66-e22d-4601-9b23-0804e1f80a60
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7593
5831
46
20
-
7593
5831
46
20
-
7617.5
5841
- false
- Variable wires
- wires
- Script Variable wires
- c7385b0b-b571-4ad8-966f-9f549087b182
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7593
5851
46
20
-
7593
5851
46
20
-
7617.5
5861
- false
- Variable material
- material
- Script Variable material
- c747762b-fd53-4b6b-ae67-7e19e112ce99
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7593
5871
46
20
-
7593
5871
46
20
-
7617.5
5881
- false
- Variable activate
- activate
- Script Variable activate
- 816f0c0f-077b-4117-bd8c-440461b490d3
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7593
5891
46
20
-
7593
5891
46
20
-
7617.5
5901
- false
- Output
- out
- Print, Reflect and Error streams
- a9e4453e-3bd2-45c3-a1cf-a48153fdc3aa
- false
- true
- true
- 0
-
7669
5751
22
160
-
7669
5751
22
160
-
7681.5
5831
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 94ab8ae8-d6dc-4b70-8ce9-e2908382dd0c
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
5598
149
20
-
7269
5598
149
20
-
7269.176
5598.985
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- b9bd6f59-4a28-41bf-8783-416a8b29ecf2
- true
- true
- true
- longest_list
-
7446
5593
63
60
-
7465
5595
24
56
-
7477
5623
- false
- Start
- A
- String to append to.
- 7bb68701-b648-41e4-ac0e-b9971e400f50
- false
- true
- true
- 1
- 94ab8ae8-d6dc-4b70-8ce9-e2908382dd0c
-
7448
5595
14
28
-
7448
5595
14
28
-
7456.5
5609
- false
- End
- B
- String to append.
- b7fd737f-20f4-4813-8284-63543903e20e
- false
- true
- true
- 0
-
7448
5623
14
28
-
7448
5623
14
28
-
7456.5
5637
- false
- Result
- R
- Resulting string consisting of A+B
- bca17bd8-a513-4d00-8de6-b76f6fdd3294
- false
- true
- true
- 0
-
7492
5595
15
56
-
7492
5595
15
56
-
7501
5623
- 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
- 37ee275a-4e2a-4763-a084-4e4314009f8f
- 1
- true
- true
- true
- longest_list
-
7590
5552
102
164
-
7641
5554
24
160
-
7653
5634
- 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
- f6ef22d5-b1d6-4d7b-8282-829bcb418cd0
- true
- true
- true
- 1
- 0056bc97-838a-4715-a29c-1fab435308fd
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
5554
46
20
-
7592
5554
46
20
-
7616.5
5564
- false
- Variable name
- name
- Script Variable name
- 7171f38e-77a6-46b4-9e64-ad938422ee67
- true
- true
- true
- 1
- bca17bd8-a513-4d00-8de6-b76f6fdd3294
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5574
46
20
-
7592
5574
46
20
-
7616.5
5584
- false
- Variable layer
- layer
- Script Variable layer
- 88c4cf54-4e89-4880-93e8-f97ed5908d68
- true
- true
- true
- 1
- 315b8cf7-4a5a-40d9-9216-bef6c2268bb0
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
5594
46
20
-
7592
5594
46
20
-
7616.5
5604
- false
- Variable color
- color
- Script Variable color
- a202ff10-48d2-42f1-87d5-c0b21f54ea33
- true
- true
- true
- 1
- 502518dd-0b85-4619-b735-0a3771664319
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
5614
46
20
-
7592
5614
46
20
-
7616.5
5624
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- d5f985bd-0e81-4166-bd55-bbcbd412b24c
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
5634
46
20
-
7592
5634
46
20
-
7616.5
5644
- false
- Variable wires
- wires
- Script Variable wires
- baa3e9fe-a2fe-41da-a1bc-50e485dc76c1
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
5654
46
20
-
7592
5654
46
20
-
7616.5
5664
- false
- Variable material
- material
- Script Variable material
- 00385891-cd78-42f5-9c82-e33a08d6408e
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
5674
46
20
-
7592
5674
46
20
-
7616.5
5684
- false
- Variable activate
- activate
- Script Variable activate
- 6294c176-f3bb-4438-a0d3-9aac95b1318d
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
5694
46
20
-
7592
5694
46
20
-
7616.5
5704
- false
- Output
- out
- Print, Reflect and Error streams
- 2c15c773-7c3f-439a-b0f3-889cd547dfad
- false
- true
- true
- 0
-
7668
5554
22
160
-
7668
5554
22
160
-
7680.5
5634
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 9ca281fd-65a8-4b83-a006-cff8c755a8ff
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
5401
149
20
-
7269
5401
149
20
-
7269.989
5401.285
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- dd761715-0443-4c6a-88c8-57dea2c6c135
- true
- true
- true
- longest_list
-
7447
5396
63
60
-
7466
5398
24
56
-
7478
5426
- false
- Start
- A
- String to append to.
- f3a955d2-6528-4711-a479-1503e8b31de6
- false
- true
- true
- 1
- 9ca281fd-65a8-4b83-a006-cff8c755a8ff
-
7449
5398
14
28
-
7449
5398
14
28
-
7457.5
5412
- false
- End
- B
- String to append.
- d885f49b-f58d-4d2f-8e0d-e520cc7438d6
- false
- true
- true
- 0
-
7449
5426
14
28
-
7449
5426
14
28
-
7457.5
5440
- false
- Result
- R
- Resulting string consisting of A+B
- 97e435ad-afd0-4bdd-91fc-2248bbf3a4a5
- false
- true
- true
- 0
-
7493
5398
15
56
-
7493
5398
15
56
-
7502
5426
- 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
- eebbb032-344f-4736-baef-db0cfa6e4962
- 1
- true
- true
- true
- longest_list
-
7591
5355
102
164
-
7642
5357
24
160
-
7654
5437
- 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
- 0fc5f8f8-19a6-4a0f-99c8-52ffab20035c
- true
- true
- true
- 1
- f3493ff2-2419-45dd-a7ac-127ee0f0d072
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7593
5357
46
20
-
7593
5357
46
20
-
7617.5
5367
- false
- Variable name
- name
- Script Variable name
- 2b102f49-d658-4abd-825f-c653880d4ceb
- true
- true
- true
- 1
- 97e435ad-afd0-4bdd-91fc-2248bbf3a4a5
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
5377
46
20
-
7593
5377
46
20
-
7617.5
5387
- false
- Variable layer
- layer
- Script Variable layer
- 3d58a8ed-a6ac-49d3-9bd5-66e4f6edd9b3
- true
- true
- true
- 1
- 83d30e8f-aa7b-4883-94bc-d254fc1a7676
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
5397
46
20
-
7593
5397
46
20
-
7617.5
5407
- false
- Variable color
- color
- Script Variable color
- 1588dff0-f9c0-49d6-b8bb-25911e5841cd
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7593
5417
46
20
-
7593
5417
46
20
-
7617.5
5427
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 3f007d75-c576-4976-910b-47225aeefeed
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7593
5437
46
20
-
7593
5437
46
20
-
7617.5
5447
- false
- Variable wires
- wires
- Script Variable wires
- 63018e57-6c5c-4023-a216-24f364f26f1d
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7593
5457
46
20
-
7593
5457
46
20
-
7617.5
5467
- false
- Variable material
- material
- Script Variable material
- 38e8d204-7451-47fa-b5f8-8a84c5ff1716
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7593
5477
46
20
-
7593
5477
46
20
-
7617.5
5487
- false
- Variable activate
- activate
- Script Variable activate
- 40241efc-da09-4a84-a429-f266395267b0
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7593
5497
46
20
-
7593
5497
46
20
-
7617.5
5507
- false
- Output
- out
- Print, Reflect and Error streams
- 80a81ee3-0b50-46b9-81e1-3be6ca09d5fe
- false
- true
- true
- 0
-
7669
5357
22
160
-
7669
5357
22
160
-
7681.5
5437
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- e1993cb5-dffe-404e-b98d-206fe16e8fad
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
6389
149
20
-
7269
6389
149
20
-
7269.176
6389.548
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- e1b9ce0a-720c-40a7-918f-5cd8e470a2d1
- true
- true
- true
- longest_list
-
7446
6383
63
60
-
7465
6385
24
56
-
7477
6413
- false
- Start
- A
- String to append to.
- c9c6ed52-3651-440b-af83-b61ded0255b7
- false
- true
- true
- 1
- e1993cb5-dffe-404e-b98d-206fe16e8fad
-
7448
6385
14
28
-
7448
6385
14
28
-
7456.5
6399
- false
- End
- B
- String to append.
- b33bbd9a-ec2e-4008-addb-3d2c00dbbc9e
- false
- true
- true
- 0
-
7448
6413
14
28
-
7448
6413
14
28
-
7456.5
6427
- false
- Result
- R
- Resulting string consisting of A+B
- 6b333fee-e97e-4d3b-9130-a156a4407185
- false
- true
- true
- 0
-
7492
6385
15
56
-
7492
6385
15
56
-
7501
6413
- 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
- b165fb69-2a76-4a63-bfec-9b10c89eb632
- 1
- true
- true
- true
- longest_list
-
7590
6342
102
164
-
7641
6344
24
160
-
7653
6424
- 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
- 6a4def02-e1e5-4d86-bf14-6d2dbfa730ff
- true
- true
- true
- 1
- d5db886c-0377-4e25-8130-b77d4eea39e8
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7592
6344
46
20
-
7592
6344
46
20
-
7616.5
6354
- false
- Variable name
- name
- Script Variable name
- 52dc9b29-ee4b-41f4-ab9a-10477175190b
- true
- true
- true
- 1
- 6b333fee-e97e-4d3b-9130-a156a4407185
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
6364
46
20
-
7592
6364
46
20
-
7616.5
6374
- false
- Variable layer
- layer
- Script Variable layer
- 3f8cf4b2-ec39-4b5b-88e9-7652b33926ff
- true
- true
- true
- 1
- 41173647-3808-49db-8e6e-cd700aa06091
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7592
6384
46
20
-
7592
6384
46
20
-
7616.5
6394
- false
- Variable color
- color
- Script Variable color
- 5ba9ac25-e236-4176-a783-9b40034d89ab
- true
- true
- true
- 0
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7592
6404
46
20
-
7592
6404
46
20
-
7616.5
6414
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 6e732832-5850-4b0c-94d2-7d87ebbc41e7
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7592
6424
46
20
-
7592
6424
46
20
-
7616.5
6434
- false
- Variable wires
- wires
- Script Variable wires
- 84e5ff20-5d67-4bbe-b473-cc793e51ab8a
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7592
6444
46
20
-
7592
6444
46
20
-
7616.5
6454
- false
- Variable material
- material
- Script Variable material
- b679373f-fadc-4141-8275-c4548a8e472e
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7592
6464
46
20
-
7592
6464
46
20
-
7616.5
6474
- false
- Variable activate
- activate
- Script Variable activate
- 5608df5d-521d-4ec8-9bc3-cb9414feb937
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7592
6484
46
20
-
7592
6484
46
20
-
7616.5
6494
- false
- Output
- out
- Print, Reflect and Error streams
- 9289c804-c945-4cc9-a934-cf0058cd83da
- false
- true
- true
- 0
-
7668
6344
22
160
-
7668
6344
22
160
-
7680.5
6424
- false
- 59e0b89a-e487-49f8-bab8-b5bab16be14c
- Panel
- Panel
- A panel for custom notes and String values
- 61ace05f-2965-4c4a-a329-5e079ee8f7a5
- false
- true
- true
- 0
- RJ-
- true
- true
- true
- 0
- 0
- false
-
255;0;0;0
-
255;189;255;112
-
7269
6191
149
20
-
7269
6191
149
20
-
7269.989
6191.634
- false
- Microsoft Sans Serif
- 10
- false
- false
- 01cbd6e3-ccbe-4c24-baeb-46e10553e18b
- Concatenate
- Concatenate
- Concat
- Concatenate two Strings
- 8ea2aa4b-bd8f-4365-b903-eb1eaf3c5bfa
- true
- true
- true
- longest_list
-
7447
6185
63
60
-
7466
6187
24
56
-
7478
6215
- false
- Start
- A
- String to append to.
- c9c34470-296c-4b49-bc6e-efb64db60aba
- false
- true
- true
- 1
- 61ace05f-2965-4c4a-a329-5e079ee8f7a5
-
7449
6187
14
28
-
7449
6187
14
28
-
7457.5
6201
- false
- End
- B
- String to append.
- 1b2cd626-abaa-4a7d-b67c-4516449a909d
- false
- true
- true
- 0
-
7449
6215
14
28
-
7449
6215
14
28
-
7457.5
6229
- false
- Result
- R
- Resulting string consisting of A+B
- ee0a2d6b-16bc-4b35-9b35-de2ffdb96ad7
- false
- true
- true
- 0
-
7493
6187
15
56
-
7493
6187
15
56
-
7502
6215
- 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
- a8c49c2d-5339-4f06-89f1-faa3e7f92585
- 1
- true
- true
- true
- longest_list
-
7591
6144
102
164
-
7642
6146
24
160
-
7654
6226
- 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
- be1f0440-6cca-410d-aadf-32ac9705ab9d
- true
- true
- true
- 1
- 57b592f8-eb2b-44fb-bf87-588cd4b9c431
- c37956f4-d39c-49c7-af71-1e87f8031b26
- true
- true
-
7593
6146
46
20
-
7593
6146
46
20
-
7617.5
6156
- false
- Variable name
- name
- Script Variable name
- 1922f293-99dd-452d-80a1-53227f49f27f
- true
- true
- true
- 1
- ee0a2d6b-16bc-4b35-9b35-de2ffdb96ad7
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
6166
46
20
-
7593
6166
46
20
-
7617.5
6176
- false
- Variable layer
- layer
- Script Variable layer
- de686c68-3f64-4230-bd7a-2f692a3bca04
- true
- true
- true
- 1
- b68800ec-8698-4212-9aa2-a974c87e3b82
- 9e93878a-f9c5-4f0a-8a70-584bf09f24bb
- true
- true
-
7593
6186
46
20
-
7593
6186
46
20
-
7617.5
6196
- false
- Variable color
- color
- Script Variable color
- 11ad799d-b7a5-495b-a779-0b7084e84655
- true
- true
- true
- 1
- f17483ab-c2ce-4098-ae15-a12e6d481b74
- 24b1d1a3-ab79-498c-9e44-c5b14607c4d3
- true
- true
-
7593
6206
46
20
-
7593
6206
46
20
-
7617.5
6216
- false
- Variable pWidth
- pWidth
- Script Variable pWidth
- 90474094-60a0-40f4-89c6-a1d33a672988
- true
- true
- true
- 0
- 19ff81a2-dc4f-4035-8de9-26224c561321
- true
- true
-
7593
6226
46
20
-
7593
6226
46
20
-
7617.5
6236
- false
- Variable wires
- wires
- Script Variable wires
- 677f74f0-1d2e-4474-9eae-97d8dc011535
- true
- true
- true
- 0
- 48d01794-d3d8-4aef-990e-127168822244
- true
- true
-
7593
6246
46
20
-
7593
6246
46
20
-
7617.5
6256
- false
- Variable material
- material
- Script Variable material
- 5e492b2a-f1b7-4a66-8b4e-d619c18719e0
- true
- true
- true
- 0
- 6a184b65-baa3-42d1-a548-3915b401de53
- true
- true
-
7593
6266
46
20
-
7593
6266
46
20
-
7617.5
6276
- false
- Variable activate
- activate
- Script Variable activate
- 0613f2a4-0751-4883-9ac5-ddc48e77fa53
- true
- true
- true
- 2
- 1
- b39eb89a-c399-4218-9d1c-41a157c19ae9
- d60527f5-b5af-4ef6-8970-5f96fe412559
- true
- true
-
7593
6286
46
20
-
7593
6286
46
20
-
7617.5
6296
- false
- Output
- out
- Print, Reflect and Error streams
- ac4ac537-8015-451c-83e2-efe8d9c4a9f8
- false
- true
- true
- 0
-
7669
6146
22
160
-
7669
6146
22
160
-
7681.5
6226
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Ring Brep
- Represents a collection of generic data
- 79826c56-f326-42e1-a2c6-4137d7fded6d
- false
- true
- true
- 2
- 0
-
7440
3975
66
20
-
7440
3975
66
20
-
7473.349
3985.424
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Tube Brep
- Represents a collection of generic data
- 98e3818a-74f8-46f1-901d-1e6929eb1a02
- false
- true
- true
- 2
- 0
-
7438
4173
67
20
-
7438
4173
67
20
-
7472.349
4183.058
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Tube Lines
- Represents a collection of generic data
- bc7aeaab-0899-44c1-8281-72c7df7979bb
- false
- true
- true
- 2
- 0
-
7434
4370
71
20
-
7434
4370
71
20
-
7470.349
4380.943
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Moire Brep
- Represents a collection of generic data
- bd57fc10-b338-4303-b12a-b0940361c111
- false
- true
- true
- 2
- 0
-
7435
4568
70
20
-
7435
4568
70
20
-
7470.099
4578.078
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Moire Lines
- Represents a collection of generic data
- 5f6ef152-1722-4e0e-b9ac-239528b7cbb4
- false
- true
- true
- 2
- 0
-
7431
4764
74
20
-
7431
4764
74
20
-
7468.099
4774.962
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Rib Brep
- Represents a collection of generic data
- 6f075257-50e0-4886-b1f4-e3c31507b85f
- false
- true
- true
- 2
- 0
-
7448
4962
59
20
-
7448
4962
59
20
-
7477.599
4972.847
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Rib Lines
- Represents a collection of generic data
- 67d9470f-4344-4096-b984-d40a16dc5390
- false
- true
- true
- 2
- 0
-
7444
5159
63
20
-
7444
5159
63
20
-
7475.599
5169.732
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Node Labels
- Represents a collection of generic data
- f3493ff2-2419-45dd-a7ac-127ee0f0d072
- true
- true
- true
- 2
- 0
-
7426
5357
78
20
-
7426
5357
78
20
-
7465.599
5367.367
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Rib Labels
- Represents a collection of generic data
- 0056bc97-838a-4715-a29c-1fab435308fd
- false
- true
- true
- 2
- 0
-
7437
5555
69
20
-
7437
5555
69
20
-
7472.099
5565.251
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Moire Labels
- Represents a collection of generic data
- a326c95e-d9d4-4586-a8a2-41ee1ef4e133
- true
- true
- true
- 2
- 0
-
7424
5752
80
20
-
7424
5752
80
20
-
7464.099
5762.386
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Tube Labels
- Represents a collection of generic data
- 861fc06e-5dc4-4362-b1bc-39768f0917ea
- false
- true
- true
- 2
- 0
-
7427
5949
77
20
-
7427
5949
77
20
-
7466.349
5959.271
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Flower Labels
- Represents a collection of generic data
- 57b592f8-eb2b-44fb-bf87-588cd4b9c431
- false
- true
- true
- 2
- 0
-
7417
6147
86
20
-
7417
6147
86
20
-
7460.849
6157.406
- false
- 8ec86459-bf01-4409-baee-174d0d2b13d0
- Data
- Data
- Ring Labels
- Represents a collection of generic data
- d5db886c-0377-4e25-8130-b77d4eea39e8
- true
- true
- true
- 2
- 0
-
7430
6344
75
20
-
7430
6344
75
20
-
7467.849
6354.791
- false
- 9c53bac0-ba66-40bd-8154-ce9829b9db1a
- Colour Swatch
-
255;255;0;0
- Colour Swatch
- Swatch
- Colour (palette) swatch
- 502518dd-0b85-4619-b735-0a3771664319
- false
- true
- true
- 0
-
6994
5614
89
20
-
6994
5614
89
20
-
6994.5
5614
- false
- 9c53bac0-ba66-40bd-8154-ce9829b9db1a
- Colour Swatch
-
255;0;255;0
- Colour Swatch
- Swatch
- Colour (palette) swatch
- ca3739b7-ecac-4d29-ad43-97804c0f3602
- false
- true
- true
- 0
-
6994
6014
89
20
-
6994
6014
89
20
-
6994.5
6014
- false
- 9c53bac0-ba66-40bd-8154-ce9829b9db1a
- Colour Swatch
-
255;0;0;255
- Colour Swatch
- Swatch
- Colour (palette) swatch
- f17483ab-c2ce-4098-ae15-a12e6d481b74
- false
- true
- true
- 0
-
6989
6232
89
20
-
6989
6232
89
20
-
6989.75
6232.75
- false
- 7f5c6c55-f846-4a08-9c9a-cfdc285cc6fe
- Scribble
-
5906.633
5022.718
-
6479.533
5022.307
-
6479.57
5186.881
-
5906.67
5187.292
- Set this toggle to true
to bake the model.
(reset to false after) ->
- 43.7668152
- Arial Black
- true
- false
- Scribble
- Scribble
- A quick note
- b0948cde-6be5-4dd8-894e-ecb6b141b18d
-
5901.633
5017.307
582.937
174.9849
-
5901.633
5017.307
582.937
174.9849
-
5906.633
5022.718
- false