<?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: Is there a way to define commands in batches? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301815#M12324</link>
    <description>&lt;P&gt;Thanks for your reply, the Autodesk.AutoCAD.Internal.Utils.AddCommand() method is public static void AddCommand(string cmdGroupName, string cmdGlobalName, string cmdLocalName, CommandFlags cmdFlags, CommandCallback func), the fifth parameter method of the method is &lt;SPAN&gt;just a delegate that takes no arguments and returns void.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public delegate void CommandCallback();&lt;/LI-CODE&gt;&lt;P&gt;so that the command name I define is still not associated with the block name. Is there any other way to achieve this? Meanwhile I'm trying to find other solutions.&lt;/P&gt;</description>
    <pubDate>Sun, 17 Jul 2022 02:34:57 GMT</pubDate>
    <dc:creator>1039574776</dc:creator>
    <dc:date>2022-07-17T02:34:57Z</dc:date>
    <item>
      <title>Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301088#M12322</link>
      <description>&lt;P&gt;Hello everyone, I have an amazing idea&lt;span class="lia-unicode-emoji" title=":rolling_on_the_floor_laughing:"&gt;🤣&lt;/span&gt;. Is it possible to define commands in batches based on a list of block names. Is this possible? Like the code example below, I know, it doesn't work correctly, so would like to try to get help to implement this idea, thanks in advance.&lt;/P&gt;&lt;P&gt;1.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        [CommandMethod("SetCommands")]
        public static void SetCommands()
        {
            List&amp;lt;string&amp;gt; commandList = new List&amp;lt;string&amp;gt;()
            {
                "CMD1",
                "CMD2",
                "CMD3",
                "CMD4",
                "CMD5",
                "CMD6"
            };
            CommandMethods(commandList);
        }&lt;/LI-CODE&gt;&lt;P&gt;2.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static void CommandMethods(List&amp;lt;string&amp;gt; commandList)
        {
            foreach (string globalName in commandList)
            {
                [CommandMethod(globalName)]
                CreateInsertBlockrefence(globalName);
            }
        }
        public static ObjectId CreateInsertBlockrefence(string blockName)
        {
            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database acCurDb = acDoc.Database;
            Editor ed=acDoc.Editor;
            Point3d postion = ed.GetPoint("\nSelect a point:").Value;
            using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
            {
                BlockTable acBlkTbl;
                acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
                
                if (!acBlkTbl.Has(blockName)) return ObjectId.Null; 
                
                BlockTableRecord acBlkTblRec;
                acBlkTblRec = acTrans.GetObject(acCurDb.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
                BlockReference acBlk;
                
                ObjectId btrId = acBlkTbl[blockName];
                
                BlockTableRecord record = btrId.GetObject(OpenMode.ForRead) as BlockTableRecord;
                
                acBlk = new BlockReference(postion, acBlkTbl[blockName]);
                acBlkTblRec.AppendEntity(acBlk);
                
                acCurDb.TransactionManager.AddNewlyCreatedDBObject(acBlk, true);
                acTrans.Commit();
                return acBlk.ObjectId;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 11:19:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301088#M12322</guid>
      <dc:creator>1039574776</dc:creator>
      <dc:date>2022-07-16T11:19:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301121#M12323</link>
      <description>&lt;P&gt;One surely can "define" command dynamically with code with this method:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Autodesk.AutoCAD.Internal.Utils.AddCommand()&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in acmgd.dll&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HTH&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Jul 2022 11:59:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301121#M12323</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2022-07-16T11:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301815#M12324</link>
      <description>&lt;P&gt;Thanks for your reply, the Autodesk.AutoCAD.Internal.Utils.AddCommand() method is public static void AddCommand(string cmdGroupName, string cmdGlobalName, string cmdLocalName, CommandFlags cmdFlags, CommandCallback func), the fifth parameter method of the method is &lt;SPAN&gt;just a delegate that takes no arguments and returns void.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public delegate void CommandCallback();&lt;/LI-CODE&gt;&lt;P&gt;so that the command name I define is still not associated with the block name. Is there any other way to achieve this? Meanwhile I'm trying to find other solutions.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 02:34:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301815#M12324</guid>
      <dc:creator>1039574776</dc:creator>
      <dc:date>2022-07-17T02:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301822#M12325</link>
      <description>&lt;P&gt;Does this help ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/utils-addcommand-function-with-params/td-p/4758899" target="_blank"&gt;https://forums.autodesk.com/t5/net/utils-addcommand-function-with-params/td-p/4758899&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Kerry&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 02:48:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301822#M12325</guid>
      <dc:creator>kerry_w_brown</dc:creator>
      <dc:date>2022-07-17T02:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301906#M12326</link>
      <description>&lt;P&gt;Thanks also, I looked up this link and it wasn't what I was looking for. I want to pass parameters into the method, so that the command name is consistent with the block name, that is, the command name is the block name, so that commands are defined in batches according to all block names.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 05:20:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11301906#M12326</guid>
      <dc:creator>1039574776</dc:creator>
      <dc:date>2022-07-17T05:20:01Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11302062#M12327</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11394263"&gt;@1039574776&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;have you tried to use&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;Autodesk.AutoCAD.Internal.Utils.GetLastCommandLines() ?&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 09:43:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11302062#M12327</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2022-07-17T09:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11302131#M12328</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;Thanks a lot, after debugging&amp;nbsp;，combined with Autodesk.AutoCAD.Internal.Utils.AddCommand() and Autodesk.AutoCAD.Internal.Utils.GetLastCommandLines(), exactly what I expected, cheers! This link has its usage example code, hope it will be more helpful to others who need it.&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/catching-command-window-output-with-net-api/m-p/9023171" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/net/catching-command-window-output-with-net-api/m-p/9023171&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 11:44:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11302131#M12328</guid>
      <dc:creator>1039574776</dc:creator>
      <dc:date>2022-07-17T11:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to define commands in batches?</title>
      <link>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11302156#M12329</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/11394263"&gt;@1039574776&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3650456"&gt;@essam-salah&lt;/a&gt;&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;Thanks a lot, after debugging&amp;nbsp;，combined with Autodesk.AutoCAD.Internal.Utils.AddCommand() and Autodesk.AutoCAD.Internal.Utils.GetLastCommandLines(), exactly what I expected, cheers! ..&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;glad you your problem solved.&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2022 12:16:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/is-there-a-way-to-define-commands-in-batches/m-p/11302156#M12329</guid>
      <dc:creator>essam-salah</dc:creator>
      <dc:date>2022-07-17T12:16:06Z</dc:date>
    </item>
  </channel>
</rss>

