Hi,
Is there any way to split beam using list of floats (from 0 to 1 excluded) to split beam at multiple points?
Im trying to loop through the list but each subsequent iteration divides the already divided beam.
Here is the piece of code im trying to use
TransactionManager.Instance.EnsureInTransaction(doc)
for index in list:
if beam.CanSplit and 0 < index < 1:
beam.Split(index)
TransactionManager.Instance.TransactionTaskDone()
Iām using element.Split(float) method whitch takes an float parameter, e.g. 0.5 will divide beam in half.
The issue here is that when I try to iterate with a list of indexes,
e.g - I want to divide beam into three beams, so my list will be [0.3 , 0.6].
But after first iteration I have two new beams and second iteration divides one of them - not the original one.
Is there any other API method that splits element by points maybe?
doc = DocumentManager.Instance.CurrentDBDocument
beam = UnwrapElement(IN[0])
list = IN[1]
TransactionManager.Instance.EnsureInTransaction(doc)
for index in lista:
if beam.CanSplit and 0 < index < 1:
beam.Split(index)
TransactionManager.Instance.TransactionTaskDone()
There doesnāt seem to be a straightforward solution to this, although I donāt think itās impossible. FamilyInstance.Split() returns the ElementId of the new element, so you should be able to get the new element from the document and split it separately. I assume that splitting a beam at 0.3 will leave the 0.7 part as the new element, but you should confirm this. A recursive function is probably the best approach here as it should continue to split the newly generated beams until there are no parameters left. What complicates this even further is that the document may have to be regenerated after the new elements are created and that the new beams have a normalized curve domain as well. For example, if you want to divide a beam into 4 equal sections, the first beam is split at 1/4, the second is split at 1/3, and the third is split at 1/2.
Thanks! Could you show your refrences? Cause I seem to miss a refrence using your code.
Generally I was avoiding any āreplacementā solution cause I wanted to keep original parameteres and FamilyInstance.Split() method seems to keep them.
I came up with idea to convert indexes to a target ones - e.g. Division to 4 parts indexes are [0.75, 0.5, 0.25]. After conversion [0.75, 0.666, 0.5].
Hi @c.poupin and @cgartland , itās possible to split multiple beams at multiple index or multiple intersection points without deleting and create a new family? Split recursively to keep the properties from the originals beams like C#?
Hi @paris. It is possible, as I said above - I came with idea to split beams recursively while keeping parameters from the original (not deleting original and creating new objects like @c.poupin proposed).
Try using my code below - it takes intersection indexes of original beam and the beam you want to split. (Try also filtering indexes that are very close to 1 or 0)
doc = DocumentManager.Instance.CurrentDBDocument
beam = UnwrapElement(IN[0])
list = IN[1]
list = filter(None, lista)
list.sort(reverse = True)
list_new = []
count = 1
while len(list) > count:
list_new.append((list[count]/list[count-1]))
count += 1
list_new.insert(0, lista[0])
TransactionManager.Instance.EnsureInTransaction(doc)
for index in list_new:
if beam.CanSplit and 0 < index < 1:
beam.Split(index)
TransactionManager.Instance.TransactionTaskDone()
It works for single selection but you could also add few lines to loop through all selected beams.
To find indexes at which beam is intersected you can use this for example:
Great @c.poupin well done ! thank you.
Can also work with points instead using a list of floats?
I have to modify your code to work with break method for split pipes and ducts at points (intersection with floors).
Have a nice day !
Hello @c.poupin
great, your code work perfectly, like a charm for split one beam at multiple points !
Thank you !
Now Iām looking to resolve the issue with multiple beamsā¦
Cheers, have a nice day !
hello ļ¼can you correct my python scriptļ¼many thanks
using revit2018 dynamo 2.0.3
i want to deal the beams at one time
iāve try to modify your codeļ¼but it could not run
alsoļ¼ i have no idea about----AttributeError: āList[object]ā object has no attribute āLocationā
and thanks again
beam = UnwrapElement(IN[0])
lstParam = IN[1]
cc=[]
count=0
loc = beam.Location
for i in beam:
if isinstance(loc, LocationCurve):
outBeam , lstPt = splitBeam(beam[count], lstParam[count])
cc.append(outBeam )
count +=1
OUT = cc
beam = UnwrapElement(IN[0])
lstParam = IN[1]
cc=[]
count=0
for i in beam:
loc = i.Location
if isinstance(loc, LocationCurve):
outBeam , lstPt = splitBeam(beam[count], lstParam[count])
cc.append(outBeam )
count +=1
OUT = cc