Hi everyone,
I have created a small plugin in AutoCAD using c# and right now I am using netload to load my dll into AutoCAD.
But I want that when I start my AutoCAD the DLL will automatically load. I tried to create a bundle file including the PackageContents.xml file and place my dll into the bundle folder. But the DLL is not loading automatically.
If anyone has any idea then please help me.
Solved! Go to Solution.
Solved by _gile. Go to Solution.
Solved by _gile. Go to Solution.
Where do you have the bundle folder stored? In one of the areas that AutoCAD looks for them? Your personal area is located at %AppData%\Autodesk\ApplicationPlugins
Hi,
In this reply, an example of minimalist PackageContents.xml file for autoloading a .NET DLL.
Hi, Where I can find this product code and upgrade code? So that I can include them in the PackageContents.xml file?
ProductCode="{83F90232-3CEB-40F0-88BE-2638C843CEA5}" UpgradeCode="{B31D4C65-464B-4460-9E9F-B36D7B1C453A}"
@prem_kumar8SXZJ wrote:
Hi, Where I can find this product code and upgrade code? So that I can include them in the PackageContents.xml file?
ProductCode="{83F90232-3CEB-40F0-88BE-2638C843CEA5}" UpgradeCode="{B31D4C65-464B-4460-9E9F-B36D7B1C453A}"
You do not "find" them, you create them (there's a "Create GUID" in the Visual Studio Tools menu and many other on the web).
ProductCode shoud be changed a each new version. UpgradeCode should never be changed.
Hi I have created a product code using GUID and Created a folder with a .bundle file and also created all the sub folders and PackageContents.xml file and Paste that bundle folder in C:\Program Files (x86)\Autodesk\ApplicationPlugins\Trapeze.bundle this directory, But still, my dll is not loading why?
The 'Trapeze.bundle' was just an example you have to adapt to suit your needs.
Name the .bundle as you need (typically as you project), create new GUIDs for both the ProductCode and the UpgradeCode, change the application Name, Set the SeriesMin and SeriesMax value to the AutoCAD releases you want your app to run on, change the AppName and, for sure, the ModuleName.
You should read this topic and the related references.
Hi, I have made all the changes and when I open AutoCAD it also shows the message "Stretch Utility has been successfully loaded" where Stretch Utility is my Application name. But then again when I give the command to run some functionality that I written in the Dll, It is saying Unknown command. If I use Netload and then use the command everything is working fine. I don't understand what is going on with the bundle file.
<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage
SchemaVersion="1.0"
AppVersion="1.0.0"
ProductCode="{04A0B285-1593-4604-B4B1-714A231770CD}"
Name="Stretch Utility"
AutodeskProduct="AutoCAD"
ProductType="Application">
<Components>
<RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD|AutoCAD*" SeriesMin="R24.3" SeriesMax="R24.3" />
<ComponentEntry
AppName="Stretch Utility"
Version="1.0.0"
ModuleName="./Contents/AutoCAD_3DProject.dll"
LoadOnAutoCADStartup="True">
</ComponentEntry>
</Components>
</ApplicationPackage>
Do not care about your application Status is "Unknown App" in the application manager dialog. This is due to the fact you application is not one from the Autodesk Application Store.
Does your application contains a class which implements IExtensionApplication? If so, your issue may be due to what does the Initialize method because this method is not called in the same context when the application is autoloaded or when it is netloaded.
Yes, my class does implement IExtensionApplication because I am creating a ribbon tab and some buttons. I just removed the code for the ribbon tab and now it is loading perfectly. Thanks.
One more question is If I don't use the IExtensionApplication then how I am going to create a ribbon tab and some buttons? Is it through cuix file or there is any other way?
You can use IExtensionApplication, but you have to take care of the context the Initialize() method is run.
Typically, you just subscribe to the Application.Idle event in the Initialize method and do your stuff in the event handler to ensure the code is not run before AutoCAD completed its own initialization.
Here's a example:
internal class ExtensionApplication : IExtensionApplication
{
public void Initialize()
{
Application.Idle += OnIdle;
}
private void OnIdle(object? sender, EventArgs e)
{
var doc = Application.DocumentManager.MdiActiveDocument;
if (doc != null)
{
Application.Idle -= OnIdle;
try
{
// Do the initialization stuff here.
}
catch (System.Exception ex)
{
doc.Editor.WriteMessage($"\nInitilization error: {ex.Message}");
}
}
}
public void Terminate()
{ }
}
You can also use this ExtensionApplicationAsync abstract class from @ActivistInvestor.
Can't find what you're looking for? Ask the community or share your knowledge.