<?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: Creating ParcelSegmentLabels example in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10818102#M8120</link>
    <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;The .net method&amp;nbsp;ParcelSegmentLabel.Create is still not working for me.&amp;nbsp; Did you get it to work without getting the index out of range error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tweaked the code to use the com method to add the labels and also added a check so that labels were not duplicated within the command.&amp;nbsp; It works while in the command, but I need to come up with a way to not duplicate existing labels.&amp;nbsp; Any advice would be appreaciated.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                        for (idx = 0; idx &amp;lt; com_seg.Count; idx++)
                        {
                            var curseg = com_seg.Item(idx);
                            if ((curseg.StartX == l_item.StartX &amp;amp;&amp;amp; 
                                curseg.StartY == l_item.StartY &amp;amp;&amp;amp; 
                                curseg.EndX == l_item.EndX &amp;amp;&amp;amp; curseg.EndY == l_item.EndY) ||
                                (curseg.StartX == l_item.EndX &amp;amp;&amp;amp; 
                                curseg.StartY == l_item.EndY &amp;amp;&amp;amp; curseg.EndX == l_item.StartX 
                                &amp;amp;&amp;amp; curseg.EndY == l_item.StartY))
                            {
                                var segelement = CivDb.DBObject.FromAcadObject(com_seg);
                                //ObjectId PLabelId = ParcelSegmentLabel.Create(segelement.ObjectId, idx + 0.5);
                      
                                Curve cv = tr.GetObject(segelement,OpenMode.ForRead)  as Curve;
                                var len = cv.GetDistanceAtParameter(idx + 0.5);
                                var pt = cv.GetPointAtDist(len);

                                if (!LabeledPoints.Contains(pt))
                                {
                                    LabeledPoints.Add(pt);
                                    curseg.ParcelSegment.SegmentLabels.Add(linStyle, crvStyle, pt.ToArray());
                                }
                                continue;
                            }
                        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help over the years!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stacy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 12 Dec 2021 23:04:10 GMT</pubDate>
    <dc:creator>stacy.dunn</dc:creator>
    <dc:date>2021-12-12T23:04:10Z</dc:date>
    <item>
      <title>Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/9654117#M8111</link>
      <description>&lt;P&gt;This is an example of how to add labels at the picked points along a ParcelSegment without needing to reference the COM libraries (no .NET methods exist to do this, as of C3D 2021).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;        [CommandMethod("TestCreateParcelLabels")]
        public void createparcellabels()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            var entOpts = new PromptEntityOptions("\nSelect a parcelsegment at location for label: ");
            entOpts.SetRejectMessage("..not a ParcelSegment, try again.");
            entOpts.AddAllowedClass(typeof(ParcelSegment), true);
            var entsel = ed.GetEntity(entOpts);
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                var linId = CivilApplication.ActiveDocument.Settings.GetSettings&amp;lt;SettingsCmdAddParcelSegmentLabels&amp;gt;().Styles.ParcelLineLabelStyleId.Value;
                var crvId = CivilApplication.ActiveDocument.Settings.GetSettings&amp;lt;SettingsCmdAddParcelSegmentLabels&amp;gt;().Styles.ParcelCurveLabelStyleId.Value;
                var linStyle = tr.GetObject(linId, OpenMode.ForRead).AcadObject;
                var crvStyle = tr.GetObject(crvId, OpenMode.ForRead).AcadObject;
                while (entsel.Status == PromptStatus.OK)
                {
                    dynamic p = tr.GetObject(entsel.ObjectId, OpenMode.ForRead).AcadObject; 
                    p.SegmentLabels.Add(linStyle, crvStyle, entsel.PickedPoint.ToArray());
                    entsel = ed.GetEntity(entOpts);
                }
                tr.Commit();
            }            
        }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3391061"&gt;@mehdi-guida&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 18:26:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/9654117#M8111</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2020-07-24T18:26:44Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/9654167#M8112</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;For this post&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jul 2020 18:54:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/9654167#M8112</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2020-07-24T18:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10746941#M8113</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;I looks like they added the class ParcelSegmentLabel to 2022.&amp;nbsp; It appears to inherit GeneralSegmentLabel.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code below returns a not within expected range exception.&amp;nbsp; Not really sure why the error is occurring yet.&amp;nbsp; Do you have any suggestions?&lt;/P&gt;&lt;LI-CODE lang="general"&gt;if (acObjId.ObjectClass.DxfName == "AECC_PARCEL_SEGMENT")
{
ParcelSegment parc = tr.GetObject(acObjId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as ParcelSegment;
for (int i = parc.StartParam; i &amp;lt;= parc.EndParam - 1; i++)
{
ObjectId PLabelId = ParcelSegmentLabel.Create(parc.ObjectId,(i + 0.5);
}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 05:00:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10746941#M8113</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-11-10T05:00:01Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10748317#M8114</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is the ParcelSegment open or closed?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 15:20:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10748317#M8114</guid>
      <dc:creator>BlackBox_</dc:creator>
      <dc:date>2021-11-10T15:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10748327#M8115</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1206685"&gt;@BlackBox_&lt;/a&gt;&amp;nbsp; Both open and closed segments give the same error.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Nov 2021 15:24:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10748327#M8115</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-11-10T15:24:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10748682#M8116</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;, not sure why you are getting that error. I did have to change the code slightly as it showed an error in the VS IDE regarding the StartParam being a double and couldn't cast to an int.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("ParcelSegLabelTest")]
        public void parcelseglabeltest()
        {
            var doc = Application.DocumentManager.CurrentDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            var civdoc = CivilApplication.ActiveDocument;
            
            var entOpts = new PromptEntityOptions("\nSelect Segment");
            entOpts.SetRejectMessage("...not a parcelsegment, try again!");
            entOpts.AddAllowedClass(typeof(ParcelSegment), true);
            var sel = ed.GetEntity(entOpts);

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                while (sel.Status == PromptStatus.OK)
                {
                    if (sel.ObjectId.ObjectClass.DxfName == "AECC_PARCEL_SEGMENT")
                    {
                        ParcelSegment parc = tr.GetObject(sel.ObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as ParcelSegment;
                        for (int i = (int)parc.StartParam; i &amp;lt;= parc.EndParam - 1; i++)
                        {
                            ObjectId PLabelId = ParcelSegmentLabel.Create(parc.ObjectId, (i + 0.5));
                        }
                    }
                    sel = ed.GetEntity(entOpts);
                }
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 10 Nov 2021 17:44:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10748682#M8116</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-11-10T17:44:31Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10754400#M8117</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do you have an example of labeling parcel segments by selecting the parcel and looping through the parcel elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Stacy&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 21:18:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10754400#M8117</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-11-12T21:18:04Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10754757#M8118</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;sure, here is such an example.&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;       [CommandMethod("ParcelSegLabelTest2")]
        public void parcelseglabeltest2()
        {
            var doc = Application.DocumentManager.CurrentDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            var civdoc = CivilApplication.ActiveDocument;

            var entOpts = new PromptEntityOptions("\nSelect Parcel:");
            entOpts.SetRejectMessage("...not a parcel, try again!");
            entOpts.AddAllowedClass(typeof(Parcel), true);
            var sel = ed.GetEntity(entOpts);

            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                while (sel.Status == PromptStatus.OK)
                {
                    var parcel = tr.GetObject(sel.ObjectId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as Parcel;
                    dynamic comparcel = parcel.AcadObject;
                    dynamic loop = comparcel.ParcelLoops.Item(0);//this will be the outer loop if more than 1
                    var count = loop.Count;
                    for (int i = 0; i &amp;lt; count; i++)
                    {
                        dynamic l_item = loop.Item(i);
                        var com_seg = l_item.ParcelSegment;
                        var idx = 0;
                        for (idx = 0; idx &amp;lt; com_seg.Count; idx++)
                        {
                            var curseg = com_seg.Item(idx);
                            if ((curseg.StartX == l_item.StartX &amp;amp;&amp;amp; curseg.StartY == l_item.StartY &amp;amp;&amp;amp; curseg.EndX == l_item.EndX &amp;amp;&amp;amp; curseg.EndY == l_item.EndY) ||
                                (curseg.StartX == l_item.EndX &amp;amp;&amp;amp; curseg.StartY == l_item.EndY &amp;amp;&amp;amp; curseg.EndX == l_item.StartX &amp;amp;&amp;amp; curseg.EndY == l_item.StartY))
                            {
                                var segelement = CivDb.DBObject.FromAcadObject(com_seg);
                                ObjectId PLabelId = ParcelSegmentLabel.Create(segelement.ObjectId, idx + 0.5);
                                continue;
                            }
                        }
                    }
                    sel = ed.GetEntity(entOpts);
                }
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 13 Nov 2021 02:13:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10754757#M8118</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-11-13T02:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10761328#M8119</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stacy&lt;/P&gt;</description>
      <pubDate>Tue, 16 Nov 2021 16:59:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10761328#M8119</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-11-16T16:59:41Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10818102#M8120</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;The .net method&amp;nbsp;ParcelSegmentLabel.Create is still not working for me.&amp;nbsp; Did you get it to work without getting the index out of range error?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tweaked the code to use the com method to add the labels and also added a check so that labels were not duplicated within the command.&amp;nbsp; It works while in the command, but I need to come up with a way to not duplicate existing labels.&amp;nbsp; Any advice would be appreaciated.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;                        for (idx = 0; idx &amp;lt; com_seg.Count; idx++)
                        {
                            var curseg = com_seg.Item(idx);
                            if ((curseg.StartX == l_item.StartX &amp;amp;&amp;amp; 
                                curseg.StartY == l_item.StartY &amp;amp;&amp;amp; 
                                curseg.EndX == l_item.EndX &amp;amp;&amp;amp; curseg.EndY == l_item.EndY) ||
                                (curseg.StartX == l_item.EndX &amp;amp;&amp;amp; 
                                curseg.StartY == l_item.EndY &amp;amp;&amp;amp; curseg.EndX == l_item.StartX 
                                &amp;amp;&amp;amp; curseg.EndY == l_item.StartY))
                            {
                                var segelement = CivDb.DBObject.FromAcadObject(com_seg);
                                //ObjectId PLabelId = ParcelSegmentLabel.Create(segelement.ObjectId, idx + 0.5);
                      
                                Curve cv = tr.GetObject(segelement,OpenMode.ForRead)  as Curve;
                                var len = cv.GetDistanceAtParameter(idx + 0.5);
                                var pt = cv.GetPointAtDist(len);

                                if (!LabeledPoints.Contains(pt))
                                {
                                    LabeledPoints.Add(pt);
                                    curseg.ParcelSegment.SegmentLabels.Add(linStyle, crvStyle, pt.ToArray());
                                }
                                continue;
                            }
                        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your help over the years!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stacy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 12 Dec 2021 23:04:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10818102#M8120</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-12-12T23:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10820118#M8121</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Jeff,&lt;/P&gt;
&lt;P&gt;The .net method&amp;nbsp;ParcelSegmentLabel.Create is still not working for me.&amp;nbsp; Did you get it to work without getting the index out of range error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I tweaked the code to use the com method to add the labels and also added a check so that labels were not duplicated within the command.&amp;nbsp; It works while in the command, but I need to come up with a way to not duplicate existing labels.&amp;nbsp; Any advice would be appreaciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help over the years!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Stacy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes, Stacy, the last code I posted worked without error in the drawing I was testing with. Are you saying it gave you the index out of range error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the existing labels, COM has the SegmentLabels property and .NET has the GetAvailableParcelSegmentLabelIds() method. With either of these you can loop through them to see if the current element has a label.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 17:24:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10820118#M8121</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-12-13T17:24:19Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10820332#M8122</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;I tried a few things and did get the .net method to work only in a specific instance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I open a blank drawing using the OOTB acad.dwt, create a parcel using a polyline, and run the code I get:&lt;/P&gt;&lt;P&gt;System.ArgumentException: The ratio should be in the range [0, 0].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If create a parcel using lines and curves and run the code it works as expected.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I test the code with my test drawing I get the error:&lt;/P&gt;&lt;P&gt;System.ArgumentException: Value does not fall within the expected range.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My test drawing or new drawing based on our production template produces this same error regardless if the parcel was created with lines or polylines.&amp;nbsp; The template is based on a previous version of C3d.&amp;nbsp; The built in commands work as expected in all drawings.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am not sure what it going on, but I will submit a support request to see if Autodesk can shed any light on it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Stacy&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;&lt;P&gt;&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>Mon, 13 Dec 2021 19:02:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10820332#M8122</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-12-13T19:02:51Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10820651#M8123</link>
      <description>&lt;P&gt;Ah, selecting a parcel created from a polyline fails. That is strange.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Dec 2021 21:14:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10820651#M8123</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-12-13T21:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10822617#M8124</link>
      <description>&lt;P data-unlink="true"&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;See the last few posts in &lt;A href="https://forums.autodesk.com/t5/civil-3d-customization/how-can-i-add-labels-to-a-polyline-by-net/td-p/9647126/page/2" target="_blank" rel="noopener"&gt;this thread&lt;/A&gt;&amp;nbsp; the GeneralLineLabel fails the same way when a closed polyline is selected. Working around the polyline issue was fairly simple...just make the polyline open then reclose it. Really can't do the same thing with parcels since it will remove/recreate the parcel and likely cause havoc with numbering.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 16:26:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10822617#M8124</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-12-14T16:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10822765#M8125</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;Thank you for the heads up on how to work around the polyline issue.&amp;nbsp; For my current needs I am using the COM methods to get the labeling done.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am having trouble figuring out how to get the individual parcel segment to check for labelIds.&amp;nbsp; When getting the objectids from the parcel segment, it is returning all of the labels attached to the segment and not the ones within the current parcel loop,&amp;nbsp; The actual linework is a rear lot line that is drawing across the back of a block.&amp;nbsp; There are multiple side lot lines that intersect it.&amp;nbsp;&amp;nbsp;Is there a way to get only the label objectid from the segment within the loop, ie the line segment within the lot itself?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using your example I am using the code below to get the ids.&amp;nbsp; It returns all of the ids along the entire length of the line instead of the one inside the parcel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ObjectId oParcelSegmentId = CivDb.DBObject.FromAcadObject(com_seg);
idcol = ParcelSegmentLabel.GetAvailableLabelIds(oParcelSegmentId);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have also tried getting the component of the parcel segment&amp;nbsp; com_seg.Item(0).ParcelSegment, but this returns the same list of all labels attached to the line.&amp;nbsp; What am I missing?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you,&lt;/P&gt;&lt;P&gt;Stacy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 17:44:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10822765#M8125</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-12-14T17:44:16Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10823269#M8126</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;the following seems to work correctly. Just check of an existing label exists in the same parameter as the segment to be labeled. Yes, this is still using the .NET method to add the label, but that comes after the check.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;                            if ((curseg.StartX == l_item.StartX &amp;amp;&amp;amp; curseg.StartY == l_item.StartY &amp;amp;&amp;amp; curseg.EndX == l_item.EndX &amp;amp;&amp;amp; curseg.EndY == l_item.EndY) ||
                                (curseg.StartX == l_item.EndX &amp;amp;&amp;amp; curseg.StartY == l_item.EndY &amp;amp;&amp;amp; curseg.EndX == l_item.StartX &amp;amp;&amp;amp; curseg.EndY == l_item.StartY))
                            {
                                var segelementId = (ObjectId)CivDb.DBObject.FromAcadObject(com_seg);
                                var segelement = (ParcelSegment)segelementId.GetObject(OpenMode.ForRead);
                                var lbls = ParcelSegmentLabel.GetAvailableLabelIds(segelementId);
                                var lblfound = false;
                                foreach (ObjectId lblId in lbls)
                                {
                                    var lbl = (ParcelSegmentLabel)lblId.GetObject(OpenMode.ForRead);
                                        var p = segelement.GetParameterAtPoint(lbl.LabelLocation);
                                    if (Math.Floor(p) == idx)
                                    {
                                        lblfound = true; ; //label found on segemnt, continue on to next
                                        continue;
                                    }
                                }
                                if (lblfound)
                                    continue;
                                ObjectId PLabelId = ParcelSegmentLabel.Create(segelementId, idx + 0.5);
                                continue;
                            }
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 22:06:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10823269#M8126</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2021-12-14T22:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10823332#M8127</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It didn't occur to me to simply check through the list and compare the location point of the existing label to the new label point.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stacy&lt;/P&gt;</description>
      <pubDate>Tue, 14 Dec 2021 22:36:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10823332#M8127</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2021-12-14T22:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10878445#M8128</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/522627"&gt;@stacy.dunn&lt;/a&gt;&amp;nbsp;looks like the closed polyline issue has been corrected with C3D 2022.1:&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Fixed an API issue in which GeneralSegmentLabel.Create() failed on closed polylines.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I haven't yet tested it, just saw it in the readme.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jan 2022 23:23:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10878445#M8128</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2022-01-13T23:23:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating ParcelSegmentLabels example</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10878511#M8129</link>
      <description>&lt;P&gt;Thank you Jeff&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 00:13:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/creating-parcelsegmentlabels-example/m-p/10878511#M8129</guid>
      <dc:creator>stacy.dunn</dc:creator>
      <dc:date>2022-01-14T00:13:50Z</dc:date>
    </item>
  </channel>
</rss>

