.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to autoload a dll file in AutoCAD 2024?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
luckyboy82292
629 Views, 7 Replies

How to autoload a dll file in AutoCAD 2024?

luckyboy82292
Enthusiast
Enthusiast

Hi everyone,

Is there a way to autoload a DLL file at startup? I’ve seen various methods online, but I’m looking for a neat and clean solution that works effectively. Any guidance on this would be greatly appreciated.

Thank you!

0 Likes

How to autoload a dll file in AutoCAD 2024?

Hi everyone,

Is there a way to autoload a DLL file at startup? I’ve seen various methods online, but I’m looking for a neat and clean solution that works effectively. Any guidance on this would be greatly appreciated.

Thank you!

7 REPLIES 7
Message 2 of 8
_gile
in reply to: luckyboy82292

_gile
Mentor
Mentor

Hi,

IMHO, the "neatest and cleanest" way is to use the auto loader mechanism with a .bundle folder in some ApplicationPlugins directory. See this section of the documentation and the related topics.

But you can also load the DLL via AutoLISP or the registry (see this topic).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

Hi,

IMHO, the "neatest and cleanest" way is to use the auto loader mechanism with a .bundle folder in some ApplicationPlugins directory. See this section of the documentation and the related topics.

But you can also load the DLL via AutoLISP or the registry (see this topic).



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 8
luckyboy82292
in reply to: _gile

luckyboy82292
Enthusiast
Enthusiast
Thanks for the reply. Can we set the LISP file to dynamically pick the path where it was loaded at startup? I want the path to be set automatically in the LISP file without having to manually update it every time I move the application to a different PC or laptop. Is there a way to make the LISP file determine its own path dynamically and set the application path accordingly?
0 Likes

Thanks for the reply. Can we set the LISP file to dynamically pick the path where it was loaded at startup? I want the path to be set automatically in the LISP file without having to manually update it every time I move the application to a different PC or laptop. Is there a way to make the LISP file determine its own path dynamically and set the application path accordingly?
Message 4 of 8
_gile
in reply to: luckyboy82292

_gile
Mentor
Mentor

If you want to netload your plugin via AutoLISP, you should add the following LISP expression (after replacing "Plugin.dll" with your DLL file name) to a file name "acad.lsp" and save is as the "Plugin.dll" file in some AutoCAD search path directory (create the "acad.lsp" file if it does not already exists).

 

((lambda (f)
   (if f
     (command-s "netload" f)
     (prompt "DLL file not found")
   )
 )
  (findfile "MyPlugin.dll")
)

 

That said, IMHO, using a .bundle folder in some ApplicationPlugins directory should be "neater and cleaner".

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes

If you want to netload your plugin via AutoLISP, you should add the following LISP expression (after replacing "Plugin.dll" with your DLL file name) to a file name "acad.lsp" and save is as the "Plugin.dll" file in some AutoCAD search path directory (create the "acad.lsp" file if it does not already exists).

 

((lambda (f)
   (if f
     (command-s "netload" f)
     (prompt "DLL file not found")
   )
 )
  (findfile "MyPlugin.dll")
)

 

That said, IMHO, using a .bundle folder in some ApplicationPlugins directory should be "neater and cleaner".

 

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 5 of 8
luckyboy82292
in reply to: _gile

luckyboy82292
Enthusiast
Enthusiast

Actually, I am trying the .bundle method, but some errors occur.

@echo off
setlocal

set BundlePath=$(TargetDir)Convert3DPoly.bundle\Contents\Windows
mkdir %BundlePath%
set BundleInfo=$(TargetDir)Convert3DPoly.bundle\Contents\BundleInfo.xml
echo %BundleInfo%


