# Revit not regenerating view after creating parts

**URL:** <https://forum.dynamobim.com/t/revit-not-regenerating-view-after-creating-parts/32927>\
**Category:** Revit\
**Created:** [March 4, 2019, 5:49pm UTC](https://forum.dynamobim.com/t/revit-not-regenerating-view-after-creating-parts/32927 "2019-03-04T17:49:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [March 4, 2019, 5:49pm UTC](https://forum.dynamobim.com/t/revit-not-regenerating-view-after-creating-parts/32927/1 "2019-03-04T17:49:40Z")

</div>

Hello, I am experimenting with diving walls into parts using the amazing script create by Einar on this post:

> [@Dividing parts with dynamo](https://forum.dynamobim.com/t/dividing-parts-with-dynamo/5388):
>
> Hi , Can any one give me some advice on using dynamo to divide parts. So the scenario is that I need to divide a cross laminated timber wall into modular construction, ie parts that are delivered to site and assembled on site. The modular units need to be a given size say 2.7m in height and 2m in width but when it come to windows and doors i need a smaller cross laminated section, so i am optimizing on the waste material.(as seen in the image below) Any advice on how to do this in …

The problem is, after a successful run of the scrip, Revit does not regenerate its view, so I can’t see or interact with the created parts using Revit.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/b/fb279cd23919d6f9274e1ada4862f95bc105d1bb.png)  
But if I manually create parts from another element, it immediately updates the previous elements and then I can see the parts.

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/e/0ee9b8003556a2f9a212629ba276f94c06f3fa53.png)

Is there a way to “refresh” the view and have the expected result in the script?

I am using Revit 2019.2 Thank a lot for the help!

---

<div class="post-metadata">

**Author:** ![Kulkul](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/kulkul/32/49801_2.png) [@Kulkul](https://forum.dynamobim.com/u/Kulkul)\
**Post date:** [March 4, 2019, 7:25pm UTC](https://forum.dynamobim.com/t/revit-not-regenerating-view-after-creating-parts/32927/2 "2019-03-04T19:25:44Z")

</div>

Hi @lucaspfmoreira

Add boolean input in python to refresh view.

Cheers!

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [March 4, 2019, 7:57pm UTC](https://forum.dynamobim.com/t/revit-not-regenerating-view-after-creating-parts/32927/3 "2019-03-04T19:57:10Z")

</div>

Thanks, for your Help, but I have tried that already!

---

<div class="post-metadata">

**Author:** ![lucaspfmoreira](https://avatars.discourse-cdn.com/v4/letter/l/c57346/32.png) [@lucaspfmoreira](https://forum.dynamobim.com/u/lucaspfmoreira)\
**Post date:** [March 4, 2019, 8:00pm UTC](https://forum.dynamobim.com/t/revit-not-regenerating-view-after-creating-parts/32927/4 "2019-03-04T20:00:59Z")

</div>

Looks like I just found the method on the Revit API.  
it is the PartsVisibility option.

the new code is:

```
import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
#Preparing input from dynamo to revit
wall = UnwrapElement(IN[0])
divisionLines = [l.ToRevitType(True) for l in IN[1]]
sketchPlane = UnwrapElement(IN[2])

#Create a list for the wall and the divisionLines
wallList = List[ElementId]()
wallList.Add(wall.Id)
intersectionElementsIds = List[ElementId]()
curveArray = List[Curve](divisionLines)

#All actions that make changes to the Revit database needs to be inside a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

if PartUtils.AreElementsValidForCreateParts(doc, wallList):
	createParts = PartUtils.CreateParts(doc, wallList)
	doc.Regenerate()

parts = PartUtils.GetAssociatedParts(doc, wall.Id, True, True)
partDivide = PartUtils.DivideParts(doc, parts, intersectionElementsIds, curveArray, sketchPlane.Id)

doc.ActiveView.PartsVisibility = PartsVisibility.ShowPartsOnly;

uidoc.RefreshActiveView()

TransactionManager.Instance.TransactionTaskDone()

OUT = partDivide

```

That does the trick.
