Dividing parts with dynamo

Hi,

post is really good and useful!

Regarding the Python script an error appears during the run. Is it possible for a little bit of support?? @Einar_Raknes

I am running Revit 2018 and Dynamo 2.0.2.

Best Regards,
Adnan

I had the same problem.
Be sure to have all the lists on the same level.
You can use the List.Flatten node to flattens the lists.

image

Hi Lucas,

tried, not working…

I can’t right now, but as soon as I have some time I will send you my script.

1 Like

Thank you!

<this post was deleted by the author>

Hello Users,

Fantastic post and thanks for sharing your knowledge! I have tried to split the exterior wall base by any interior wall that touches it. Is it possible instead of using Integer slider to do the divisions for the exterior wall, can we actually split the exterior wall only by using the coordinate of interior wall?

DivideParts Method

curveArray
Type: System.Collections.Generic IList Curve
Array of curves that will divide the elements.

As you can see the PartUtils Method uses a curveArray as reference.

You need to have some sort of curve reference for “the cut”.

you don’t need to use the “Curve.PointAtEqualSegmentLength” node to create your divisions you can use separate points and use these points as the origin for the line that will serve as a reference for the PartUtils method as long as you have a curve reference, in the end, it will work.

Hi Einar, I am trying to do a composite part division like the one shown in the picture in the first post the headers.

Do you know how I’d go about that? I can get parts cur vertically but horizontal cuts fail due to the sketch plane being different.

Any ideas?

You should use a sketchplane that is oriented in the same direction as one of the vertical faces of the wall. One suggestion is to acquire the largest face of a wall and use that as a basis for a sketchplane like this:

2 Likes

First, thank a lot for trying to help!
The problem is the cuts I need are in 2 different planes:

The highlight in red is composed solely of but joints and can be drawn in the face of the wall.
The highlight in yellow is a vertical cut that forms a shiplap connection.

For the one in yellow, the sketch plane would be the bottom of the wall.

Think through how you would do this manually in the UI. I think that doing so will be a bit of an ‘ah ha’ moment for you.

Hi Jacob I had no ah ha moment yet. I have being trying for the pas day to figure this out but noting so far. I notice that if I try to edit the sketch I cant change the sketch plane to do make the division manually from the same original part, I can edit the resulting parts to do that and that is a real pain, because now I need to know which parts intersect with which lines to and iterate trough parts and lines to achieve my desired result instead of only providing the division lines.

Any help would be appreciated.

There is an option to use a Division Profile to the cuts, but it doesn’t seem to be possible to have different division profiles in the different directions. As you say, we are forced to make new cuts to sub-parts. If you afterwards edits the cuts of the main part, all division of sub-parts are lost :frowning:

So you have had an ‘ah ha’ moment. :wink:

Seriously though, this was exactly what I was referring to - each part can only be edited in one sketch plan at a time, with additional parts needing a new sketch plane for each edit. Not ideal, but it’s how the system works.

Start a ‘toy’ project where you attempt to divide a part like this:

Pick any one of the two lines, to divide the original box into two, then pick any other, attempt to intersect it with the result of the two parts, and use a filter by bool mask to remove the part that doesn’t intersect. Once you have that done you can attempt to divide the included part by the line.

If you make that work, try a slightly harder problem, and then a still slightly harder one, and then try your real problem. If you can’t make that work, share your DYN and toy RVT files so we can help. :slight_smile:

@Einar_Raknes, just to include you in this answer.

1st thanks a lot for helping. I am attempting to divide the wall in 2 separate steps, one for each plane/direction of cut.

The problem is after the first cut, I need to retrieve the resulting parts.
But the method .GetDividedElementIds() is deprecated.
I posted in the Parts related blog by Jeremy Tammik https://thebuildingcoder.typepad.com/blog/2012/09/parts-assemblies-partutils-and-divideparts.html
And he suggested to create an event handler and subscribe to a DocumentChanged event, after the creation of the parts unsubscribe and read the registered changes.

The problem is I am failing hard at this.
The variable I create to store the events returns empty every time.

from System import EventHandler, EventArgs
    
    _added_element_ids =  List[ElementId]()
    _added_element_ids.Clear()
    
    def OnDocumentChanged(sender, e):
        _added_element_ids.Add(e.GetElementIds())
    
    app.DocumentChanged += OnDocumentChanged

    parts = createParts(doc, selected, intersections, ros, vskplane)

    app.DocumentChanged -= OnDocumentChanged
    
    print len(_added_element_ids)

I never dealt with event handlers before I think I am declaring it wrong or calling it wrong.
My sources for this where:

https://ironpython.net/documentation/dotnet/dotnet.html
https://thebuildingcoder.typepad.com/blog/2010/06/place-family-instance.html

@Gui_Talarico documents it well here:

and I have updated my code to:

def OnDocumentChanged(sender, e):
added_element_ids.AddRange(e.GetElementIds())
pass

app.DocumentChanged += EventHandler[DocumentChangedEventArgs](OnDocumentChanged)

parts = createParts(doc, selected, intersections, ros, vskplane)

app.DocumentChanged -= EventHandler[DocumentChangedEventArgs](OnDocumentChanged)

for l in added_element_ids:
    print l.Id.ToString + " Here" 

Only to get the same result.

Any Ideas?

1 Like

So I figured it out.
If you’re doing all in one script, you need to regenerate the document before collecting the new panels.
Its is that simple.

2 Likes

Any luck getting this to run? Getting the same error.

Hello, @Einar_Raknes, nice to meet you.
Could you share the Python script please?
Regards.

Hi @Rodolfo_Jordan ,

I don’t know if @Einar_Raknes is still active in this forum, but all the python as well as a very detailed description of the functionality is in posts 4-7 in this thread.

1 Like