Jump to content

Autcad addon development guide is needed


samifox

Recommended Posts

Greetings,

 

I work as a developer for AutoCAD add-ons.

 

Typically, I store my developments in: C:\Users\WIN10\AppData\Roaming\Autodesk\ApplicationPlugins

 

My add-on introduces a new tab, commands, tool palette, and custom icons.

I'm interested in creating an installer, but I'm uncertain about the appropriate location to paste certain data to ensure it doesn't overwrite anything on the target PC but rather complements it.

 

I've been unable to locate any official documentation explaining the deployment process.

Does anyone have information on this?

Link to comment
Share on other sites

Because an installer has to do stuff internally with CAD like add menu's etc I use a install lisp, and a zip, the zip for a client is 27Mb, so using a server for installs is the way to go but does run stand alone also, I send 2 files to client, the lisp and the ZIP, just drad the lisp onto Cad and the magic happens.

 

Ok the secret is that CAD can call a UNZIP shell command it it unzips to a program directory like C:/BIGAL-CAD-TOOLS obviously at a top level. 

 

(vl-mkdir "c:\\xxx-CAD-TOOLS")

(setq filename (getfiled "Select the File \"xxx Cad tools 18-02-2024\"" "" "ZIP" 16))

; unzip
(startapp (strcat "powershell -command Expand-Archive -Path '" filename "' -DestinationPath 'C:/xxx-CAD-TOOLS' -FORCE"))
(alert "programs unzipped to C:/xxx-CAD-TOOLS")

(setq *files*  (vla-get-files  (vla-get-preferences (vlax-get-Acad-object))))
(setq paths (vla-get-SupportPath *files*))
(if (wcmatch paths "*C:\\xxx-CAD-TOOLS*")
(princ "path set")
(vla-put-SupportPath *files* (strcat "C:\\xxx-CAD-TOOLS\\SLIDES;C:\\xxx-CAD-TOOLS\\IMAGES;C:\\xxx-CAD-TOOLS;" paths))
)

(vla-put-PrinterStyleSheetPath *files* (strcat (vla-get-PrinterStyleSheetPath *files*) ";C:\\xxx-CAD-TOOLS"))

; template location
(vla-put-QnewTemplateFile *files* "C:\\xxx-CAD-TOOLS\\xxx.dwt")
; template  path
(vla-put-TemplateDwgPath *files* "C:\\xxx-CAD-TOOLS")


(if  (> (vl-string-search  "BRICSCAD" (strcase (getvar 'product))) 0)
(princ "Bricscad not found") 
(progn
(setq oldtrust (getvar 'trustedpaths))
(if (wcmatch  oldtrust "*xxx*")
(princ)
(setvar 'trustedpaths (strcat oldtrust ";" "c:\\xxx-CAD-TOOLS"))
)
)
)
(command "workspace" "save" "" "y")
(alert "\nSupport and trusted paths added")

(setq Menu_Path "C:\\xxx-CAD-TOOLS\\") ; Path to Menu file
(setq Menu_Name "xxx-CAD-TOOLS") ; pop menu to load
(setq Group_Name "VFTMENU") ; groupname assigned in .mnu or .mns file

(if (menugroup menu_Name)
(command "_MENUUNLOAD" menu_Name)
)
(setq cnt (vla-get-count(vla-get-menuGroups (vlax-get-acad-object))))
(if  (> (vl-string-search  "BRICSCAD" (strcase(getvar 'product))) 0)
(progn
(command "MENULOAD" (strcat Menu_Path Menu_Name ".mnu"))
(menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
)
(progn
(command "MENULOAD" (strcat Menu_Path Menu_Name ".mnu"))
(menucmd (strcat "P" (rtos (+ cnt 1) 2 0) "=+" menu_Name ".POP1"))
)
)
(setvar "menubar" 1)

(alert "\n Menu loaded \n \n xxx CAD Tools now installed")

)
(vftinstall)

 

The other way to go is make a BUNDLE for Autocad, similar approach for Bricscad.

 

Link to comment
Share on other sites

How does the MSI installer add menus, support path etc to the CAD ? Or do you always use a bundle ? Its a bit more complicated for Bricscad. 

Link to comment
Share on other sites

It’s a good question

 

You can set the MSI to use custom actions. The installer can invoke methods in a separate DLL.

This DLL can be C/C++ or .NET… or whatever

 

caction.png.b7e178398b9959a00df5390e43412900.png

 

I usually use two custom action functions RxInstall, RxUninstall, example.

 

static HMODULE ghThisModule = NULL;

#define DllExport   __declspec( dllexport ) 

std::filesystem::path getModulePath()
{
	TCHAR modPath[MAX_PATH] = { 0 };
	GetModuleFileName(ghThisModule, modPath, MAX_PATH);
	return std::filesystem::path{ modPath };
}

EXTERN_C DllExport UINT WINAPI RxInstall(MSIHANDLE hInstall)
{
	std::filesystem::path path = getModulePath();
	RxEnvironment& env = RxEnvironment::instance(path, hInstall);
	env.install(); // DO the install
	return ERROR_SUCCESS;
}

EXTERN_C DllExport UINT WINAPI RxUninstall(MSIHANDLE hInstall)
{
	std::filesystem::path path = getModulePath();
	RxEnvironment& env = RxEnvironment::instance(path, hInstall);
	env.uninstall();// DO the uninstall
	return ERROR_SUCCESS;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD  dwReason, LPVOID lpReserved)
{
	if (dwReason == DLL_PROCESS_ATTACH)
	{
		DisableThreadLibraryCalls(hModule);
		ghThisModule = hModule;
	}
	return TRUE;
}

 

These functions are sent a MSIHANDLE to provide context.  They are invoked by thin installer under the rights/credentials, which may or may not be limited. Anyway, from here you can play with the registry, environment, files etc.

 

BricsCAD you must add an autoload entry to the registry, which is a bummer. AutoCAD I use the bundle.

 

Note: I really try avoid writing to the registry, so for persistent settings, I usually use SQLite or a file.

Menus, I usually create a partial CUIX, or I load them dynamically  

 

Link to comment
Share on other sites

hi guys,

i would be more specific, 

 

how my installer can add paths to the AutoCAD "supporting file" in the target pc? 

should i implant my tool palette files somewhere in the target pc?

 

 

There is no developer official document to address all of those questions?

 

Link to comment
Share on other sites

I would look at appending to \CurProfile\ToolPalettePath in the registry,

or you can probably append it on first run with vla-put-ToolPalettePath if your using lisp

Link to comment
Share on other sites

sorry I can’t be of more help, I’m not familiar with the tool palettes.

 

how my installer can add paths to the AutoCAD "supporting file" in the target pc? 

A, this value is stored in the registry, in the profile section, you must add it yourself from an installer perspective

 

path.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...