<?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: how to extract _AcDb.Surfce isolines in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12297735#M7024</link>
    <description>&lt;P&gt;i'm trying to use &lt;EM&gt;_AcDb.NurbSurface&lt;/EM&gt;.&lt;EM&gt;&lt;STRONG&gt;GetIsolineAtU(&lt;/STRONG&gt;&lt;/EM&gt;du&lt;STRONG&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/STRONG&gt; after converting my _AcDb.Surface into NurbSurface using mySurface.ConvertToNurbSurface(),&lt;/P&gt;&lt;P&gt;the problem is i can't figure out how calculate du/dv for&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;GetIsolineAtU&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;/&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;GetIsolineAtV&lt;/EM&gt; &lt;/STRONG&gt;.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Oct 2023 01:10:41 GMT</pubDate>
    <dc:creator>essam-salah</dc:creator>
    <dc:date>2023-10-11T01:10:41Z</dc:date>
    <item>
      <title>how to extract _AcDb.Surfce isolines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12297665#M7023</link>
      <description>&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;is it possible to extract &lt;EM&gt;&lt;STRONG&gt;Autodesk.Autocad.DatabaseServices.Surface&lt;/STRONG&gt;&lt;/EM&gt;&amp;nbsp; isolines and border using .Net ?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 23:58:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12297665#M7023</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2023-10-10T23:58:42Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract _AcDb.Surfce isolines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12297735#M7024</link>
      <description>&lt;P&gt;i'm trying to use &lt;EM&gt;_AcDb.NurbSurface&lt;/EM&gt;.&lt;EM&gt;&lt;STRONG&gt;GetIsolineAtU(&lt;/STRONG&gt;&lt;/EM&gt;du&lt;STRONG&gt;&lt;EM&gt;)&lt;/EM&gt;&lt;/STRONG&gt; after converting my _AcDb.Surface into NurbSurface using mySurface.ConvertToNurbSurface(),&lt;/P&gt;&lt;P&gt;the problem is i can't figure out how calculate du/dv for&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;GetIsolineAtU&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;/&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;GetIsolineAtV&lt;/EM&gt; &lt;/STRONG&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 01:10:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12297735#M7024</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2023-10-11T01:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract _AcDb.Surfce isolines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12299725#M7025</link>
      <description>&lt;P&gt;Have a look at&amp;nbsp;&lt;A href="https://adndevblog.typepad.com/autocad/2014/03/extracting-isolines-from-surface.html" target="_blank" rel="noopener"&gt;this blog post.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It shows how to do it in native ObjectARX. The only potential problem I see is that the managed Surface class may not expose all of the needed apis, which means that you may need to resort to p/Invoke.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 18:39:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12299725#M7025</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2023-10-11T18:39:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract _AcDb.Surfce isolines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12300182#M7026</link>
      <description>&lt;P&gt;You are on the right track. See below two example commands for extracting the isolines (curve object) from an AutoCAD surface.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a rectangle and then converted that rectangle to a plane surface using the PlaneSurf command.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Using the following two commands (U &amp;amp; V) you can extract an isoline by inputting a value. A value of zero is the midpoint of the plane surface. Inputting a positive number goes in one direction while inputting a negative number goes in the other direction. The value inputted is a unit distance from the mid-point, at least in the example of a plane surface.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps get you going in the right direction.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt; &amp;lt;CommandMethod("AcSurfExtractU")&amp;gt;
        Public Sub CmdAcSurfExtractU()
            Dim aDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = aDoc.Database
            Dim ed As Editor = aDoc.Editor

            Dim opt As New PromptEntityOptions(vbCrLf &amp;amp; "Select AutoCAD Surface: ")
            opt.SetRejectMessage(vbCrLf &amp;amp; "Selected entity must be a AutoCAD Surface. Try again.")
            opt.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.Surface), False)

            Dim res As PromptEntityResult = ed.GetEntity(opt)

            If res.Status &amp;lt;&amp;gt; PromptStatus.OK Then Exit Sub

            Using tr As Transaction = db.TransactionManager.StartTransaction
                Dim surf As Autodesk.AutoCAD.DatabaseServices.Surface = tr.GetObject(res.ObjectId, OpenMode.ForRead)
                Dim nurbs As Autodesk.AutoCAD.DatabaseServices.NurbSurface() = surf.ConvertToNurbSurface

                If Not nurbs.Length &amp;gt; 0 Then
                    Exit Sub
                End If

                Dim nurb As Autodesk.AutoCAD.DatabaseServices.NurbSurface = nurbs(0)

                Dim U_dblOpt As New PromptDoubleOptions(vbCrLf &amp;amp; "Enter U Value: ")

                Dim U_dblRes As PromptDoubleResult = ed.GetDouble(U_dblOpt)

                If U_dblRes.Status &amp;lt;&amp;gt; PromptStatus.OK Then
                    Exit Sub
                End If

                Dim blkTblRec As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)

                Dim curves As Curve() = nurb.GetIsolineAtU(U_dblRes.Value)

                For Each crv As Curve In curves
                    blkTblRec.AppendEntity(crv)
                    tr.AddNewlyCreatedDBObject(crv, True)
                Next

                tr.Commit()
            End Using
        End Sub

        &amp;lt;CommandMethod("AcSurfExtractV")&amp;gt;
        Public Sub CmdAcSurfExtractV()
            Dim aDoc As Document = Application.DocumentManager.MdiActiveDocument
            Dim db As Database = aDoc.Database
            Dim ed As Editor = aDoc.Editor

            Dim opt As New PromptEntityOptions(vbCrLf &amp;amp; "Select AutoCAD Surface: ")
            opt.SetRejectMessage(vbCrLf &amp;amp; "Selected entity must be a AutoCAD Surface. Try again.")
            opt.AddAllowedClass(GetType(Autodesk.AutoCAD.DatabaseServices.Surface), False)

            Dim res As PromptEntityResult = ed.GetEntity(opt)

            If res.Status &amp;lt;&amp;gt; PromptStatus.OK Then Exit Sub

            Using tr As Transaction = db.TransactionManager.StartTransaction
                Dim surf As Autodesk.AutoCAD.DatabaseServices.Surface = tr.GetObject(res.ObjectId, OpenMode.ForRead)
                Dim nurbs As Autodesk.AutoCAD.DatabaseServices.NurbSurface() = surf.ConvertToNurbSurface

                If Not nurbs.Length &amp;gt; 0 Then
                    Exit Sub
                End If

                Dim nurb As Autodesk.AutoCAD.DatabaseServices.NurbSurface = nurbs(0)

                Dim V_dblOpt As New PromptDoubleOptions(vbCrLf &amp;amp; "Enter V Value: ")

                Dim V_dblRes As PromptDoubleResult = ed.GetDouble(V_dblOpt)

                If V_dblRes.Status &amp;lt;&amp;gt; PromptStatus.OK Then
                    Exit Sub
                End If

                Dim blkTblRec As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)

                Dim curves As Curve() = nurb.GetIsolineAtV(V_dblRes.Value)

                For Each crv As Curve In curves
                    blkTblRec.AppendEntity(crv)
                    tr.AddNewlyCreatedDBObject(crv, True)
                Next

                tr.Commit()
            End Using
        End Sub&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;</description>
      <pubDate>Wed, 11 Oct 2023 21:49:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12300182#M7026</guid>
      <dc:creator>hippe013</dc:creator>
      <dc:date>2023-10-11T21:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract _AcDb.Surfce isolines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12300260#M7027</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4476837"&gt;@ActivistInvestor&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Have a look at&amp;nbsp;&lt;A href="https://adndevblog.typepad.com/autocad/2014/03/extracting-isolines-from-surface.html" target="_blank" rel="noopener"&gt;this blog post.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It shows how to do it in native ObjectARX. The only potential problem I see is that the managed Surface class may not expose all of the needed apis, which means that you may need to resort to p/Invoke.&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;yes, i already tried to use this blog post, here is my code so far:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// prompt for _AcDbSurface, and get surfId