copy /Y $(TargetPath) %BundlePath%\Convert3DPoly.dll
echo ^<?xml version="1.0" encoding="utf-8"?^> > %BundleInfo%
echo ^<Bundle^> >> %BundleInfo%
echo ^  <Assembly^> >> %BundleInfo%
echo ^    <Name>Convert3DPoly</Name^> >> %BundleInfo%
echo ^    <Description>Convert 3D Polylines in AutoCAD</Description^> >> %BundleInfo%
echo ^    <Version>1.0.0.0</Version^> >> %BundleInfo%
echo ^    <AssemblyPath>Convert3DPoly.dll</AssemblyPath^> >> %BundleInfo%
echo ^  </Assembly^> >> %BundleInfo%
echo ^</Bundle^> >> %BundleInfo%

endlocal

Here is the code for a 'post-build event command line.' However, when I rebuild the application, I get the following error: '1> The filename, directory name, or volume label syntax is incorrect.' I hope this helps you understand the issue.

0 Likes

Actually, I am trying the .bundle method, but some errors occur.

@echo off
setlocal

set BundlePath=$(TargetDir)Convert3DPoly.bundle\Contents\Windows
mkdir %BundlePath%
set BundleInfo=$(TargetDir)Convert3DPoly.bundle\Contents\BundleInfo.xml
echo %BundleInfo%


copy /Y $(TargetPath) %BundlePath%\Convert3DPoly.dll
echo ^<?xml version="1.0" encoding="utf-8"?^> > %BundleInfo%
echo ^<Bundle^> >> %BundleInfo%
echo ^  <Assembly^> >> %BundleInfo%
echo ^    <Name>Convert3DPoly</Name^> >> %BundleInfo%
echo ^    <Description>Convert 3D Polylines in AutoCAD</Description^> >> %BundleInfo%
echo ^    <Version>1.0.0.0</Version^> >> %BundleInfo%
echo ^    <AssemblyPath>Convert3DPoly.dll</AssemblyPath^> >> %BundleInfo%
echo ^  </Assembly^> >> %BundleInfo%
echo ^</Bundle^> >> %BundleInfo%

endlocal

Here is the code for a 'post-build event command line.' However, when I rebuild the application, I get the following error: '1> The filename, directory name, or volume label syntax is incorrect.' I hope this helps you understand the issue.

Message 6 of 8
luckyboy82292
in reply to: _gile

luckyboy82292
Enthusiast
Enthusiast

I have corrected the 'post-build event command line' code.

 

@echo off
setlocal

set BundlePath=$(TargetDir)Convert3DPoly.bundle\Contents\Windows
mkdir %BundlePath%
set BundleInfo=$(TargetDir)Convert3DPoly.bundle\Contents\BundleInfo.xml
echo %BundleInfo%


copy /Y $(TargetPath) %BundlePath%\Convert3DPoly.dll
echo ^<?xml version="1.0" encoding="utf-8"?^> > %BundleInfo%
echo ^<Bundle^> >> %BundleInfo%
echo ^  ^<Assembly^> >> %BundleInfo%
echo ^    ^<Name^>Convert3DPoly^</Name^> >> %BundleInfo%
echo ^    ^<Description^>Convert 3D Polylines in AutoCAD^</Description^> >> %BundleInfo%
echo ^    ^<Version^>1.0.0.0^</Version^> >> %BundleInfo%
echo ^    ^<AssemblyPath^>Convert3DPoly.dll^</AssemblyPath^> >> %BundleInfo%
echo ^  ^</Assembly^> >> %BundleInfo%
echo ^</Bundle^> >> %BundleInfo%

endlocal

 

But I still don't know how to use it now or where to put it so that it can be loaded at startup. A step-by-step guide would be greatly appreciated.

0 Likes

I have corrected the 'post-build event command line' code.

 

@echo off
setlocal

set BundlePath=$(TargetDir)Convert3DPoly.bundle\Contents\Windows
mkdir %BundlePath%
set BundleInfo=$(TargetDir)Convert3DPoly.bundle\Contents\BundleInfo.xml
echo %BundleInfo%


