<?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: Create dimensions in a room in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689743#M43443</link>
    <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;So you want to create dimension in a room?&lt;/P&gt;
&lt;P&gt;Try using the below code&lt;/P&gt;
&lt;P&gt;Select the Room and try to run the below code&lt;/P&gt;
&lt;PRE&gt;if(Room!=null)
                {
                    SpatialElementBoundaryOptions op = new SpatialElementBoundaryOptions();
                    op.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center;
                    IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt; segmensts = Room.GetBoundarySegments(op) as IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt;;
                    foreach ( IList&amp;lt;BoundarySegment&amp;gt; BSS in segmensts)
                    {
                        foreach(BoundarySegment BS in BSS)
                        {

                            XYZ p1 = new XYZ(BS.GetCurve().GetEndPoint(0).X, BS.GetCurve().GetEndPoint(0).Y, BS.GetCurve().GetEndPoint(0).Z);
                            XYZ p2= new XYZ(BS.GetCurve().GetEndPoint(1).X, BS.GetCurve().GetEndPoint(1).Y, BS.GetCurve().GetEndPoint(1).Z);

                            Line l1 = Line.CreateBound(p1, p2);
                            ModelCurve mc = doc.Create.NewModelCurve(l1, SketchPlane.Create(doc, r.LevelId));
                            if(l1!=null)
                            {
                                ReferenceArray RA = new ReferenceArray();
                                RA.Append(mc.GeometryCurve.GetEndPointReference(0));
                                RA.Append(mc.GeometryCurve.GetEndPointReference(1));
                                doc.Create.NewDimension(doc.ActiveView, l1, RA, newdimesionType);
                            }
                        }                       
                    }
                }&lt;/PRE&gt;
&lt;P&gt;and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;while setting the&amp;nbsp;&lt;STRONG&gt;op.SpatialElementBoundaryLocation,&amp;nbsp;&lt;/STRONG&gt;make sure you are giving the proper boundary options for the spatial element geometry calculation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also refer the below link&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2015/349e4292-28b6-cffa-e128-50ac5c90db36.htm" target="_blank" rel="noopener"&gt;SpatialElementBoundaryLocation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this helped solve your problem please mark it as solution, so other users can get this solutions as well&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 28 Mar 2019 10:07:57 GMT</pubDate>
    <dc:creator>naveen.kumar.t</dc:creator>
    <dc:date>2019-03-28T10:07:57Z</dc:date>
    <item>
      <title>Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8687901#M43441</link>
      <description>&lt;P&gt;Hi everyone!&lt;/P&gt;
&lt;P&gt;I am trying to get the dimensions in a room, but I have a mistake in the code. Because when I built it, I get every dimension with the value 0.0, like you could see in the next picture.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dimension.PNG" style="width: 666px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/618955i8BE5DE27FDE3B07E/image-size/large?v=v2&amp;amp;px=999" role="button" title="dimension.PNG" alt="dimension.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I don't attach the completely code because is so long, there are a lot of&amp;nbsp;verifications...&lt;/P&gt;
&lt;P&gt;Therefore I am going to attach the parts that I think that is important,and where maybe the mistake is...&lt;/P&gt;
&lt;P&gt;I first created a loop to run through the walls of the room.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With this I create the point, the start of the wall and the end of the wall.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;var startVertice1 = boundSeg1.GetCurve().GetEndPoint(0);
var endVertice1 = boundSeg1.GetCurve().GetEndPoint(1);&lt;BR /&gt;&lt;BR /&gt;Line dimensionLine1 = Line.CreateBound(startVertice1, endVertice1);&lt;/PRE&gt;
&lt;P&gt;Then create a sketch and the ModelCurve&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;SketchPlane sketch = SketchPlane.Create(doc, geomPlane);&lt;BR /&gt;modelCurve1 = doc.Create&lt;BR /&gt;.NewModelCurve(dimensionLine1, sketch);&lt;/PRE&gt;
&lt;P&gt;The same for the other line!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I add the geometry details references to an array:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;references.Append(modelCurve1.GeometryCurve.Reference);
references.Append(modelCurve2.GeometryCurve.Reference);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I prove that the two lines are paralell&amp;nbsp;and also that they are different:&lt;/P&gt;
&lt;PRE&gt;var paralell = Math.Abs(Vector3D.DotProduct(vVector3D1, vVector3D2));

