how to make a code run automatically when autocad is opened every time? (without showing the security- executable file message)

how to make a code run automatically when autocad is opened every time? (without showing the security- executable file message)

a.kouchakzadeh
Advocate Advocate
2,564 Views
13 Replies
Message 1 of 14

how to make a code run automatically when autocad is opened every time? (without showing the security- executable file message)

a.kouchakzadeh
Advocate
Advocate

Hello every one. my main intention is to create a ribbon tab with some panels and commands by code so when ever AutoCAD runs, the ribbon would be added and when a button is clicked, a dll files would be netloaded and run automatically, without the security warning message. so I was wondering how is this possible?

if I manually create a CUIX file, is there any way to load only the specific tab that i created with a command?

 

 

0 Likes
Accepted solutions (1)
2,565 Views
13 Replies
Replies (13)
Message 2 of 14

BlackBox_
Advisor
Advisor
Accepted solution

Consider using Autoloader:

 

https://adndevblog.typepad.com/autocad/2013/01/autodesk-autoloader-white-paper.html


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 3 of 14

a.kouchakzadeh
Advocate
Advocate

Hi BlackBox

thanks for the reply.

In the comments sections in the link you provided I saw your messages with Fenton and I also took a look at the spiderinnet page. but unfortunately I wasn't able to find the test app file in the link they provided.

Im not that good in programming yet, and I didn't know any thing about xml before your post. so I had to read a bit about xml and autoloader, but I'm still confused

can you give me a hand in creating this Autoloader file?

lets say I just wanna add a simple command (with a "bboxtest" command method) which pops a message "hello world" and link it to a button in a custom tab in the AutoCAD ribbon.

TIA

0 Likes
Message 4 of 14

BlackBox_
Advisor
Advisor

