<?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 Convert a Lisp code to C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11240862#M12649</link>
    <description>&lt;P&gt;Hi Guy.&lt;BR /&gt;I have a Twist lisp attached below.&lt;BR /&gt;I would like to convert this Lisp to C#.&lt;BR /&gt;Thank you so much.&lt;/P&gt;</description>
    <pubDate>Fri, 17 Jun 2022 02:15:08 GMT</pubDate>
    <dc:creator>binhnguyen1202</dc:creator>
    <dc:date>2022-06-17T02:15:08Z</dc:date>
    <item>
      <title>Convert a Lisp code to C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11240862#M12649</link>
      <description>&lt;P&gt;Hi Guy.&lt;BR /&gt;I have a Twist lisp attached below.&lt;BR /&gt;I would like to convert this Lisp to C#.&lt;BR /&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2022 02:15:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11240862#M12649</guid>
      <dc:creator>binhnguyen1202</dc:creator>
      <dc:date>2022-06-17T02:15:08Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Lisp code to C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11241847#M12650</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a way but it do not handle RText objects because they're not exposed to the .NET API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("TW", CommandFlags.NoPaperSpace)]
        public static void TwistView()
        {
            var doc = Application.DocumentManager.MdiActiveDocument;
            var db = doc.Database;
            var ed = doc.Editor;
            using (var tr = db.TransactionManager.StartTransaction())
            {
                var pao = new PromptAngleOptions("\nSpecify the twistview angle or [Block angle/Line angle/Text angle]", "Block Line Text");
                pao.AllowNone = false;
                var par = ed.GetAngle(pao);
                double angle = 0.0;
                switch (par.Status)
                {
                    case PromptStatus.Keyword:
                        switch (par.StringResult)
                        {
                            case "Block":
                                while (true)
                                {
                                    var peo = new PromptEntityOptions("\nSelect block: ");
                                    peo.SetRejectMessage("\nSelected object is not a block.");
                                    peo.AddAllowedClass(typeof(BlockReference), true);
                                    var per = ed.GetEntity(peo);
                                    if (per.Status == PromptStatus.Cancel)
                                    {
                                        return;
                                    }
                                    if (per.Status == PromptStatus.OK)
                                    {
                                        var br = (BlockReference)tr.GetObject(per.ObjectId, OpenMode.ForRead);
                                        angle = br.Rotation;
                                        break;
                                    }
                                }
                                break;
                            case "Line":
                                while (true)
                                {
                                    var peo = new PromptEntityOptions("\nSelect line: ");
                                    peo.SetRejectMessage("\nSelected object is not a line.");
                                    peo.AddAllowedClass(typeof(Line), true);
                                    var per = ed.GetEntity(peo);
                                    if (per.Status == PromptStatus.Cancel)
                                    {
                                        return;
                                    }
                                    if (per.Status == PromptStatus.OK)
                                    {
                                        var line = (Line)tr.GetObject(per.ObjectId, OpenMode.ForRead);
                                        var pt = per.PickedPoint.TransformBy(ed.CurrentUserCoordinateSystem);
                                        angle = pt.DistanceTo(line.EndPoint) &amp;lt; pt.DistanceTo(line.StartPoint) ?
                                            Vector3d.XAxis.GetAngleTo(line.EndPoint - line.StartPoint, Vector3d.ZAxis) :
                                            Vector3d.XAxis.GetAngleTo(line.StartPoint - line.EndPoint, Vector3d.ZAxis);
                                        break;
                                    }
                                }
                                break;
                            case "Text":
                            default:
                                while (true)
                                {
                                    var peo = new PromptEntityOptions("\nSelect text: ");
                                    peo.SetRejectMessage("\nSelected object is not a text, mtext, attribute reference or definition.");
                                    peo.AddAllowedClass(typeof(DBText), false);
                                    peo.AddAllowedClass(typeof(MText), true);
                                    var per = ed.GetEntity(peo);
                                    if (per.Status == PromptStatus.Cancel)
                                    {
                                        return;
                                    }
                                    if (per.Status == PromptStatus.OK)
                                    {
                                        if (per.ObjectId.ObjectClass.DxfName == "MTEXT")
                                        {
                                            var mtext = (MText)tr.GetObject(per.ObjectId, OpenMode.ForRead);
                                            angle = mtext.Rotation;
                                        }
                                        else
                                        {
                                            var text = (DBText)tr.GetObject(per.ObjectId, OpenMode.ForRead);
                                            angle = text.Rotation;
                                        }
                                        break;
                                    }
                                    break;
                                }
                                break;
                        }
                        break;
                    case PromptStatus.OK:
                        angle = par.Value;
                        break;
                    default:
                        return;
                }
                using (ViewTableRecord view = ed.GetCurrentView())
                {
                    var center = new Point3d(view.CenterPoint.X, view.CenterPoint.Y, 0.0)
                        .TransformBy(
                        Matrix3d.Rotation(-view.ViewTwist, view.ViewDirection, view.Target) *
                        Matrix3d.Displacement(view.Target.GetAsVector()) *
                        Matrix3d.PlaneToWorld(view.ViewDirection));
                    view.ViewTwist = -angle;
                    center = center.TransformBy(
                        Matrix3d.WorldToPlane(view.ViewDirection) *
                        Matrix3d.Displacement(view.Target.GetAsVector().Negate()) *
                        Matrix3d.Rotation(view.ViewTwist, view.ViewDirection, view.Target));
                    view.CenterPoint = new Point2d(center.X, center.Y);
                    ed.SetCurrentView(view);
                }
                Application.SetSystemVariable("SnapAng", angle);
                tr.Commit();
            }
        }&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 17 Jun 2022 13:33:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11241847#M12650</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2022-06-17T13:33:53Z</dc:date>
    </item>
    <item>
      <title>Re: Convert a Lisp code to C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11243071#M12651</link>
      <description>Thank you so so much _gile.&lt;BR /&gt;</description>
      <pubDate>Sat, 18 Jun 2022 03:34:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/convert-a-lisp-code-to-c/m-p/11243071#M12651</guid>
      <dc:creator>binhnguyen1202</dc:creator>
      <dc:date>2022-06-18T03:34:51Z</dc:date>
    </item>
  </channel>
</rss>

