<?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 Can't place a group in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8593522#M44212</link>
    <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I don't know where is my mistake but when I try to create an instance of a group nothing happens..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            // On crée la liste de tous les groupes présents dans le fichier
            List&amp;lt;GroupType&amp;gt; collectiongrouptype = new FilteredElementCollector(doc).
                OfClass(typeof(GroupType)).OfType&amp;lt;GroupType&amp;gt;().ToList();

                
                using (ConfigurateurBVForm f = new ConfigurateurBVForm())
                {
                    #region  Bouton Appliquer
                    
                    f.applyButton.Click += (sender, e) =&amp;gt;
                    {
                        using (Transaction tr = new Transaction(doc))
                        {
                            tr.Start("Insert group");

                            //On regarde le nom qui est à inserer
                            foreach (GroupType grouptype in collectiongrouptype)
                            {
                                TaskDialog.Show("e", grouptype.Name);
                                if (grouptype.Name == "montype")
                                {
                                    TaskDialog.Show("ee", "if condition");

                                    //On crée l'instance.
                                    try
                                    {
                                        XYZ zero = new XYZ(0, 0, 0);
                                        doc.Create.PlaceGroup(zero, grouptype);
                                        break;
                                    }
                                    catch { }

                                    tr.Commit();
                                }
                            }
                        }
                    };
                    f.ShowDialog();
                }
                #endregion
            return Result.Succeeded;&lt;/PRE&gt;
&lt;P&gt;Thanks for your help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alexandre&lt;/P&gt;</description>
    <pubDate>Wed, 13 Feb 2019 18:10:19 GMT</pubDate>
    <dc:creator>a.sabatier</dc:creator>
    <dc:date>2019-02-13T18:10:19Z</dc:date>
    <item>
      <title>Can't place a group</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8593522#M44212</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;I don't know where is my mistake but when I try to create an instance of a group nothing happens..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            // On crée la liste de tous les groupes présents dans le fichier
            List&amp;lt;GroupType&amp;gt; collectiongrouptype = new FilteredElementCollector(doc).
                OfClass(typeof(GroupType)).OfType&amp;lt;GroupType&amp;gt;().ToList();

                
                using (ConfigurateurBVForm f = new ConfigurateurBVForm())
                {
                    #region  Bouton Appliquer
                    
                    f.applyButton.Click += (sender, e) =&amp;gt;
                    {
                        using (Transaction tr = new Transaction(doc))
                        {
                            tr.Start("Insert group");

                            //On regarde le nom qui est à inserer
                            foreach (GroupType grouptype in collectiongrouptype)
                            {
                                TaskDialog.Show("e", grouptype.Name);
                                if (grouptype.Name == "montype")
                                {
                                    TaskDialog.Show("ee", "if condition");

                                    //On crée l'instance.
                                    try
                                    {
                                        XYZ zero = new XYZ(0, 0, 0);
                                        doc.Create.PlaceGroup(zero, grouptype);
                                        break;
                                    }
                                    catch { }

                                    tr.Commit();
                                }
                            }
                        }
                    };
                    f.ShowDialog();
                }
                #endregion
            return Result.Succeeded;&lt;/PRE&gt;
&lt;P&gt;Thanks for your help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Alexandre&lt;/P&gt;</description>
      <pubDate>Wed, 13 Feb 2019 18:10:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8593522#M44212</guid>
      <dc:creator>a.sabatier</dc:creator>
      <dc:date>2019-02-13T18:10:19Z</dc:date>
    </item>
    <item>
      <title>Re: Can't place a group</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8594832#M44213</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4063112"&gt;@a.sabatier&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Filter Group instead of Grouptype and from the filtered group try to get the GroupType.&lt;/P&gt;
&lt;PRE&gt;IList&amp;lt;Element&amp;gt; groups = new FilteredElementCollector(doc).OfClass(typeof(Group)).WhereElementIsNotElementType().ToElements() as IList&amp;lt;Element&amp;gt;;
                 
                 foreach (Element group in groups)
                 {
                     Group g = group as Group;&lt;BR /&gt;                     GroupType GT = g.GroupType;&lt;BR /&gt;                     doc.Create.PlaceGroup(new XYZ(0, 0, 0), GT);
                 } &lt;/PRE&gt;
&lt;P&gt;If this helped solve your problem&amp;nbsp; mark it as solution&lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://forums.autodesk.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 05:09:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8594832#M44213</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2019-02-14T05:09:16Z</dc:date>
    </item>
    <item>
      <title>Re: Can't place a group</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8594848#M44214</link>
      <description>&lt;P&gt;hi,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some wrong in your code: after break with foreach loop, the code after break will not be executed; I guess the tr.Commit() is not called, so the placement will not occur; you should move the tr.Commit() outside foreach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try following fixed code, I verified it works:&lt;/P&gt;
&lt;P&gt;foreach (GroupType grouptype in collectiongrouptype)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // your other code&lt;BR /&gt;}&lt;BR /&gt;//&lt;BR /&gt;// commit transaction after group placing&lt;BR /&gt;tr.Commit();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Feb 2019 05:17:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/can-t-place-a-group/m-p/8594848#M44214</guid>
      <dc:creator>JimJia</dc:creator>
      <dc:date>2019-02-14T05:17:42Z</dc:date>
    </item>
  </channel>
</rss>

