<?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: Getting ComponentManager.Ribbon as null for AutoCAD 2020 in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10630209#M15175</link>
    <description>&lt;P&gt;You should indicate/describe when/how/where your code tries to have access to ComponentManager.Ribbon, ideally by showing your code relevant to the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing the details from you, it is just a wild speculation that your code is loaded and runs at the moment when AutoCAD has not finished its startup, especially the ribbon menu has not been fully loaded. It all depends on how/when your DLL is loaded and how the code runs (as IExtensionApplication, or runs manually...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, when you ask question, try provide as much as information/details possible, if you really want to get meaningful responses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 17 Sep 2021 17:37:00 GMT</pubDate>
    <dc:creator>norman.yuan</dc:creator>
    <dc:date>2021-09-17T17:37:00Z</dc:date>
    <item>
      <title>Getting ComponentManager.Ribbon as null for AutoCAD 2020</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10629845#M15174</link>
      <description>&lt;P&gt;&lt;SPAN&gt;I was trying to create the custom .net autocad plugin, I'm getting ComponentManager.Ribbon as null currently, previously I tried with same line of code, I was able to get RibbonControl Object but it not working now, Can anybody suggest why these is actually happening?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 14:56:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10629845#M15174</guid>
      <dc:creator>veeresh.huvinahalliACK3L</dc:creator>
      <dc:date>2021-09-17T14:56:29Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ComponentManager.Ribbon as null for AutoCAD 2020</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10630209#M15175</link>
      <description>&lt;P&gt;You should indicate/describe when/how/where your code tries to have access to ComponentManager.Ribbon, ideally by showing your code relevant to the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Without knowing the details from you, it is just a wild speculation that your code is loaded and runs at the moment when AutoCAD has not finished its startup, especially the ribbon menu has not been fully loaded. It all depends on how/when your DLL is loaded and how the code runs (as IExtensionApplication, or runs manually...).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, when you ask question, try provide as much as information/details possible, if you really want to get meaningful responses.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Sep 2021 17:37:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10630209#M15175</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2021-09-17T17:37:00Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ComponentManager.Ribbon as null for AutoCAD 2020</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10633670#M15176</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is code snippet, I'm using for creating a plugin in AutoCAD and I have highlighted the line where I'm getting null.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;namespace TestPlugin1&lt;BR /&gt;{&lt;BR /&gt;public class Class1&lt;BR /&gt;{&lt;BR /&gt;[CommandMethod("LoadTestPanel", CommandFlags.NoHistory)]&lt;BR /&gt;public void RibbonPanelCreation()&lt;BR /&gt;{&lt;BR /&gt;&lt;STRONG&gt;var ribbonControl = ComponentManager.Ribbon;// Here I'm getting ribbon Control as NULL&lt;/STRONG&gt;&lt;BR /&gt;AddRibbonTab(ribbonControl);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;public void AddRibbonTab(RibbonControl ribbonControl)&lt;BR /&gt;{&lt;BR /&gt;RibbonTab ribbonTab = new RibbonTab()&lt;BR /&gt;{&lt;BR /&gt;Title = "Test",&lt;BR /&gt;Id = "Tes"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;//Add the Tab&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;ribbonControl.Tabs.Add(ribbonTab);&lt;BR /&gt;}&lt;BR /&gt;catch (System.Exception)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;MessageBox.Show("Ribbon Tab Not Added Successfully");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;AddTabContent(ribbonTab);&lt;/P&gt;&lt;P&gt;ribbonTab.IsActive = true;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;public void AddTabContent(RibbonTab ribbonTab)&lt;BR /&gt;{&lt;BR /&gt;ribbonTab.Panels.Add(this.AddImportFilePanel());&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;private Autodesk.Windows.RibbonPanel AddImportFilePanel()&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;var ribbonPanelSource = new RibbonPanelSource()&lt;BR /&gt;{&lt;BR /&gt;Title = "Test Panel Creation"&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var ribbonPanel = new Autodesk.Windows.RibbonPanel()&lt;BR /&gt;{&lt;BR /&gt;Source = ribbonPanelSource&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;var importButton = CreateRibonButton("Import File", "Import\nFile", true, true, RibbonItemSize.Large, System.Windows.Controls.Orientation.Vertical, "import.png");&lt;/P&gt;&lt;P&gt;if (importButton != null)&lt;BR /&gt;{&lt;BR /&gt;importButton.CommandHandler = new ImportFileHandler();&lt;BR /&gt;ribbonPanelSource.Items.Add(importButton);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return ribbonPanel;&lt;BR /&gt;}&lt;BR /&gt;private RibbonButton CreateRibonButton(string buttonName, string buttonText, bool showText, bool showImage, RibbonItemSize size, System.Windows.Controls.Orientation orientation, string icon)&lt;BR /&gt;{&lt;BR /&gt;var icoUtil = new IconUtility();&lt;BR /&gt;var iconImage = icoUtil.GetIcon(icon);&lt;BR /&gt;var ribbonButton = new RibbonButton&lt;BR /&gt;{&lt;BR /&gt;Name = buttonName,&lt;BR /&gt;ShowText = showText,&lt;BR /&gt;Text = buttonText,&lt;BR /&gt;ShowImage = showImage,&lt;BR /&gt;Orientation = orientation,&lt;BR /&gt;Size = size,&lt;BR /&gt;Image = iconImage&lt;BR /&gt;};&lt;BR /&gt;if (size == RibbonItemSize.Large)&lt;BR /&gt;ribbonButton.LargeImage = iconImage;&lt;/P&gt;&lt;P&gt;return ribbonButton;&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;class IconUtility&lt;BR /&gt;{&lt;BR /&gt;/// &amp;lt;summary&amp;gt;&lt;BR /&gt;/// Method to return bitmap object of the icon&lt;BR /&gt;/// &amp;lt;/summary&amp;gt;&lt;BR /&gt;/// &amp;lt;param name="icon"&amp;gt;icon path&amp;lt;/param&amp;gt;&lt;BR /&gt;/// &amp;lt;returns&amp;gt;bitmap&amp;lt;/returns&amp;gt;&lt;BR /&gt;public BitmapImage GetIcon(string icon)&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;var assembly = Assembly.GetExecutingAssembly();&lt;BR /&gt;var resourcePath = assembly.GetManifestResourceNames().Single(str =&amp;gt; str.Contains(icon));&lt;BR /&gt;var bitmap = new BitmapImage();&lt;BR /&gt;using (var stream = assembly.GetManifestResourceStream(resourcePath))&lt;BR /&gt;{&lt;BR /&gt;bitmap.BeginInit();&lt;BR /&gt;bitmap.StreamSource = stream;&lt;BR /&gt;bitmap.CacheOption = BitmapCacheOption.OnLoad;&lt;BR /&gt;bitmap.EndInit();&lt;BR /&gt;}&lt;BR /&gt;return bitmap;&lt;BR /&gt;}&lt;BR /&gt;catch (Exception ex)&lt;BR /&gt;{&lt;BR /&gt;MessageBox.Show("Exception in getting icon: " + ex.Message.ToString());&lt;BR /&gt;return new BitmapImage();&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Veeresh Huvinahalli&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 08:45:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10633670#M15176</guid>
      <dc:creator>veeresh.huvinahalliACK3L</dc:creator>
      <dc:date>2021-09-20T08:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ComponentManager.Ribbon as null for AutoCAD 2020</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10634789#M15177</link>
      <description>&lt;P&gt;How do you run the command "LoadTestPanel"? Do you run in manually when AutoCAD fully loaded and there is ribbon menu showing? Or you somehow execute the command automatically when/during AutoCAD startup. I mean, if you run the command manually, do that line of code still give you a null pointer to the ComponentManager.Ribbon?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 16:41:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10634789#M15177</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2021-09-20T16:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ComponentManager.Ribbon as null for AutoCAD 2020</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10634900#M15178</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, I have tried manually and I tried&amp;nbsp;&lt;SPAN&gt;executing the command automatically using &lt;STRONG&gt;"PackageContents.xml".&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;&lt;BR /&gt;&amp;lt;ApplicationPackage SchemaVersion="1.0" AutodeskProduct="AutoCAD" Name="TestPlugin1" Description="TestPlugin1" AppVersion="1.0.0" ProductType="Application" Author="TestPlugin1" ProductCode="{FECE6978-C7A1-4381-BF7E-71AD8E213AC4}" UpgradeCode="{FBB07B46-118D-4B8D-8F76-58C257F95F68}"&amp;gt;&lt;BR /&gt;&amp;lt;CompanyDetails Name="TestPlugin1" Email="" Url="" /&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;Components&amp;gt;&lt;BR /&gt;&amp;lt;RuntimeRequirements OS="Win64" Platform="AutoCAD*" SeriesMin="R23.1" SeriesMax="R23.1" /&amp;gt;&lt;BR /&gt;&amp;lt;ComponentEntry AppName="TestPlugin1" ModuleName=".\Contents\Class1.dll"&amp;gt;&lt;BR /&gt;&amp;lt;Commands GroupName="LoadTest"&amp;gt;&lt;BR /&gt;&amp;lt;Command Local="&lt;SPAN&gt;LoadTestPanel&lt;/SPAN&gt;" Global="&lt;SPAN&gt;LoadTestPanel&lt;/SPAN&gt;" StartupCommand="True" /&amp;gt;&lt;BR /&gt;&amp;lt;/Commands&amp;gt;&lt;BR /&gt;&amp;lt;/ComponentEntry&amp;gt;&lt;BR /&gt;&amp;lt;/Components&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/ApplicationPackage&amp;gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 17:23:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10634900#M15178</guid>
      <dc:creator>veeresh.huvinahalliACK3L</dc:creator>
      <dc:date>2021-09-20T17:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Getting ComponentManager.Ribbon as null for AutoCAD 2020</title>
      <link>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10634948#M15179</link>
      <description>&lt;P&gt;Are you saying that even you run the command manually, that line of code still gives you null for ComponentManager.Ribbon? Sorry, you did not make it very clear. I can see it is problematic when you make this command automatically run as StartupCommand: If you want to create custom ribbon item with code on AutoCAD startup, you MUST make sure the RibbonControl has been created by AutoCAD before your code goes ahead to add custom items. The common practice for this task is to handle AutoCAD's Idle event when your DLL loads (say, add Idle event handler in IExtensionApplication.Initialize()). And then in the event handler, test if RibbonControl is null. This topic has been discussed here quite a few times, such as this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/net/custom-menu-and-ribbon-with-code/m-p/10511529#M69850" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/net/custom-menu-and-ribbon-with-code/m-p/10511529#M69850&lt;/A&gt;&amp;nbsp;&lt;/P&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 17:48:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/getting-componentmanager-ribbon-as-null-for-autocad-2020/m-p/10634948#M15179</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2021-09-20T17:48:39Z</dc:date>
    </item>
  </channel>
</rss>