if (boundSeg2.ElementId != boundSeg1.ElementId)
{
 //comprobamos si es paralelo 
         if (paralell &amp;gt; 1E-1)
          {....&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the conditions are true, I create a line for the dimension:&lt;/P&gt;
&lt;PRE&gt; XYZ dimensionLineStart = new XYZ(startVerticeXyz1.X + Cota,startVerticeXyz1.Y, 0);
 XYZ dimensionLineEnd = new XYZ(endVertice2.X + Cota,endVertice2.Y,0);
 dimensionLine = Line.CreateBound(dimensionLineStart,dimensionLineEnd);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And finally I use&amp;nbsp;NewDimension with the view&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using (Transaction tCota = new Transaction(doc, "dimensions"))
 {
  tCota.Start();
  var comprodDimension =doc.Create.NewDimension(doc.ActiveView, dimensionLine, references);
  tCota.Commit();
 }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Mar 2019 17:33:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8687901#M43441</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-27T17:33:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689272#M43442</link>
      <description>&lt;P&gt;Does this help?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.45" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.45&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 07:21:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689272#M43442</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-03-28T07:21:32Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689743#M43443</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;So you want to create dimension in a room?&lt;/P&gt;
&lt;P&gt;Try using the below code&lt;/P&gt;
&lt;P&gt;Select the Room and try to run the below code&lt;/P&gt;
&lt;PRE&gt;if(Room!=null)
                {
                    SpatialElementBoundaryOptions op = new SpatialElementBoundaryOptions();
                    op.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center;
                    IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt; segmensts = Room.GetBoundarySegments(op) as IList&amp;lt;IList&amp;lt;BoundarySegment&amp;gt;&amp;gt;;
                    foreach ( IList&amp;lt;BoundarySegment&amp;gt; BSS in segmensts)
                    {
                        foreach(BoundarySegment BS in BSS)
                        {

                            XYZ p1 = new XYZ(BS.GetCurve().GetEndPoint(0).X, BS.GetCurve().GetEndPoint(0).Y, BS.GetCurve().GetEndPoint(0).Z);
                            XYZ p2= new XYZ(BS.GetCurve().GetEndPoint(1).X, BS.GetCurve().GetEndPoint(1).Y, BS.GetCurve().GetEndPoint(1).Z);

                            Line l1 = Line.CreateBound(p1, p2);
                            ModelCurve mc = doc.Create.NewModelCurve(l1, SketchPlane.Create(doc, r.LevelId));
                            if(l1!=null)
                            {
                                ReferenceArray RA = new ReferenceArray();
                                RA.Append(mc.GeometryCurve.GetEndPointReference(0));
                                RA.Append(mc.GeometryCurve.GetEndPointReference(1));
                                doc.Create.NewDimension(doc.ActiveView, l1, RA, newdimesionType);
                            }
                        }                       
                    }
                }&lt;/PRE&gt;
&lt;P&gt;and&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;while setting the&amp;nbsp;&lt;STRONG&gt;op.SpatialElementBoundaryLocation,&amp;nbsp;&lt;/STRONG&gt;make sure you are giving the proper boundary options for the spatial element geometry calculation&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also refer the below link&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.revitapidocs.com/2015/349e4292-28b6-cffa-e128-50ac5c90db36.htm" target="_blank" rel="noopener"&gt;SpatialElementBoundaryLocation&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this helped solve your problem please mark it as solution, so other users can get this solutions as well&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 10:07:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689743#M43443</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2019-03-28T10:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689934#M43444</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Naveen,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you very much for a nice approach!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;One little note on the code: it would be more readable if you just called&amp;nbsp;BS.GetCurve() once (not six times!) and stored the result in a variable, e.g. `c`.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Next, why don't you simply say:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;  XYZ p1 = c.GetEndPoint(0);
  XYZ p2 = c.GetEndPoint(1);&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Finally, a more serious and non-trivial problem:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This solution creates a model curve.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If the room changes, the model curve will not, so the dimension will not adapt.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The association is lost.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You could implement the association yourself using DMU to update the model curve when the room changes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It would be simpler if the dimension could use the built-in Revit associativity functionality to adapt when the room changes. &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;After all, that is what BIM is all about...&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you retrieve references from the room? Maybe, to achieve that, you have to retrieve references from the room bounding walls?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 10:54:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689934#M43444</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-03-28T10:54:53Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689981#M43445</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't consider an Updater as a good idea because the NewDimension method takes a view argument.&lt;/P&gt;
&lt;P&gt;A Room may be changed while a ViewSection being the active view, for example.&lt;/P&gt;
&lt;P&gt;So you would need to store the view Id, but the view could be deleted meanwhile etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Revitalizer&lt;/P&gt;</description>
      <pubDate>Thu, 28 Mar 2019 11:05:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8689981#M43445</guid>
      <dc:creator>Revitalizer</dc:creator>
      <dc:date>2019-03-28T11:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8694240#M43446</link>
      <description>&lt;P&gt;Hi Naveen!&lt;/P&gt;
&lt;P&gt;Thank you so much for your code. Thanks to your code I have realized that I had added in the array References the geometry of the two differentlines, but as you had written in the answer I have to add two points like references (of the same line) :&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;RA.Append(mc.GeometryCurve.GetEndPointReference(1))&lt;/PRE&gt;
&lt;P&gt;After fixed this, my code works perfectly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lorena&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 29 Mar 2019 16:33:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/8694240#M43446</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-03-29T16:33:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/9404643#M43447</link>
      <description>&lt;P&gt;Where did you write this code?&lt;/P&gt;&lt;P&gt;I am using python node inside dynamo, so I noticed that this syntax is not written in python.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kindly advice&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 15:00:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/9404643#M43447</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-27T15:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: Create dimensions in a room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/9404654#M43448</link>
      <description>&lt;P&gt;The link does not open, please send another one&lt;/P&gt;</description>
      <pubDate>Fri, 27 Mar 2020 15:02:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/create-dimensions-in-a-room/m-p/9404654#M43448</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-27T15:02:30Z</dc:date>
    </item>
  </channel>
</rss>

