Hi all!
Inspired by Rebar.ByCurve node from DynamoRebar package, I was wondering if is it possible to create freeform rebars in a similar way.
I created a Python Script whose inputs are:
- Rebar Bar Type;
- Host Element;
- IList of curves (supposed to become freeform rebars).
The script is the following:
As a result I get this:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. _
Traceback (most recent call last):
_ File “”, line 28, in
TypeError: CreateFreeForm() takes at least 2147483647 arguments (5 given)
Thanks in advance, best regards!
1 Like
2147483647 arguments? Wow. What version of revit are you using? Also could you post your code?
Hi Tom,
as I was uploading a screenshot your reply appeared, thanks for that. I hope the code will clarify something.
I’m on rvt2018.2+dynamo1.3.2.
1 Like
Hey there! Any ideas, anyone?
Thanks
Sorry I had a quick go but didn’t manage to figure it out, I’ll keep working on it
Hello there! Has anyone any ideas?
Thanks
Hello there,
Finally got it working although not using the override method in python since for some reason it doesn’t seem to work I suspect this happens because of the last parameter in the function, the RebarFreeFormValidationResult, since that parameter should be an output, it seems the python compiler gets confused and can’t find the method signature. So the way I found around it, was to access the api call in .NET. and wrap it in a function. you can find how to develop .dlls for dynamo here: Become a Dynamo Zero Touch C# Node Developer in 75 Minutes
This is how it looks in c#:
public class Carcass
{
public static Autodesk.Revit.DB.Structure.Rebar AccessToMethodOverload(Autodesk.Revit.DB.Document doc, RebarBarType bartype, Autodesk.Revit.DB.Element host, List<CurveLoop> curves)
{
Rebar rebar = Rebar.CreateFreeForm(doc, bartype, host, (IList<CurveLoop>)curves, out RebarFreeFormValidationResult error);
return rebar;
}
}
you can call the function afterwards in IronPython: do not forget to reference your .dll file in dynamo.
The transaction management can be handled in the python script:
clr.AddReference('Carcass')
from Carcass import Carcass
doc=DocumentManager.Instance.CurrentDBDocument
TransactionManager.Instance.EnsureInTransaction(doc)
#define function args here
reb=Carcass.AccessToMethodOverload(doc,bartype,host,curves)
TransactionManager.Instance.TransactionTaskDone()
Hope this helps.