Hi
I searched the 2018 API chm file and cannot find a method. I’m thinking to use this method to extend both beam ends to the project beam surface before cope. Thankyou
Hi, it is possible with the SetEndReference Method that you find in the Class Revit.DB.Structure.StructuralFramingUtils:
http://www.revitapidocs.com/2018.1/a694033f-eb4f-45bb-d989-8bc95780e574.htm
I did a fast test:
Running this script you get:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
beams = UnwrapElement(IN[0])
b = UnwrapElement(IN[1])
TransactionManager.Instance.EnsureInTransaction(doc)
ref = FamilyInstance.GetReferenceByName(b,"Center (Front/Back)")
for x in beams:
FamilyInstance.AddCoping(x,b)
StructuralFramingUtils.SetEndReference(x,1,ref)
TransactionManager.Instance.TransactionTaskDone()
Instead of “Center (Front/Back)” you might need to use the name of your reference plane in your family.
Instead of 1 you might need to use 0: those are the start point and the end point of your beams (I would use a IF sentence)
@glenncai is it what you were looking for?
Thank you Luca and sorry for the late reply. I have not try it yet. This what happened when project dead line is coming. All Dynamo and API have to stop. I will give it a try later, i think it will work.
Hi Luca
I run the script successful once. but then I keep getting this error:
Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 24, in
Exception: The input argument “pick” of function
Have you seen this while running the script?
Hi, I think the problem is the name of the Reference Plane of your reference beam, instead of “Center” you have to write the correct name, most probably “Center (Front/Back)”.
In my case it was in german, so I changed the name of the family to “Center” to make it easy. I did a test and apparently it fixed the problem.
Moreover the script a posted was only the core part (no TransactionManager etc…), I will edit now that post to make it useful for everyone
Thank you Luca. it works now. Some how after I change the Reference Name, it was not working immediately. and I have to disconnect and reconnect between nodes to clear the error, but after restart Dynamo everything works perfectly.
Here my script please free to give any advice. Thank you.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
if isinstance(IN[0],list):
beams = UnwrapElement(IN[0])
else:
beams = [UnwrapElement(IN[0])]
b = UnwrapElement(IN[1])
ref = FamilyInstance.GetReferenceByName(b,"Center (Front/Back)")
TransactionManager.Instance.EnsureInTransaction(doc)
for x in beams:
FamilyInstance.AddCoping(x,b)
StructuralFramingUtils.SetEndReference(x,1,ref)
TransactionManager.Instance.TransactionTaskDone()
Hi @glenncai I improved the script, now it works in both cases, for StartPoint (0) and EndPoint (1) of your beams.
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
if isinstance(IN[0],list):
beams = UnwrapElement(IN[0])
else:
beams = [UnwrapElement(IN[0])]
b = UnwrapElement(IN[1])
TransactionManager.Instance.EnsureInTransaction(doc)
ref = FamilyInstance.GetReferenceByName(b,"Center (Front/Back)")
for x in beams:
FamilyInstance.AddCoping(x,b)
if StructuralFramingUtils.IsEndReferenceValid(x,0,ref):
StructuralFramingUtils.SetEndReference(x,0,ref)
else:
StructuralFramingUtils.SetEndReference(x,1,ref)
TransactionManager.Instance.TransactionTaskDone()
Please also don’t forget to mark the topic as solved, so that everybody can find it easily