<?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 MText match orientation to layout in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/mtext-match-orientation-to-layout/m-p/12153529#M7815</link>
    <description>&lt;P&gt;I have a working code for the mtext match orientation to layout, but it won't set the match orientation to layout in bricscad. Anyone have any working code for the match orientation to layout in bricscad?&lt;/P&gt;&lt;P&gt;The&amp;nbsp;acMText.SetPaperOrientation(true); does not work with bricscad, only works with autocad.&lt;/P&gt;&lt;P&gt;Here is my code:&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;#if BRX_APP
    Document doc = Bricscad.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
#elif ACAD_APP
    Document doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
#endif
    Database acCurDb = doc.Database;
    using (doc.LockDocument())
    {
        using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
        {
            MText acMText = acTrans.GetObject(id, OpenMode.ForWrite, false) as MText;

            ObjectContextManager ocm = acCurDb.ObjectContextManager;
            ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
            if (isAnnotation == true)
            {
                acMText.Annotative = AnnotativeStates.True;
                acMText.SetPaperOrientation(true);
#if BRX_APP
                try
                {
                    acMText.AddContext(occ.CurrentContext);
                }
                catch { }
#elif ACAD_APP
                try
                {
                    ObjectContexts.AddContext(acMText, occ.CurrentContext);
                }
                catch { }
#endif
            }
            else
            {
                acMText.Annotative = AnnotativeStates.False;
                acMText.SetPaperOrientation(false);
            }

            acTrans.Commit();
        }
    }&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 07 Aug 2023 11:58:20 GMT</pubDate>
    <dc:creator>office</dc:creator>
    <dc:date>2023-08-07T11:58:20Z</dc:date>
    <item>
      <title>MText match orientation to layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/mtext-match-orientation-to-layout/m-p/12153529#M7815</link>
      <description>&lt;P&gt;I have a working code for the mtext match orientation to layout, but it won't set the match orientation to layout in bricscad. Anyone have any working code for the match orientation to layout in bricscad?&lt;/P&gt;&lt;P&gt;The&amp;nbsp;acMText.SetPaperOrientation(true); does not work with bricscad, only works with autocad.&lt;/P&gt;&lt;P&gt;Here is my code:&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;#if BRX_APP
    Document doc = Bricscad.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
#elif ACAD_APP
    Document doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
#endif
    Database acCurDb = doc.Database;
    using (doc.LockDocument())
    {
        using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
        {
            MText acMText = acTrans.GetObject(id, OpenMode.ForWrite, false) as MText;

            ObjectContextManager ocm = acCurDb.ObjectContextManager;
            ObjectContextCollection occ = ocm.GetContextCollection("ACDB_ANNOTATIONSCALES");
            if (isAnnotation == true)
            {
                acMText.Annotative = AnnotativeStates.True;
                acMText.SetPaperOrientation(true);
#if BRX_APP
                try
                {
                    acMText.AddContext(occ.CurrentContext);
                }
                catch { }
#elif ACAD_APP
                try
                {
                    ObjectContexts.AddContext(acMText, occ.CurrentContext);
                }
                catch { }
#endif
            }
            else
            {
                acMText.Annotative = AnnotativeStates.False;
                acMText.SetPaperOrientation(false);
            }

            acTrans.Commit();
        }
    }&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 07 Aug 2023 11:58:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mtext-match-orientation-to-layout/m-p/12153529#M7815</guid>
      <dc:creator>office</dc:creator>
      <dc:date>2023-08-07T11:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: MText match orientation to layout</title>
      <link>https://forums.autodesk.com/t5/net-forum/mtext-match-orientation-to-layout/m-p/12161300#M7816</link>
      <description>&lt;P&gt;I found a lisp code how to enable the match orientation to layout and I made a C# code that works both with AutoCAD and BricsCAD.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        /// &amp;lt;summary&amp;gt;
        /// Match orientation to layout.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="paperOrientation"&amp;gt;0 = Disable match orientation to layout. 1 = Enable match orientation to layout&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="dbObj"&amp;gt;Any annotative database object: MText, BlockTableRecord, etc...&amp;lt;/param&amp;gt;
        static void SetPaperOrientation(Database acCurDb, Transaction acTrans, DBObject dbObj, int paperOrientation)
        {
#if ACAD_APP
            if (paperOrientation == 1)
                dbObj.SetPaperOrientation(true);
            else
                dbObj.SetPaperOrientation(false);
#elif BRX_APP
            //This portion of code works with AutoCAD too.
            string regAppName = "AcadAnnoPO";
            ResultBuffer resbuf = dbObj.GetXDataForApplication(regAppName);
            if (resbuf != null)
            {
                TypedValue[] data = resbuf.AsArray();
                for (int i = 0; i &amp;lt; data.Length; i++)
                {
                    TypedValue tv = data[i];
                    if (tv.TypeCode == 1070)
                    {
                        data[i] = new TypedValue(1070, paperOrientation);
                    }
                }
                resbuf = new ResultBuffer(data);
                dbObj.XData = resbuf;
            }
            else
            {
                if (paperOrientation == 1)
                {
                    RegAppTable regAppTable = (RegAppTable)acTrans.GetObject(acCurDb.RegAppTableId, OpenMode.ForRead);
                    if (!regAppTable.Has(regAppName))
                    {
                        using (RegAppTableRecord regAppRecord = new RegAppTableRecord())
                        {
                            regAppRecord.Name = regAppName;
                            regAppTable.Add(regAppRecord);
                            acTrans.AddNewlyCreatedDBObject(regAppRecord, true);
                        }
                    }

                    ResultBuffer rb = new ResultBuffer(new TypedValue(1001, regAppName), new TypedValue(1070, paperOrientation));
                    dbObj.XData = rb;
                }
            }
#endif
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2023 04:32:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/mtext-match-orientation-to-layout/m-p/12161300#M7816</guid>
      <dc:creator>office</dc:creator>
      <dc:date>2023-08-10T04:32:50Z</dc:date>
    </item>
  </channel>
</rss>

