I am following the C# scripting instruction on the official webpage.
https://www.rhino3d.com/inside/revit/1.0/guides/rir-csharp
in the example section, there’s one example illustrates how we can take the advantage from NodeInCode
and to rearrange RhinoInside Components in C# code.
The problem I am facing is that I don’t know how to get it work, if there’re some inputs missing.
For example,
I want to implement the same logic in C# scripting.
private void RunScript(Brep BREP, object y, ref object DS)
{
// AddMaterial component to create a material
var queryMaterials = Components.FindComponent("RhinoInside_QueryMaterials");
// and AddGeometryDirectShape to create a DirectShape element in Revit
var addGeomDirectshape = Components.FindComponent("RhinoInside_AddGeometryDirectShape");
if (queryMaterials == null || addGeomDirectshape == null) {
throw new Exception("One or more of the necessary components are not available as node-in-code");
}
if(BREP != null) {
var newMaterials = queryMaterials.Invoke("", "Glass", null);
var dsElements = addGeomDirectshape.Invoke(
"Custom DS",
GetCategory("Walls"),
BREP,
newMaterials[0]
);
// assign the new DirectShape element to output
DS = dsElements[0];
}
}
// <Custom additional code>
public DB.Category GetCategory(string categoryName){
var doc = RIR.Revit.ActiveDBDocument;
foreach(DB.Category cat in doc.Settings.Categories) {
if (cat.Name == categoryName)
return cat;
}
return null;
}
I think it’s because I missed the first and third input for queryMaterial
node, and I currently don’t know how can I tackle it.
Any suggestion will be helpful. Thanks.
NodeInCodeQuestino.gh (9.8 KB)