# Attempted to read or write protected memory. This is often an indication that other memory is corrupt

**URL:** <https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518>\
**Category:** Revit\
**Created:** [October 30, 2019, 12:04pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518 "2019-10-30T12:04:31Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezindzer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dezindzer/32/174553_2.png) [@dezindzer](https://forum.dynamobim.com/u/dezindzer)\
**Post date:** [October 30, 2019, 12:04pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/1 "2019-10-30T12:04:31Z")

</div>

So i created/stitched a script to speed up my workflow which place’s down roofs and floors for every room in my project.  
I’m using Revit 2019.1.6 and Dynamo 2.0.3.

[5.0 Floor and roof by room v2 wip.dyn](https://forum.dynamobim.com/uploads/short-url/rHmMVvOPir3gnyn2dbKw2qv3HZW.dyn) (344.2 KB)  
The floor part works great, but creating roofs does not. I get this error:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/6/7657d1de25b3458c6a4ddcd138ebd0e3db0f8ab1.png)

I have also tried switching to this node by Wombat, but it makes the same error:  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/0/d07d74b8791c58899720b78a28c3ac63954c0f0f.png)

Any idea? 🙂

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [October 31, 2019, 4:00pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/2 "2019-10-31T16:00:08Z")

</div>

this implies a memory issue with the dynamo geometry library somewhere in the graph - it does not necessarily mean it occurs where the error is actually raised though.

Do you have any python in this graph creating geometry?

are you following this advice?

> **[DynamoDS/Dynamo](https://github.com/DynamoDS/Dynamo/wiki/Zero-Touch-Plugin-Development#dispose--using-statement)**
>
> Open Source Graphical Programming for Design. Contribute to DynamoDS/Dynamo development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [October 31, 2019, 5:24pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/3 "2019-10-31T17:24:06Z")

</div>

Are you using Links at all? I have seen this error when trying to do certain things in / with linked documents.

---

<div class="post-metadata">

**Author:** ![dezindzer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dezindzer/32/174553_2.png) [@dezindzer](https://forum.dynamobim.com/u/dezindzer)\
**Post date:** [October 31, 2019, 10:55pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/4 "2019-10-31T22:55:16Z")

</div>

[5.2. Roof by room v2.dyn](https://forum.dynamobim.com/uploads/short-url/vC4nYtQuGHkRz101R3dRP6pU7iu.dyn) (21.9 KB)

I have tried using the “standard” nodes that come with dynamo, but the error still occurs…

 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/c/fcdbcd928f396c75b6ce313ec95482f865eb92ee.png)

---

<div class="post-metadata">

**Author:** ![dezindzer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dezindzer/32/174553_2.png) [@dezindzer](https://forum.dynamobim.com/u/dezindzer)\
**Post date:** [October 31, 2019, 10:57pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/5 "2019-10-31T22:57:07Z")

</div>

> [@SeanP](#):
>
> Are you using Links at all? I have seen this error when trying to do certain things in / with linked documents.

I’m not using linked documents.  
The walls i draw are sometimes Curtain Panel system walls, and sometimes regular walls.  
The code does not work on both of them.

---

<div class="post-metadata">

**Author:** ![Michael\_Kirschner2](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/michael_kirschner2/32/75576_2.png) [@Michael\_Kirschner2](https://forum.dynamobim.com/u/Michael_Kirschner2)\
**Post date:** [October 31, 2019, 11:38pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/6 "2019-10-31T23:38:55Z")

</div>

there is a bug in this node - thanks for reporting it:

> <https://github.com/DynamoDS/DynamoRevit/blob/4cc183fb6eb7db13e29cf2d04192df499961a8b9/src/Libraries/RevitNodes/Elements/Roof.cs#L162>

these curves need to be disposed, I will report it to the Revit team.

potential fix:

> <https://github.com/DynamoDS/DynamoRevit/pull/2444>

---

<div class="post-metadata">

**Author:** ![dezindzer](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dezindzer/32/174553_2.png) [@dezindzer](https://forum.dynamobim.com/u/dezindzer)\
**Post date:** [December 14, 2019, 8:32pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/7 "2019-12-14T20:32:49Z")

</div>

Has this been fixed or if not, and will it be?  
I found a way to trick dynamo to place all the roofs, just by placing a random roof somwhere on the model and then running the script.

---

<div class="post-metadata">

**Author:** ![ilgnv88](https://avatars.discourse-cdn.com/v4/letter/i/bcef8e/32.png) [@ilgnv88](https://forum.dynamobim.com/u/ilgnv88)\
**Post date:** [April 17, 2020, 4:59pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/8 "2020-04-17T16:59:15Z")

</div>

> [@SeanP](#):
>
> Are you using Links at all? I have seen this error when trying to do certain things in / with linked documents.

Thank you! There was the same mistake. This was because Doc and Linkdoc were used in the same transaction. Also changed doc.ActiveView from 3D view to FloorPlan view

---

<div class="post-metadata">

**Author:** ![willy.tovar](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@willy.tovar](https://forum.dynamobim.com/u/willy.tovar)\
**Post date:** [April 9, 2024, 10:02pm UTC](https://forum.dynamobim.com/t/attempted-to-read-or-write-protected-memory-this-is-often-an-indication-that-other-memory-is-corrupt/42518/9 "2024-04-09T22:02:40Z")

</div>

Change 3D to FloorPlan worked for me.
