<?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: Extract Elevation from Surface by X &amp;amp; Y Coordinates in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/13280935#M21679</link>
    <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for that code!&amp;nbsp; About two decades ago we had a program by Schreiber called Quicksurf which allowed you to create a surface from masspoints and breaklines and you could access the elevations with a simple Quicksurf provided lisp routine.&amp;nbsp; Quicksurf went out of support about a decade ago.&amp;nbsp; I had a lisp routine for making a tabulation of the DZ's between photogrammetric C3D topo and field check shots.&amp;nbsp; The three lines of code you provided allowed me to bring this back to life.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;</description>
    <pubDate>Fri, 24 Jan 2025 21:52:52 GMT</pubDate>
    <dc:creator>LarryGrube</dc:creator>
    <dc:date>2025-01-24T21:52:52Z</dc:date>
    <item>
      <title>Extract Elevation from Surface by X &amp; Y Coordinates</title>
      <link>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8942804#M21675</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write a function to extract elevation from tinsurface from x &amp;amp; y coordinates. I've written following code but it's giving error and I'm not able to solve it.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [LispFunction("SURFELEV")]
        public object GETSURFACEELEVATION (ResultBuffer resbuf)
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Database db = Application.DocumentManager.MdiActiveDocument.Database;
            TypedValue[] args = resbuf.AsArray();
            TinSurface surf = args[0];
            double PointX = Convert.ToDouble(((TypedValue)args.GetValue(1)).Value);
            double PointY = Convert.ToDouble(((TypedValue)args.GetValue(2)).Value);
            double z = surf.FindElevationAtXY(PointX, PointY);
            return z;
        }&lt;/PRE&gt;&lt;P&gt;my lisp function will be:&lt;/P&gt;&lt;PRE&gt;(SurfElev &amp;lt;SurfaceEntity&amp;gt; &amp;lt;XCoord&amp;gt; &amp;lt;YCoord&amp;gt;)&lt;/PRE&gt;&lt;P&gt;Thanks &amp;amp; Regards,&lt;/P&gt;&lt;P&gt;Satish&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 12:19:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8942804#M21675</guid>
      <dc:creator>Satish_Rajdev</dc:creator>
      <dc:date>2019-08-01T12:19:19Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Elevation from Surface by X &amp; Y Coordinates</title>
      <link>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8942932#M21676</link>
      <description>&lt;P&gt;By saying "it's giving error...", you should have provide more details, such as when the said error raised, and what was the error message, so that others do not have to do the guess game&amp;nbsp;&lt;img id="manmad" class="emoticon emoticon-manmad" src="https://forums.autodesk.com/i/smilies/16x16_man-mad.png" alt="Man Mad" title="Man Mad" /&gt; .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But let me try to guess: the C# code probably does not pass compiling here:&lt;/P&gt;
&lt;PRE&gt;            TypedValue[] args = resbuf.AsArray();
            TinSurface surf = args[0];&lt;/PRE&gt;
&lt;P&gt;because surf is type of TinSurface of Civil3D, while arg[0] is a type of TypedValue. Thus the code will not compile.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your Lisp function call, you did not explicitly say what data type the argument &amp;lt;SurfaceEntity&amp;gt; is, but likely, it is the surface entity's ObjectId. so, the arg[0] as TypedValue should be something like (LispDataType.ObjectId, [id]). Therefore, in your C# code, you should use a Transaction to open the TinSurface with the passed-in ObjectId. better yet, you may want to first make should it is ObjectId. Something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;var args = resbuf.AsArray();&lt;/P&gt;
&lt;P&gt;if (args.Length == 3)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;if (args[0].TypeCode == ListDataType )&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var id=(ObjectId)args[0].Value;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//Then you can open the Entity with this ObjectId as TinSurface&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// You may also want to test ObjectId.ObjectClass.DxfName to make sure&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// the entity is TinSurface before you open it in transaction&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;else&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // The first piece of data is not an objectId, thus, cannot continue&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;}&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;else&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;//The passed-in argument is not good as expected (must be 3 pieces of data)&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 01 Aug 2019 13:11:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8942932#M21676</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2019-08-01T13:11:29Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Elevation from Surface by X &amp; Y Coordinates</title>
      <link>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8946711#M21677</link>
      <description>&lt;P&gt;Why create a LispFunction for this? You can do this in lisp already, for example:&lt;/P&gt;
&lt;PRE&gt;(setq entpick (entsel "\nSelect a surface: "))
(setq surf (vlax-ename-&amp;gt;vla-object (car entpick)))
(setq elev (vlax-invoke surf 'findelevationatxy (car (last entpick)) (cadr (last entpick))))&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Aug 2019 17:36:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8946711#M21677</guid>
      <dc:creator>Jeff_M</dc:creator>
      <dc:date>2019-08-03T17:36:46Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Elevation from Surface by X &amp; Y Coordinates</title>
      <link>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8949173#M21678</link>
      <description>&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921" target="_self"&gt;&lt;SPAN class="login-bold"&gt;@norman.yuan&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've made changes as per your comments and it working beautifully for me now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much for great explanation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/32637"&gt;@Jeff_M&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank for the help but I'm already aware of this and using this code from last 2 years but while working on large drawings lisp gets slower and that's why I've written my lisp into c# where it takes few seconds to perform operation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Aug 2019 17:27:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/8949173#M21678</guid>
      <dc:creator>Satish_Rajdev</dc:creator>
      <dc:date>2019-08-05T17:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extract Elevation from Surface by X &amp; Y Coordinates</title>
      <link>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/13280935#M21679</link>
      <description>&lt;P&gt;Jeff,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for that code!&amp;nbsp; About two decades ago we had a program by Schreiber called Quicksurf which allowed you to create a surface from masspoints and breaklines and you could access the elevations with a simple Quicksurf provided lisp routine.&amp;nbsp; Quicksurf went out of support about a decade ago.&amp;nbsp; I had a lisp routine for making a tabulation of the DZ's between photogrammetric C3D topo and field check shots.&amp;nbsp; The three lines of code you provided allowed me to bring this back to life.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Much appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Larry&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 21:52:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/extract-elevation-from-surface-by-x-amp-y-coordinates/m-p/13280935#M21679</guid>
      <dc:creator>LarryGrube</dc:creator>
      <dc:date>2025-01-24T21:52:52Z</dc:date>
    </item>
  </channel>
</rss>

