Add .cui by installation

Add .cui by installation

Anonymous
Not applicable
782 Views
1 Reply
Message 1 of 2

Add .cui by installation

Anonymous
Not applicable

Hello everybody
Two questions.
First question:

I would like to offer my plugins.

The prerequisite is that AutoCAD is already installed (2020).

Now I would like to load my .cui file directly from my installation setup so that the user does not have to do anything. Whats the best way to do this?

 

Second question:
I would like to make my license tool (an .exe file) executable via the AutoCAD. Whats the best way to do this?
I dont have any Shell or AutoLisp experiences. Can anybody help me?

0 Likes
783 Views
1 Reply
Reply (1)
Message 2 of 2

office
Enthusiast
Enthusiast

1)

(defun loadMyMenu(
		  menuGroupName
		  menuName
		  cuiPath
		  / cui_database mnbar flag
		  )
  (vl-load-com)
  (setq	cui_database
	 (list
	   menuGroupName ;<<< MENUGROUP
	   cuiPath ;<<<PATH & CUI FILENAME
	   menuName ;<<< MENUNAME
	) ;_ end_list
  ) ;_ end_setq
  (vlax-for n
	      (setq all_menus
		     (vla-get-MenuGroups
		       (vlax-get-Acad-Object)
		     ) ;_ end_vla-get-MenuGroups
	      ) ;_ end_setq
    (if	(= (vla-get-name n) (car cui_database))
      (setq flag T)
    ) ;_ end_if
  ) ;_ end_vlax-for
  (if (null flag)
    (progn
      (vla-load
	all_menus
	(cadr cui_database)
      ) ;_ end_vla-load
      (setq MnBar
	     (vla-get-MenuBar
	       (vlax-get-Acad-Object)
	     ) ;_ end_vla-get-MenuBar
      ) ;_ end_setq
      (vla-InsertInMenuBar
	(vla-Item
	  (vla-get-Menus
	    (vla-Item
	      (vla-get-MenuGroups
		(vlax-get-Acad-Object)
	      ) ;_ end_vla-get-MenuGroups
	      (car cui_database)
	    ) ;_ end_vla-Item
	  ) ;_ end_vla-get-Menus
	  (caddr cui_database)
	) ;_ end_vla-Item
	(1- (vla-get-Count MnBar))
      ) ;_ end_vla-InsertInMenuBar
    ) ;_ end_progn
  ) ;_ end_if
  (princ)
) ;_ end_defun

(defun checkIfFirstRun(
		       / myAppName acadObject menuGroupName menuName cuiPath isFirstRun
		       )
  	(setq menuGroupName "MyMenu"
	      menuName "M&yMenu"
	      myAppName "MyCoolApp"
	      )
  	;You have to create or edit your custom registry entry with your setup.exe and with the value 1 (integer). The 1 value will mean that an istall happend and with first run of autocad we neeed to load the menu!!
	(setq isFirstRun
	       (vl-registry-read
		 (strcat
		   "HKEY_CURRENT_USER\\"
		   (vlax-product-key)
		   "\\Profiles\\"
		   (getvar "cprofile")
		   "\\" myAppName)
		 "IsFirstRun")) ;if 1 the menu must be loaded automatically. If 0 it means no need to load the menu because it is already loaded
  	(if (= isFirstRun 1)
	(progn
	  	(if (/= (menugroup menuGroupName) nil)
			(command "_.cuiunload" menuGroupName) ;if you reinstalled the app and the menu is already loaded it will be unloaded!!!!
		)
	  	(setq cuiPath "C:\\program files\\MyAppName\\MyMenu.cuix" ;the path of your cui file, you have to enter here your path
		      acadObject (vlax-get-acad-object)
		      )
	  	(loadMyMenu
		  	menuGroupName
			menuName
			cuiPath
		  )
	       (vl-registry-write
		 (strcat
		   "HKEY_CURRENT_USER\\"
		   (vlax-product-key)
		   "\\Profiles\\"
		   (getvar "cprofile")
		   "\\" myAppName)
		 "IsFirstRun" 0) ;we set the registry to 0, so no need to load the menu each time when a drawing is open!!
	))  
)

!!!Your acad.lsp file must contain the (checkIfFirstRun) function!!!!

2)

(startapp yourExeFileLocation)

0 Likes