Author Topic: Macro based upon calls from within a DLL command  (Read 1551 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Macro based upon calls from within a DLL command
« on: March 30, 2023, 01:09:57 PM »
Is it possible to create a button macro from calling loading a dll, then executing the calls from within the dll?

https://stackoverflow.com/questions/52381055/how-to-call-a-function-from-a-dll-in-autocad-via-custom-menu

Code: [Select]
^C^C(Load "C:\\Test\\Test.dll");Test1;;
Loading the dll, the call would be Test1, with 2 enters to complete the macro.

If not, it was worth a shot.
thanks!
Civil3D 2020

57gmc

  • Bull Frog
  • Posts: 362
Re: Macro based upon calls from within a DLL command
« Reply #1 on: March 30, 2023, 04:16:51 PM »
First of all, the (load) function only loads lisp files. NET dll's must use the NETLOAD command.
What you want to do is called demand loading. The best way to deploy is to use a bundle. It supports the autoloader technology. From the preceding article, you would use the LoadReasonsflag and specify LoadOnCommandInvocation. To use this option, you also have to include a list of the commands you dll has defined. When your menu macro calls a function and the dll hasn't been loaded yet, acad automatically loads it.

The stackflow post you pointed to also mentioned another problem with trying to do what you want...security warnings. Bundles get stored in folders that are trusted locations.
« Last Edit: March 30, 2023, 04:23:09 PM by 57gmc »

MSTG007

  • Gator
  • Posts: 2599
  • I can't remeber what I already asked! I need help!
Re: Macro based upon calls from within a DLL command
« Reply #2 on: March 31, 2023, 10:23:02 AM »
Thank you for shedding some light on that. On top of that, If the dll has sub options within the command, could a macro still be setup?

example. Test1, activates the command, then user has to click somewhere, a new subcommand prompts user, then the command would be completed.

Code: [Select]
command: Test1
command: User pick polyline: (User picks)
command: Change the (L) Lineweight or (PE) pedit the polyline width: (User picks L)
command: What lineweight do you want to use?: (User types in 0.00) (Command is completed.)

Civil3D 2020

57gmc

  • Bull Frog
  • Posts: 362
Re: Macro based upon calls from within a DLL command
« Reply #3 on: March 31, 2023, 12:57:14 PM »
If your command follows AutoCAD standards, you can use standard command macro syntax. ^C cancels any command in progress. A space acts like {Enter}. a backslash = pause.