<?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 Re: Form in application in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5652101#M72213</link>
    <description>&lt;P&gt;Hello&amp;nbsp;carolinalm:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is more severe than it appears. THe most important information for you at this moment is that &lt;STRONG&gt;You&amp;nbsp;may not call directly to the Revit API from a form that you invoked&amp;nbsp;using the Form.Show method&lt;/STRONG&gt;. It is because&amp;nbsp;such dialog then is modeless and operates on a different thread&amp;nbsp;than&amp;nbsp;the external command Revit called. Revit does not allow calling to the API from threads other than the main thread. There is a solution to this problem, however, even though I am not sure if it is really what you need. Please search the SDK samples and look for the two samples documenting a ModelessDIalog.&amp;nbsp;Two possible approaches to use when calling from a modeless dialog are illustrated in the two examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you&amp;nbsp;do not need a&amp;nbsp;the dialog to be modeless, then use the &lt;STRONG&gt;Form.ShowDialog&lt;/STRONG&gt; method. It shows the form as a modal dialog (executing on the main thread), and calling from that to the API is fine.&lt;/P&gt;</description>
    <pubDate>Tue, 26 May 2015 16:31:10 GMT</pubDate>
    <dc:creator>arnostlobel</dc:creator>
    <dc:date>2015-05-26T16:31:10Z</dc:date>
    <item>
      <title>Form in application</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5651785#M72211</link>
      <description>&lt;P&gt;I am new at Revit API (and I don't know english very well), so I don`t know if the words&amp;nbsp;that I use are correct. But...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a class (in Transaction.Mode) and a form. &lt;BR /&gt;When I press a button in the form my code catch points written in the form and put beams in its place (I am using delegate to do this). The problem is that it's not working. There`s no errors when I execute the code, but the beams are not being placed. Below there is a summary of the code.&lt;BR /&gt;Can anyone help me? Besides I have searched about calling forms in applications and the best solution was use 'delegate'. Is there another solution?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;[Transaction(TransactionMode.Manual)]&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; public class Estrutura : IExternalCommand&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; public Result Execute(&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; ExternalCommandData commandData,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; ref string message,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; ElementSet elements)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; UIApplication uiapp = commandData.Application;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; UIDocument uidoc = uiapp.ActiveUIDocument;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; Document doc = uidoc.Document;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; Autodesk.Revit.DB.View view = doc.ActiveView;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; Autodesk.Revit.ApplicationServices.Application application = doc.Application;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; var dados = new RevitAddin1.Form2();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; dados.Show();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; dados.button3.Click += delegate&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; {&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;double[][] matriz = dados.AtribuiValores(); //It's the method used to catch the points.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;. //I hid this part of the code to let it cleaner.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; .&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; .&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; .&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; .&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;instance = doc.Create.NewFamilyInstance(line, gotSymbol, l, StructuralType.Beam);&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#808080"&gt;dados.Close();&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; };&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt; \\I have already tried to place the beams with another Transaction, but the code stops in dados.Close();&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; using (Transaction tx = new Transaction(doc, "Viga"))&lt;/FONT&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;FONT color="#808080"&gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; tx.Start("v");&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; foreach (Line linha in lista)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; {&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; instance = doc.Create.NewFamilyInstance(linha, gotSymbol, l, StructuralType.Beam);&lt;/FONT&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;FONT color="#808080"&gt; } &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; tx.Commit();&lt;/FONT&gt;&lt;BR /&gt; &lt;BR /&gt;&lt;FONT color="#808080"&gt; }&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; return Result.Succeeded;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; }&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#808080"&gt; }&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2015 13:16:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5651785#M72211</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-26T13:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Form in application</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5651803#M72212</link>
      <description>When you open a form inside a command, you cannot move the button handle to a different location (unless you really need)&lt;BR /&gt;&lt;BR /&gt;Try something like: change your OK button to DialogResult.OK, then use like&lt;BR /&gt;&lt;BR /&gt;if (dados.Show()==OK)&lt;BR /&gt;{&lt;BR /&gt;    /// add your family instances here&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;And avoid that delegate...</description>
      <pubDate>Tue, 26 May 2015 13:32:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5651803#M72212</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2015-05-26T13:32:49Z</dc:date>
    </item>
    <item>
      <title>Re: Form in application</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5652101#M72213</link>
      <description>&lt;P&gt;Hello&amp;nbsp;carolinalm:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The problem is more severe than it appears. THe most important information for you at this moment is that &lt;STRONG&gt;You&amp;nbsp;may not call directly to the Revit API from a form that you invoked&amp;nbsp;using the Form.Show method&lt;/STRONG&gt;. It is because&amp;nbsp;such dialog then is modeless and operates on a different thread&amp;nbsp;than&amp;nbsp;the external command Revit called. Revit does not allow calling to the API from threads other than the main thread. There is a solution to this problem, however, even though I am not sure if it is really what you need. Please search the SDK samples and look for the two samples documenting a ModelessDIalog.&amp;nbsp;Two possible approaches to use when calling from a modeless dialog are illustrated in the two examples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, if you&amp;nbsp;do not need a&amp;nbsp;the dialog to be modeless, then use the &lt;STRONG&gt;Form.ShowDialog&lt;/STRONG&gt; method. It shows the form as a modal dialog (executing on the main thread), and calling from that to the API is fine.&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2015 16:31:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5652101#M72213</guid>
      <dc:creator>arnostlobel</dc:creator>
      <dc:date>2015-05-26T16:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Form in application</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5652108#M72214</link>
      <description>Nice catch Arnost! Indeed if is a modeless dialog, then it's a different deal...</description>
      <pubDate>Tue, 26 May 2015 16:35:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5652108#M72214</guid>
      <dc:creator>augusto.goncalves</dc:creator>
      <dc:date>2015-05-26T16:35:43Z</dc:date>
    </item>
    <item>
      <title>Re: Form in application</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5654814#M72215</link>
      <description>&lt;P&gt;Thank you Arnost and Augusto.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will try to understand this Modeless Dialog... I believe this is what I need.&lt;/P&gt;</description>
      <pubDate>Thu, 28 May 2015 11:07:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/form-in-application/m-p/5654814#M72215</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-05-28T11:07:08Z</dc:date>
    </item>
  </channel>
</rss>

