<?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: Unable to specify a custom point to hook to? in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13251089#M821</link>
    <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7472042"&gt;@soonhui&lt;/a&gt;&amp;nbsp;from the help file for the Point object:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-08_18-49-37.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1452708iECAF2ACD89A15BF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2025-01-08_18-49-37.png" alt="2025-01-08_18-49-37.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It just seemed like something that I should try. I don't work with subassemblies/assemblies in code very often so it was just a "let's give this a try" moment.&lt;/P&gt;</description>
    <pubDate>Thu, 09 Jan 2025 02:52:07 GMT</pubDate>
    <dc:creator>Jeff_M</dc:creator>
    <dc:date>2025-01-09T02:52:07Z</dc:date>
    <item>
      <title>Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13217801#M816</link>
      <description>&lt;P&gt;I use the following code to create a&amp;nbsp;&lt;STRONG&gt;MedianConstantSlopeWithBarrier&lt;/STRONG&gt;, and I have&amp;nbsp;&lt;STRONG&gt;LaneSuperelevationAOR&lt;/STRONG&gt; connected to it both on the left and right hand side. The catch is that I am introducing new Points into the&amp;nbsp;&lt;STRONG&gt;MedianConstantSlopeWithBarrier&lt;/STRONG&gt; subassembly, so that the two sides of&amp;nbsp;&lt;STRONG&gt;LaneSuperelevationAOR&lt;/STRONG&gt; can attach to those specific Points and not the original Points that&amp;nbsp;&lt;STRONG&gt;MedianConstantSlopeWithBarrier&lt;/STRONG&gt; has. Here's the code:&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;LI-CODE lang="csharp"&gt;        [CommandMethod(nameof(CreateMedianCarriageWayShoulder))]
        public void CreateMedianCarriageWayShoulder()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;

            using Transaction tr = doc.TransactionManager.StartTransaction();

            var assId = CivilApplication.ActiveDocument.AssemblyCollection.Add("MedianCarriageShoulder", AssemblyType.UndividedCrownedRoad, Point3d.Origin);
            var median = CreateMedianConstantSlopeWithBarrier(tr);

            var laneId = CivilApplication.ActiveDocument.SubassemblyCollection.ImportStockSubassembly("LaneSuperelevationAOR", "Subassembly.LaneSuperelevationAOR", Point3d.Origin);
            var lane = tr.GetObject(laneId, OpenMode.ForWrite) as Subassembly;
            var laneWidth = lane.ParamsDouble["Width"];
            laneWidth.Value = 4;
            var defaultSlope = lane.ParamsDouble["DefaultSlope"];
            defaultSlope.Value = -0.025;

            var ass = assId.GetObject(OpenMode.ForWrite) as Assembly;
            var assemblyGroupRight = ass.AddSubassembly(median.ObjectId);
            assemblyGroupRight.Name = "Right";

            // Find Right Top Point
            var pt1 =
            median.Points.Single(pt =&amp;gt; pt.Elevation == -0.3 &amp;amp;&amp;amp; pt.Offset == 3); // this doesn't work even though ( 3,-0.3) is at the subassembly profile
            //(from x in median.Points
            // orderby x.Offset descending, x.Elevation descending
            // select x).First();  // if I pick any of the points from median.Points then I have no problem

            if (pt1 != null)
            {
                ass.AddSubassembly(laneId, pt1);
            }


            var laneLeftId = CivilApplication.ActiveDocument.SubassemblyCollection.ImportStockSubassembly("LaneSuperelevationAOR", "Subassembly.LaneSuperelevationAOR", Point3d.Origin);
            var laneLeft = tr.GetObject(laneLeftId, OpenMode.ForWrite) as Subassembly;
            var laneLeftWidth = laneLeft.ParamsDouble["Width"];
            laneLeftWidth.Value = 3.8;
            var defaultSlopeLeft = laneLeft.ParamsDouble["DefaultSlope"];
            defaultSlopeLeft.Value = -0.030;
            var laneLeftDirection = laneLeft.ParamsLong["Side"];
            laneLeftDirection.Value =1;

            //find left top point
            var pt2 =
            median.Points.Single(pt =&amp;gt; pt.Elevation == -0.2 &amp;amp;&amp;amp; pt.Offset == -2);      // this doesn't work even though ( -2,-0.2) is at the subassembly profile
            //(from x in median.Points
            // orderby x.Offset ascending, x.Elevation descending
            // select x).First();  // if I pick any of the points from median.Points then I have no problem

            if (pt2 != null)
            {
                ass.AddSubassembly(laneLeftId, pt2);
            }

            tr.Commit();

        }

      private static Subassembly CreateMedianConstantSlopeWithBarrier(Transaction tr)
      {
          var medianId = CivilApplication.ActiveDocument.SubassemblyCollection.ImportStockSubassembly("MedianConstantSlopeWithBarrier", "Subassembly.MedianConstantSlopeWithBarrier", Point3d.Origin);
          var median = tr.GetObject(medianId, OpenMode.ForWrite) as Subassembly;  // no left and right. Only one guy

          
          var leftMedianWidth = median.ParamsDouble["LeftMedianWidth"];
          leftMedianWidth.Value = 2;
          var rightMedianWidth = median.ParamsDouble["RightMedianWidth"];
          rightMedianWidth.Value = 3;
          var leftMedianSlope = median.ParamsDouble["LeftMedianCrossSlope"];
          leftMedianSlope.Value = -0.025;  // in absolute value
          var rightMedianSlope = median.ParamsDouble["RightMedianCrossSlope"];
          rightMedianSlope.Value =-0.030;
          var leftMedianShoulderWidth = median.ParamsDouble["LeftShoulderWidth"];
          leftMedianShoulderWidth.Value = 0;
          var rightMedianShoulderWidth = median.ParamsDouble["RightShoulderWidth"];
          rightMedianShoulderWidth.Value = 0;
          var medianKeyWidth = median.ParamsDouble["KeyWidth"];
          medianKeyWidth.Value = 0;
          var medianBarrierTopHeight = median.ParamsDouble["BarrierHeight"];
          medianBarrierTopHeight.Value = 0;
          var medianBarrierMiddleHeight = median.ParamsDouble["BarrierMiddleHeight"];
          medianBarrierMiddleHeight.Value = 0;
          var aCode = "Crown";
          median.Points.Add(3, -0.3, aCode); //for Right lane to latch on
          median.Points.Add(-2, -0.2, aCode);// for left lane to latch on
          return median;
      }&lt;/LI-CODE&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;However as you can see from the below screenshot, now the&amp;nbsp;LaneSuperelevationAOR is hooked to the origin which is wrong. I won't have this problem if I want to set&amp;nbsp;LaneSuperelevationAOR to hook to any of the Points inside the original&amp;nbsp;MedianConstantSlopeWithBarrier point list.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How to fix this issue?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Dec 2024 10:06:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13217801#M816</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2024-12-18T10:06:46Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13247043#M817</link>
      <description>&lt;P&gt;&lt;EM&gt;"However as you can see from the below screenshot..."&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;I can't find the screenshot attached. Can you please share it?&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Tue, 07 Jan 2025 09:55:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13247043#M817</guid>
      <dc:creator>sreeparna_mandal</dc:creator>
      <dc:date>2025-01-07T09:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13248640#M818</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13438733"&gt;@sreeparna_mandal&lt;/a&gt;&amp;nbsp;, as you can see below, the median and the lane overlap&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="crash.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1452158iE7B8534B2DB593E8/image-size/large?v=v2&amp;amp;px=999" role="button" title="crash.jpg" alt="crash.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 01:37:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13248640#M818</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-01-08T01:37:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13250646#M819</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7472042"&gt;@soonhui&lt;/a&gt;&amp;nbsp;I had thought that this approach would work so p1 and p2 (defined as static Point variables) could be used when adding to the assembly.&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;                var aCode = "Crown";
                p1 = median.Points.Add(3, -0.3, aCode); //for Right lane to latch on
                p2 = median.Points.Add(-2, -0.2, aCode);// for left lane to latch on
                p1.IsLoopPoint = true;
                p2.IsLoopPoint = true;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp; But, alas, it did not...the lanes still attach direct to the assembly.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2025 20:48:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13250646#M819</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2025-01-08T20:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13251032#M820</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;, I'm interested to know why you think that by setting the Point.IsLoopPoint to true, it will work? Care to explain?&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 02:03:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13251032#M820</guid>
      <dc:creator>soonhui</dc:creator>
      <dc:date>2025-01-09T02:03:56Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13251089#M821</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7472042"&gt;@soonhui&lt;/a&gt;&amp;nbsp;from the help file for the Point object:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2025-01-08_18-49-37.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1452708iECAF2ACD89A15BF3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2025-01-08_18-49-37.png" alt="2025-01-08_18-49-37.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It just seemed like something that I should try. I don't work with subassemblies/assemblies in code very often so it was just a "let's give this a try" moment.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2025 02:52:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13251089#M821</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2025-01-09T02:52:07Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to specify a custom point to hook to?</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13324775#M822</link>
      <description>&lt;P&gt;The C3D team says-&lt;/P&gt;
&lt;P&gt;"This is as designed. We don't support adding custom points to stock subassemblies or even SAC subassemblies. Although the API succeeds, every time the subassembly is updated (runScript() is called for any operation like parameter value change), we will lose all those new points.&lt;/P&gt;
&lt;P&gt;So for the hook point, because the hook point index (39 for (3, -0.3) here) will not exist after the the update, it will fall back (0, 0)."&lt;/P&gt;</description>
      <pubDate>Tue, 18 Feb 2025 06:16:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/unable-to-specify-a-custom-point-to-hook-to/m-p/13324775#M822</guid>
      <dc:creator>sreeparna_mandal</dc:creator>
      <dc:date>2025-02-18T06:16:45Z</dc:date>
    </item>
  </channel>
</rss>