var db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
using (var tr = db.TransactionManager.StartTransaction())
{
    var dbSurface = (_AcDb.Surface)tr.GetObject(surfId, _AcDb.OpenMode.ForWrite);
    // convert to nurb
    var dbNurbSurfaces = dbSurface.ConvertToNurbSurface();
    if (dbNurbSurfaces.Length &amp;lt; 1)
    {
        return;
    }
    var dbNurbSurface = dbNurbSurfaces[0]; // pNS in original code
    var uIsoDensity = dbSurface.UIsoLineDensity;
    var vIsoDensity = dbSurface.VIsoLineDensity;

    using (var brep = new _AcBr.Brep(dbSurface))
    {
        foreach (var face in brep.Faces)
        {
            var pGeSurface = face.Surface; 

            var intervals = pGeSurface.GetEnvelope();
            var intervalU = intervals[0];
            var intervalV = intervals[1];

            // get min/max bounds 
            var boundMinU = intervalU.LowerBound;
            var boundMaxU = intervalU.UpperBound;
            var boundMinV = intervalV.LowerBound;
            var boundMaxV = intervalV.UpperBound;

            var isClosedInU = pGeSurface.IsClosedInU(tolerance);
            var isClosedInV = pGeSurface.IsClosedInV(tolerance);
            var paramIncrU = (boundMaxU - boundMinU) / (isClosedInU ? uIsoDensity : (uIsoDensity + 1));
            var paramIncrV = (boundMaxV - boundMinV) / (isClosedInV ? vIsoDensity : (vIsoDensity + 1));

            var ucMax = isClosedInU ? uIsoDensity : uIsoDensity + 2;
            int vcMax = isClosedInV ? vIsoDensity : vIsoDensity + 2;

            var paramU = boundMinU;

            for (int uc = 0; uc &amp;lt; ucMax; uc++)
            {
                double paramV = boundMinV;
                for (int vc = 0; vc &amp;lt; vcMax; vc++)
                {
                    // u lines
                    var uIsoLines = dbNurbSurface.GetIsolineAtU(paramU);
                    foreach (var uCurve in uIsoLines)
                    {
                        uCurve.ColorIndex = 1;
                        // Add uCurve to Current drawing
                    }
                    // v lines
                    var vIsoLines = dbNurbSurface.GetIsolineAtV(paramV);
                    foreach (var vCurve in vIsoLines)
                    {
                        vCurve.ColorIndex = 2;
                        // Add vCurve to Current drawing
                    }
                    paramV += paramIncrV;
                }
                paramU += paramIncrU;
            }

        } // foreach face end
    } // brep end

    // apply changes
    tr.Commit();
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but it doesn't work, it always drawy a 96 Spline as straight lines of length 0.095 at origin for every surface i select,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 22:31:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12300260#M7027</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2023-10-11T22:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract _AcDb.Surfce isolines</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12306453#M7028</link>
      <description>&lt;P&gt;Just for kicks, I copied the C++ code from the original blog post and &lt;A href="https://chat.openai.com/share/8c9dc892-8a4c-4a45-bef6-afd604df36e4" target="_blank" rel="noopener"&gt;asked ChatGPT to convert it to C#&lt;/A&gt;&amp;nbsp;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't tell you if works, but it looks as though it can at least be useful for reducing some typing.&lt;/P&gt;</description>
      <pubDate>Sat, 14 Oct 2023 20:17:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-extract-acdb-surfce-isolines/m-p/12306453#M7028</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2023-10-14T20:17:55Z</dc:date>
    </item>
  </channel>
</rss>