copy /Y $(TargetPath) %BundlePath%\Convert3DPoly.dll
echo ^<?xml version="1.0" encoding="utf-8"?^> > %BundleInfo%
echo ^<Bundle^> >> %BundleInfo%
echo ^  ^<Assembly^> >> %BundleInfo%
echo ^    ^<Name^>Convert3DPoly^</Name^> >> %BundleInfo%
echo ^    ^<Description^>Convert 3D Polylines in AutoCAD^</Description^> >> %BundleInfo%
echo ^    ^<Version^>1.0.0.0^</Version^> >> %BundleInfo%
echo ^    ^<AssemblyPath^>Convert3DPoly.dll^</AssemblyPath^> >> %BundleInfo%
echo ^  ^</Assembly^> >> %BundleInfo%
echo ^</Bundle^> >> %BundleInfo%

endlocal

 

But I still don't know how to use it now or where to put it so that it can be loaded at startup. A step-by-step guide would be greatly appreciated.

Message 7 of 8

luckyboy82292
Enthusiast
Enthusiast
Accepted solution

My issue has been resolved. I researched and used ChatGPT, and I found that AutoCAD 2024 only works with the 'PackageContents.xml' file structure.

 

Here's the recommended bundle folder structure:

Mylibfiles.bundle
|
|--> PackageContents.xml
|
|--> Contents
        |
        |--> Windows
                |
                |--> Put lib files here

 

In the 'PackageContents.xml' file, use the following content:

 

<?xml version="1.0" encoding="UTF-8"?>
<ApplicationPackage SchemaVersion="1.0" 
Name="MyLibFiles" 
AppVersion="1.0.0" 
Author="xyz"
Description="Multiple Commands" >

  <Components>
    <RuntimeRequirements OS="Win64" SeriesMin="R19.0" />
    
    <ComponentEntry AppName="mylib1" 
                    ModuleName="./Contents/Windows/mylib1.dll" 
                    AppDescription="put any description here" 
                    LoadOnAutoCADStartup="True">
    </ComponentEntry>

	<ComponentEntry AppName="mylib2" 
                    ModuleName="./Contents/Windows/mylib2.dll" 
                    AppDescription="put any description here" 
                    LoadOnAutoCADStartup="True">
    </ComponentEntry>

  </Components>
</ApplicationPackage>

 

You can add more files to the 'Windows' folder and update the 'PackageContents.xml' file accordingly. I hope this helps!

0 Likes

My issue has been resolved. I researched and used ChatGPT, and I found that AutoCAD 2024 only works with the 'PackageContents.xml' file structure.

 

Here's the recommended bundle folder structure:

Mylibfiles.bundle
|
|--> PackageContents.xml
|
|--> Contents
        |
        |--> Windows
                |
                |--> Put lib files here

 

In the 'PackageContents.xml' file, use the following content:

 

<?xml version="1.0" encoding="UTF-8"?>
<ApplicationPackage SchemaVersion="1.0" 
Name="MyLibFiles" 
AppVersion="1.0.0" 
Author="xyz"
Description="Multiple Commands" >

  <Components>
    <RuntimeRequirements OS="Win64" SeriesMin="R19.0" />
    
    <ComponentEntry AppName="mylib1" 
                    ModuleName="./Contents/Windows/mylib1.dll" 
                    AppDescription="put any description here" 
                    LoadOnAutoCADStartup="True">
    </ComponentEntry>

	<ComponentEntry AppName="mylib2" 
                    ModuleName="./Contents/Windows/mylib2.dll" 
                    AppDescription="put any description here" 
                    LoadOnAutoCADStartup="True">
    </ComponentEntry>

  </Components>
</ApplicationPackage>

 

You can add more files to the 'Windows' folder and update the 'PackageContents.xml' file accordingly. I hope this helps!

Message 8 of 8

luckyboy82292
Enthusiast
Enthusiast

Some additions. I put the .bundle folder into 'C:\Program Files (x86)\Autodesk\ApplicationPlugins\' folder. And it's working very well now.

0 Likes

Some additions. I put the .bundle folder into 'C:\Program Files (x86)\Autodesk\ApplicationPlugins\' folder. And it's working very well now.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report