Your demo looks promising and it's nice to walk along with you to learn what every block does or why you use it. But I'm getting stuck when you add Element.CopyByVector. I can't seem to find the block in my library. Could it be that there is a package that I need to load first?
Where can I find this package Worksheet Visibility 11:49
Your demo looks promising and it's nice to walk along with you to learn what every block does or why you use it. But I'm getting stuck when you add Element.CopyByVector. I can't seem to find the block in my library. Could it be that there is a package that I need to load first?
It's in the Clockwork package
Spent some time on this , won’t work. Not sure why
I think its because your model is not workset enabled
for auto split duct, pipe,.. you should better using Python or C#
@@vuinhduy8314
Yes Looks something like this:
import clr
import math
from System import Guid
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
# Functie om duct op te splitsen
def split_duct(doc, duct, max_length):
# Start een transaction
transaction = Transaction(doc, "Split Ducts")
transaction.Start()
try:
location_curve = duct.Location.Curve
start_point = location_curve.GetEndPoint(0)
end_point = location_curve.GetEndPoint(1)
total_length = location_curve.Length
if total_length > max_length:
current_start = start_point
current_length = 0
while current_length < total_length:
segment_length = min(max_length, total_length - current_length)
direction = (end_point - current_start).Normalize()
segment_end = current_start + direction * segment_length
new_duct = doc.Create.NewDuct(current_start, segment_end, duct.MEPSystem, duct.GetTypeId())
current_start = segment_end
current_length += segment_length
doc.Delete(duct.Id)
transaction.Commit()
except Exception as e:
transaction.RollBack()
print("Fout bij het splitsen van ducts: {}".format(e))
uiapp = __revit__
doc = uiapp.ActiveUIDocument.Document
collector = FilteredElementCollector(doc).OfClass(Duct)
ducts = collector.ToElements()
# Maximum lengte in millimeters (Convert to feet -> Revit uses feet)
MAX_LENGTH = 1500 / 304.8 # Omrekenen naar feet (Revit gebruikt feet)
for duct in ducts:
split_duct(doc, duct, MAX_LENGTH)
print("Ducts gesplitst op maximale lengte van {} mm.".format(1500))