No worries; you can check out one of my (or others') free apps: 

 

https://apps.autodesk.com/ACD/en/Detail/Index?id=2136331629271009666&appLang=en&os=Win32_64

 

ADN team takes what we upload and makes a lot of unnecessary changes to the .XML file, using an automated code generator in the published app (the XML can be quite simple). 

 

Just be sure to set the applicable 'merge' setting on the Ribbon Tab in CUI Editor, and AutoCAD products will handle it for you when loaded. 

 

If you have to make multiple changes to .CUIx, just be mindful that AutoCAD copies what's in your .bundle to support folder, so you may need to use FINDFILE at Command Line to locate/remove after editing the .CUIX in your .bundle folders.

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 5 of 14

a.kouchakzadeh
Advocate
Advocate

--> if you have to make multiple changes to .CUIx, just be mindful that AutoCAD copies what's in your .bundle to support folder, so you may need to use FINDFILE at Command Line to locate/remove after editing the .CUIX in your .bundle folders.

the only change I want to make is to create a new tab and insert a few panels and buttons to each panel.

can you tell me how to use the findfile?

 

EDIT: I downloaded your xml file from the link you provided and made some edits on it just to see if it does work or not.

How ever I used your help file because its required and I wanna first get my main problem fixed then create the help file. I also made a little edits on your ico file just to check out if its working or not.

unfortunately its not. I did anything that crossed my mind but no lock. I have attached the whole file I have created.

I also didnt assign any button function yet. I just added one simple dll file with a command method to see if it does load or not. but it didnt even load at all.

I used the same ProductCode and UpgradeCode that you had.

I also omitted AppNameSpace cuz I didnt know what to put instead of it. 

 

 

0 Likes
Message 6 of 14

BlackBox_
Advisor
Advisor

Sorry for the delayed reply - when your PM came in, I had already gone:

 

 

Dad.IsWorking = false;
Dad.Mode = Modes.FamilyTime; 
Dad.IsKeepingUpWith2yo = true;

 

 

Haha

 


 

I'll take a look at what you started; first observation is that your SeriesMin & SeriesMax aren't matching up. 

 

You're compiling this app for 23.1 (AutoCAD 2020), right?

 

Are you sure that you want to compile using .NET 4.0 instead of .NET 4.7?


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 7 of 14

a.kouchakzadeh
Advocate
Advocate
😄

yes sir Im compiling it with cad 2020 but I would like to make it work with all AutoCAD versions.
but how did you know that I'm compiling it with CAD 2020?
I didn't compile my dll with .NET 4.0 intentionally so I'm not sure if I want to use .NET 4.0
Im not aware of .NET 4.7 benefits
0 Likes
Message 8 of 14

BlackBox_
Advisor
Advisor

Busy day, but real quick -

 

Making your source code work for all versions may not be possible; entirely depends on what you're doing and what Autodesk has done with the API. 

 

I know that you compiled for 2020, because your assembly includes references to acdbmgd version=23.1, etc and says that Removeblk.CreateSSet.BlockClean(), aka CommandMethod("NSVBlockClean") was compiled using architecture x64 & runtime .NET 4.0... Also you have a typo after if (flag7)... 'curretn' should be 'current' :wink:

 

 

promptSelectionOptions2.set_MessageForAdding("all blocks on the curretn screen will be deleted\nSelect each objects you wish to keep (press R to remove again)");

 

 

2020 was released with SDK using .NET 4.7, but that doesn't mean an assembly compiled using older .NET version won't work (again, depending on what's being done in your source code). I have multiple apps compiled for 2018 that still worked when loaded in 2022. 

 

... More to follow; again, very busy day.

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 9 of 14

BlackBox_
Advisor
Advisor

Revised PackageContents.xml file (for your privacy, I've removed contact info): 

 

 

 

<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage AppVersion="2.3.1" Author="Amir" Description="Block Delete" HelpFile="./Contents/Resources/CubeHelp.html" Icon="./Contents/Resources/Cube.ico" Name="Amir Name test" ProductCode="{39CC1599-E035-4953-AD06-D7C7EC572636}" ProductType="Application" SchemaVersion="1.0" UpgradeCode="{22497B03-325F-482E-80BC-C0B479A84A23}" AutodeskProduct="AutoCAD" FriendlyVersion="2.3.1" SupportedLocales="Enu" AppNameSpace="appstore.exchange.autodesk.com" OnlineDocumentation=" ">
  <CompanyDetails Name=" " Phone=" " Url=" " Email=" " />
  <Components Description="2020-2023">
    <RuntimeRequirements SupportPath="./Contents/Resources;./Contents/Support" />
    <ComponentEntry AppDescription="Insertes a tab in the ribbon" AppName="CubeKCUI" LoadOnAutoCADStartup="true" ModuleName="./Contents/Resources/CubeK.cuix" Version="2.3.1" />
  </Components>
  <Components Description="2020-2023">
    <RuntimeRequirements OS="Win32|Win64" Platform="AutoCAD*" SeriesMin="R23.1" SeriesMax="R24.2" />
    <ComponentEntry AppDescription="deletes blocks" AppName="CubeK\CleanBlock" LoadOnAutoCADStartup="true" ModuleName="./Contents/Support/CleanBlock.lsp" Version="2.3.1" />
  </Components>
</ApplicationPackage>

 

 

 

** Please note that on my end, I changed CleanBlock.dll to CleanBlock.lsp with a call to (alert "Hello world!") that works. 

 

If you're loading the assembly on startup, there's no need for any of the load on command invocation malarkey. 

 

For your .CUIX file, be sure to edit that to have ID_ADDINSTAB for the Ribbon Tab's, Properties, Advanced, Aliases, so that automagically shows up in Ribbon's Add-Ins Tab. I'd also suggest ensuring Partial File Behavior Default Display == Add to workspaces, and Workspace behavior == Merge or add tab. 

 

HTH


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 10 of 14

a.kouchakzadeh
Advocate
Advocate

BlackBox, thanks for the help,

the dll is loading perfect. but the CUIX is still not loading. what Im willing to do, is unlike the applications downloaded from AutoDesk appstore which are loaded in the Add-ins tab, I want to create my own tab.

I have also set the Default Display = add to workspace and workspace behavior to merge or add tab. 

but still no luck.
oh and one more question, how is it possible to see the code within a dll file? 

0 Likes
Message 11 of 14

BlackBox_
Advisor
Advisor

Double check that the Ribbon Tab in your CUIx is configured properly, here's another example: 

 

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/custom-ribbon-not-displaying/m-p/754...

 

One way to easily edit your app's CUIx, is to setup an 'APPS' Profile that has your standard Main CUI, and your app's CUIx added as Enterprise CUI - then I use Robert Bell's 'Edit Enterprise CUI' LISP to programmatically swap them & make changes: 

 

https://forums.augi.com/showthread.php?137223-Enterprise-cui-Main-cui&p=1163984&viewfull=1#post11639...

 

After making the desired changes to your app's CUIx and quitting AutoCAD, then you need to delete all references to it from here: 

 

%AppData%\Autodesk\C3D 2023\enu\Support

 

** Change the red to your product or version

 

Yes, the CUIx you've prepared is located under your app's .bundle folder, but Autoloader copies that to the above path (for each version that loads your app), so any changes you make to the CUIx in your app aren't necessarily reflected until the app is upgraded (Version & UpgradeCode change in PackageContents.xml).

 

So, the easiest thing to do, is simply make the changes to your app's CUIx, quit AutoCAD, navigate to the folder above, sort by name and delete all .cuix & .mnr files related to your app's CUIx, then re-launch AutoCAD using the desired Profile (not your 'APPS' Profile), and then you should be able to see the changes made. 

 

As for decompiling a DLL assembly... I know a Little Spy. :beer:

 

Cheers

 

 


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes
Message 12 of 14

a.kouchakzadeh
Advocate
Advocate

I just noticed some thing,

I tried to use another .bundle file which was provided in one of this forums topics.

my CubeK.cuix file loads in it perfectly fine.

but when I use your xml file, it does not load.

I opened and closed AutoCAD many times. your xml file cant load my CUIX file.

I made a few changes to the xml you sent me to make sure the component element which is responsible for the cui part looks exactly similar to the one in the other topic. still didnt see my tab:

 

this is the other xml sample which loads the CUIX file:

akouchakzadeh_0-1651668980708.png

 

this is your xml file which I made changes to the CUI:

akouchakzadeh_1-1651669268168.png

and even before making this changes, it still didnt work.

 

0 Likes
Message 13 of 14

a.kouchakzadeh
Advocate
Advocate

BlackBox, thanks for the help Sir.

the problem is fixed, I had a typo which caused this problem. "Resources" had to be changed to "Resource"

every thing works perfectly fine now.

Message 14 of 14

BlackBox_
Advisor
Advisor

Awesome; glad you got it sorted!

 

The only other thing that jumped out to me in reading your earlier post now, is consider changing Platform from "AutoCAD" to "AutoCAD*" (or other from White Paper linked above), if you want to support more than _just_ AutoCAD.

 

Cheers


"How we think determines what we do, and what we do determines what we get."

Sincpac C3D ~ Autodesk Exchange Apps

0 Likes