<?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 add a title and separator in the Tool Palette Manager using C# in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12684837#M4683</link>
    <description>&lt;P&gt;But, so you know an example of what it would be like using Tooltype, to add text or separator&lt;BR /&gt;I think these commands are not useful for ToolType, because both commands you mentioned ask for an image&lt;/P&gt;</description>
    <pubDate>Wed, 03 Apr 2024 18:32:46 GMT</pubDate>
    <dc:creator>artillis_prado</dc:creator>
    <dc:date>2024-04-03T18:32:46Z</dc:date>
    <item>
      <title>How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12679113#M4673</link>
      <description>&lt;P&gt;&lt;SPAN&gt;My code can create a palette and add the PKT files via path.&lt;BR /&gt;I am using the Tool Palette Manager from the AcTcMgd DLL.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="artillis_prado_0-1711989110665.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1344339iF5DAA32F98B30313/image-size/medium?v=v2&amp;amp;px=400" role="button" title="artillis_prado_0-1711989110665.png" alt="artillis_prado_0-1711989110665.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;SPAN&gt;However, I'm unable to add text or a separator via C# code. Does anyone know how to do it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="artillis_prado_1-1711989167770.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1344342iF05948556C67F9E8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="artillis_prado_1-1711989167770.png" alt="artillis_prado_1-1711989167770.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;            [CommandMethod("QSAVEAS")]
            public void QuickSaveAs()
            {
                Document doc = Application.DocumentManager.MdiActiveDocument;
                Editor ed = doc.Editor;
                Database db = doc.Database;

                // If this is the first time run...

                if (_path == "" || _base == "")
                {
                    // Ask the user for a base file location

                    PromptSaveFileOptions opts =
                      new PromptSaveFileOptions(
                        "Select location to save first drawing file"
                      );
                    opts.Filter = "Drawing (*.dwg)|*.dwg";
                    PromptFileNameResult pr =
                      ed.GetFileNameForSave(opts);

                    // Delete the file, if it exists
                    // (may be a problem if the file is in use)

                    if (File.Exists(pr.StringResult))
                    {
                        try
                        {
                            File.Delete(pr.StringResult);
                        }
                        catch { }
                    }

                    if (pr.Status == PromptStatus.OK)
                    {
                        // If a file was selected, and it contains a path...

                        if (pr.StringResult.Contains(pthSep))
                        {
                            // Separate the path from the file name

                            int idx = pr.StringResult.LastIndexOf(pthSep);
                            _path =
                              pr.StringResult.Substring(0, idx);
                            string fullname =
                              pr.StringResult.Substring(idx + 1);

                            // If the path has an extension (this should always
                            // be the case), extract the base file name

                            if (fullname.Contains(extSep))
                            {
                                _base =
                                  fullname.Substring(
                                    0,
                                    fullname.LastIndexOf(extSep)
                                  );

                                // Create folders for our icons and our scripts

                                Directory.CreateDirectory(
                                  _path + pthSep + bmpLoc
                                );
                                Directory.CreateDirectory(
                                  _path + pthSep + scrLoc
                                );
                            }
                        }
                    }
                }

                // Assuming the path and name were set appropriately...

                if (_path != "" &amp;amp;&amp;amp; _base != "")
                {
                    string name = _base;

                    // Add our suffix if not the first time run

                    if (_count &amp;gt; 0)
                        name += sfxSep + _count.ToString();

                    // Our drawing is located in the base path

                    string dwgPath = _path + pthSep + name + dwgExt;

                    // While our script is in a sub-folder

                    string scrPath =
                      _path + pthSep + scrLoc + pthSep + name + scrExt;

                    // Create a dummy script, so we can make sure we pick
                    // up the contents in our dummy execute command

                    File.WriteAllText(
                      scrPath,
                      "This is a dummy script for " + name + "."
                    );

                    // Now we want to save our drawing and use the image
                    // for our tool icon

                    // Using either COM or .NET doesn't generate a
                    // thumbnail in the resultant file (or its Database)

                    // .NET:
                    // db.SaveAs(dwgPath, false, DwgVersion.Current, null);

                    // COM:
                    // AcadDocument adoc = (AcadDocument)doc.AcadDocument;
                    // adoc.SaveAs(dwgPath, AcSaveAsType.acNative, null);

                    // So we'll send commands to the command-line
                    // We'll use LISP, to avoid having to set FILEDIA to 0

                    object ocmd = Application.GetSystemVariable("CMDECHO");
                    string dwgPath2 = dwgPath.Replace(pthSep, lspSep);
                    string scrPath2 = scrPath.Replace(pthSep, lspSep);

                    string c1 =
                      "(setvar \"CMDECHO\" 0)" +
                      "(command \"_.SAVEAS\" \"\" \"" + dwgPath2 + "\")";
                    string c2 =
                      "(setvar \"CMDECHO\" " + ocmd.ToString() + ")" +
                      "(tp-create \"" + name + "\" \"" + scrPath2 + "\")" +
                      "(princ) ";
                    string cmd = c1 + c2;

                    if (cmd.Length &amp;lt;= 255)
                    {
                        doc.SendStringToExecute(cmd, false, false, false);
                    }
                    else
                    {
                        doc.SendStringToExecute(c1 + " ", false, false, false);
                        doc.SendStringToExecute(c2, false, false, false);
                    }

                    // Print a confirmation message for the DWG save
                    // (which actually gets displayed before the queued
                    // string gets executed, but anyway)

                    ed.WriteMessage("\nSaved to: \"" + dwgPath + "\"");

                    _count++;
                }
            }

            // Our LISP-registered continuation function to create a
            // command tool on our tool palette

            [LispFunction("TP-CREATE")]
            public ResultBuffer CreateToolPaletteCommand(
              ResultBuffer rb
            )
            {
                const int RTSTR = 5005;

                Document doc = Application.DocumentManager.MdiActiveDocument;
                Editor ed = doc.Editor;

                if (rb == null)
                {
                    ed.WriteMessage("\nError: too few arguments.");
                }
                else
                {
                    // We're only interested in the first two arguments

                    Array args = rb.AsArray();
                    if (args.Length != 2)
                    {
                        ed.WriteMessage(
                          "\nError: wrong number of arguments."
                        );
                    }
                    else
                    {
                        // First argument is the name, second is the path
                        // to the script

                        TypedValue tv1 = (TypedValue)args.GetValue(0);
                        TypedValue tv2 = (TypedValue)args.GetValue(1);

                        if (tv1 != null &amp;amp;&amp;amp; tv1.TypeCode == RTSTR &amp;amp;&amp;amp;
                            tv2 != null &amp;amp;&amp;amp; tv2.TypeCode == RTSTR)
                        {
                            string name = Convert.ToString(tv1.Value);
                            string lspScrPath = Convert.ToString(tv2.Value);
                            string scrPath =
                              lspScrPath.Replace(lspSep, pthSep);
                            bool success =
                              CreateCommand(doc.Database, name, scrPath);
                              //CreateCommand(doc.Database, name, scrPath);
                              //CreateCommand(doc.Database, name, scrPath);
                        return
                              (success ?
                                new ResultBuffer(
                                  new TypedValue(RTSTR, tv1.Value)
                                )
                                : null);
                        }
                    }
                }
                return null;
            }

            // Function to add a command tool to
            // Function to add a command tool to our tool palette to
            // execute the script

            private bool CreateCommand(
              Database db,
              string name,
              string scrPath
            )
            {
                const string catName = "ScriptCatalog";
                const string palName = "ToolsPalette";

                ToolPaletteManager tpm = ToolPaletteManager.Manager;

                // Get the GUID of our dummy custom tool

                Type t = typeof(DummyTool);
                GuidAttribute ga =
                  (GuidAttribute)t.GetCustomAttributes(
                    typeof(GuidAttribute), false)[0];
                Guid g = new Guid(ga.Value);

                // Instantiate our dummy tool - this will allow us to use
                // its helper functions

                DummyTool tool = new DummyTool();
                Catalog cat;
                Autodesk.AutoCAD.Windows.ToolPalette.Palette pal = null;

            // First we check whether our GUID is in a catalog

            CatalogItem ci = tpm.StockToolCatalogs.Find(g);
                if (ci != null)
                {
                    // If it is, search each catalog for our palette

                    foreach (CatalogItem ci2 in tpm.Catalogs)
                    {
                        for (int i = 0; i &amp;lt; ci2.ChildCount; i++)
                        {
                            CatalogItem ci3 = ci2.GetChild(i);
                            if (ci3 != null &amp;amp;&amp;amp; ci3.Name == palName)
                            {
                                pal = ci3 as Autodesk.AutoCAD.Windows.ToolPalette.Palette;
                                break;
                            }
                        }
                        if (pal != null)
                            break;
                    }
                }

                // If we didn't find our palette, create it

                if (pal == null)
                {
                    cat = tool.CreateStockTool(catName);
                    pal = tool.CreatePalette(cat, palName);
                }

            // To add our command tool instance we need an icon

            List&amp;lt;string&amp;gt; listaPKT = new List&amp;lt;string&amp;gt; { "Ferrovias_Surperestrutura 1", "Ferrovias_InfraEstrutura 1"};
            List&amp;lt;string&amp;gt; listpath = new List&amp;lt;string&amp;gt;() { "C:\\Users\\pc\\music\\file 1.pkt", "C:\\Users\\pc\\music\\file 2.pkt" };

            int cont = 0;
            foreach (string namePKT in listaPKT)
            {
                ImageInfo ii = new ImageInfo();
                ii.Size = new System.Drawing.Size(65, 65);

                // And then we use our dummy tool to create the
                // command tool


                tool.CreateCommandTool(
                  pal,
                  namePKT,
                  ii,
                  "_IMPORTPKT\"" + listpath[cont] + "\""
                );
                cont += 1;
            }
            // Finally we reload the catalogs to display the change

            tpm.LoadCatalogs();

                return true;
            }

            [Guid("3B725500-0451-4081-A1BB-B37CE6A65767")]
            [Tool("MyDummyTool", "IDB_TOOL")]
            [ClassInterface(ClassInterfaceType.AutoDual)]
            public class DummyTool : CustomToolBase
            {

            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 16:42:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12679113#M4673</guid>
      <dc:creator>artillis_prado</dc:creator>
      <dc:date>2024-04-01T16:42:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12680160#M4674</link>
      <description>&lt;P&gt;What release of AutoCAD are you using that forces you to resort to sending lisp Expressions to the command line?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 03:13:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12680160#M4674</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-02T03:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12680475#M4675</link>
      <description>&lt;P&gt;That was a question but it definitely didn't solve your problem. There should be a property named ToolType that can be assigned the value ToolType.Seperator or ToolType.Text.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 06:59:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12680475#M4675</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-02T06:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12681837#M4676</link>
      <description>&lt;P&gt;2024&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 17:12:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12681837#M4676</guid>
      <dc:creator>artillis_prado</dc:creator>
      <dc:date>2024-04-02T17:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682228#M4677</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14570232"&gt;@artillis_prado&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;2024&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Are you sure?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;// Using either COM or .NET doesn't generate a
// thumbnail in the resultant file (or its Database)

// COM:
// AcadDocument adoc = (AcadDocument)doc.AcadDocument;
// adoc.SaveAs(dwgPath, AcSaveAsType.acNative, null);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The above code has not worked since AutoCAD 2012.&amp;nbsp; After that release, there is no AcadDocument property (It was replaced with the GetAcadDocument() extension method).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AutoCAD 2024 doesn't require sending LISP expressions to the command line to execute commands. You can use the Editor's &lt;A href="https://help.autodesk.com/view/OARX/2025/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_EditorInput_Editor_Command_params_object__" target="_blank" rel="noopener"&gt;Command()&lt;/A&gt; method to do that more directly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;About your original problem, to create a separator or text, you have to create an&amp;nbsp;&lt;SPAN&gt;Autodesk.AutoCAD.Windows.ToolPalette.Tool, and set its ToolType&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;property to ToolTip.Seperator or ToolType.Text.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 20:38:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682228#M4677</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-02T20:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682487#M4678</link>
      <description>How do I add it to the palette? My question is how to add it.</description>
      <pubDate>Tue, 02 Apr 2024 22:13:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682487#M4678</guid>
      <dc:creator>artillis_prado</dc:creator>
      <dc:date>2024-04-02T22:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682557#M4679</link>
      <description>&lt;P&gt;First, You should have mentioned that the code you posted is from a 2009 Through The Interface blog post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You add items using the AddChild() method.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 22:53:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682557#M4679</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-02T22:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682664#M4680</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I realized that it accepts catalog as a parameter, and not other parameters I am experienced with the autocad api, so these doubts&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 00:11:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682664#M4680</guid>
      <dc:creator>artillis_prado4J852</dc:creator>
      <dc:date>2024-04-03T00:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682665#M4681</link>
      <description>I realized that it accepts catalog as a parameter, and not other parameters I am experienced with the autocad api, so these doubts</description>
      <pubDate>Wed, 03 Apr 2024 00:11:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682665#M4681</guid>
      <dc:creator>artillis_prado4J852</dc:creator>
      <dc:date>2024-04-03T00:11:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682746#M4682</link>
      <description>&lt;P&gt;CreateTool() and CreateCommandTool() both create and return a Tool object, and adds it to a Palette.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 01:05:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12682746#M4682</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2024-04-03T01:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a title and separator in the Tool Palette Manager using C#</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12684837#M4683</link>
      <description>&lt;P&gt;But, so you know an example of what it would be like using Tooltype, to add text or separator&lt;BR /&gt;I think these commands are not useful for ToolType, because both commands you mentioned ask for an image&lt;/P&gt;</description>
      <pubDate>Wed, 03 Apr 2024 18:32:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-to-add-a-title-and-separator-in-the-tool-palette-manager/m-p/12684837#M4683</guid>
      <dc:creator>artillis_prado</dc:creator>
      <dc:date>2024-04-03T18:32:46Z</dc:date>
    </item>
  </channel>
</rss>

