<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Parameter.Set error in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375231#M75090</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is nolonger working.&amp;nbsp; get error "MoficationOutsideTransacionException" Attempt to modify the model outside of transaction. PramElem has correct value.&lt;/P&gt;&lt;P&gt;Using Revit 2015 and vb.net 2012&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Sub ChangeParam(ByVal elem As Element)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim params As ParameterSet = elem.Parameters&lt;BR /&gt;Dim Parameter As Autodesk.Revit.DB.Parameter&lt;BR /&gt;Dim ParamElem As Double&lt;BR /&gt;&lt;BR /&gt;If elem.Name.StartsWith("L") Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each Parameter In params&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If (Parameter.Definition.Name = "Leg") Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ParamElem = Val(Leg) / 12&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parameter.Set(ParamElem)&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Bob V&lt;/P&gt;</description>
    <pubDate>Sat, 01 Nov 2014 22:15:24 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2014-11-01T22:15:24Z</dc:date>
    <item>
      <title>Parameter.Set error</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375231#M75090</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;This is nolonger working.&amp;nbsp; get error "MoficationOutsideTransacionException" Attempt to modify the model outside of transaction. PramElem has correct value.&lt;/P&gt;&lt;P&gt;Using Revit 2015 and vb.net 2012&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Public Sub ChangeParam(ByVal elem As Element)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim params As ParameterSet = elem.Parameters&lt;BR /&gt;Dim Parameter As Autodesk.Revit.DB.Parameter&lt;BR /&gt;Dim ParamElem As Double&lt;BR /&gt;&lt;BR /&gt;If elem.Name.StartsWith("L") Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For Each Parameter In params&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If (Parameter.Definition.Name = "Leg") Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ParamElem = Val(Leg) / 12&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Parameter.Set(ParamElem)&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;next&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Bob V&lt;/P&gt;</description>
      <pubDate>Sat, 01 Nov 2014 22:15:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375231#M75090</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-01T22:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter.Set error</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375583#M75091</link>
      <description>&lt;P&gt;Hello Bob V:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You did not explain how your code differed from previous versions. I assume there have to be some changes made, because the parameter setting works as it should and as it has been for&amp;nbsp;many releases.&amp;nbsp;Changing&amp;nbsp;a parameter as well as any other modifications to&amp;nbsp;a Revit model&amp;nbsp;can only be done within an open transaction. That means that you have to either&amp;nbsp;start your own transaction (Transaction.Start method), or your code must be inside an external command that uses Automatic Transaction Mode. Unless this condition is met, Revit API&amp;nbsp;would throw the very exact exception you got when you attempted modifying the model by changing a parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Question I need to ask you: When do you start your transaction?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 02 Nov 2014 12:35:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375583#M75091</guid>
      <dc:creator>arnostlobel</dc:creator>
      <dc:date>2014-11-02T12:35:25Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter.Set error</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375737#M75092</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I started transaction at beginning of my class and had it set to manual.&lt;BR /&gt;Changed to automatic and it works. Thanks for pointing me in the right&lt;BR /&gt;direction.&lt;BR /&gt;&lt;BR /&gt;Bob V</description>
      <pubDate>Sun, 02 Nov 2014 17:01:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375737#M75092</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-02T17:01:50Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter.Set error</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375889#M75093</link>
      <description>&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 10.8pt; color: black;"&gt;Hello Bob V,&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 10.8pt; color: black;"&gt;I actually now suggest you revisit your code to find what was happening with your transaction instead of simply switching to using the automatic transaction mode. I cannot recommend using that&amp;nbsp;mode as it is more of an inconvenience rather than a helpful feature. Besides the fact that it frees programmers their of duty to start a transaction before they modify a Revit model, automatic transaction mode has nothing but disadvantages. Therefore I strongly recommend you use the manual transaction mode and start transactions manually whenever they are needed.&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 10.8pt; color: black;"&gt;The fact that you got the exception suggests that the transaction you started at the beginning of your class (whatever that means) has closed before your code reached the point at which you&amp;nbsp;attempted modifying the model by&amp;nbsp;changing a parameter. My guess is that you probably put the transaction in an "using" block and started it within the block (which is perfectly fine and it is what we always recommend). However, when&amp;nbsp;such an "using" block ends,&amp;nbsp;the transaction that started there gets automatically&amp;nbsp;rolled back and destroyed&amp;nbsp;if it was not committed explicitly.&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 10.8pt; color: black;"&gt;Again, I suggest you revisit your code, find the cause&amp;nbsp;of your transaction being closed prematurely, and fix it. Using transactions manually will give you more flexibility and control over your changes.&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 11.0pt;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin: 0in; line-height: 11pt; font-family: Calibri; font-size: 10.8pt; color: black;"&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sun, 02 Nov 2014 20:34:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5375889#M75093</guid>
      <dc:creator>arnostlobel</dc:creator>
      <dc:date>2014-11-02T20:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Parameter.Set error</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5376815#M75094</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;Again thank you for your help. I will definitely look into your suggestion.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Bob V</description>
      <pubDate>Mon, 03 Nov 2014 12:22:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/parameter-set-error/m-p/5376815#M75094</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-11-03T12:22:50Z</dc:date>
    </item>
  </channel>
</rss>

