Jump to content
BIGAL

Forwarding code onto a new user

Recommended Posts

BIGAL
Posted (edited)

I found my self trying to write a simple install routine and something that would work inside Autocad.

 

I did find that you can unzip and direct the contents to a specific directory, so my in my case have 42 fas files around 40 dwgs a menu or two , numerous dcl's and Slb's. 

 

It just needs a simple bat file, it finds the zip in "downloads" the normal save as location etc

 

Md c:\Cadarc
powershell.exe -nologo -noprofile -command "& { Add-Type -A 'System.IO.Compression.FileSystem'; IO.Compression.ZipFile]::ExtractToDirectory('C:\users\%username%\downloads\cadarc.zip', 'C:\Cadarc'); }"

 

 

The next is to wrapper it using "Shell" in a lisp that also sets the support and trusted paths, loads the menu's and makes a workspace, possibly a ARG for if anything goes wrong.

 

Trying to get end users to make directories add support paths can be a nightmare if they have never done it.

 

Edited by BIGAL

Share this post


Link to post
Share on other sites
rlx

Looks interesting Bigal. Will play with it when I have the time (suddenly everybody is giving me work here at the office... how dare you! 😓 )

Share this post


Link to post
Share on other sites
CHLUCFENG

Interesting to use a batch file through shell. I'll have to keep that in mind.

 

At our company, there is a master lisp routine that loads where we can add tidbits as necessary. One small portion adds the support paths for FONTS, TRUSTED PATHS, and PLOTTER/PEN settings.

 

Here's how I worked through that:

(defun TrustedPath
       (/ AcadObject PrefsObject TabNameObject SupPath TrustPath)
  (vl-load-com)
  (setq AcadObject (vlax-get-acad-object))
  (setq PrefsObject (vlax-get-property AcadObject 'Preferences))
					;store a reference to Preferences (Preferences object)
  (setq TabNameObject (vlax-get-property PrefsObject 'Files))
					;Store a reference to the Files (Files Object)
  (setq
    SupPath (strcase (vlax-get-property TabNameObject 'SupportPath))
  )					;get the existing support path (CAPS)


  ;; check for FONTS
  (if (not (vl-string-search "K:\\FONTS" SupPath))
    (progn
      (princ "\nFonts are not listed in Support Path")
      (setq SupPath (strcat SupPath ";" "K:\\fonts"))
      ;; Update the path
      (vlax-put-property TabNameObject 'SupportPath SupPath)
      (alert
	"   The FONTS in your support path did not include K:\Fonts.
	    \n\t\tI have added the support path.
	    \n\tPlease close all AutoCAD sessions and re-open."
      )
    )					;end progn
    ;;else
    (princ "\nCheck - Fonts are pathed.")
  )					;end if

;;; Directories for Trusted Paths
  (defun check (str)
    (if	(not
	  (vl-string-search str (strcase (getvar "trustedpaths")))
	)
      (setvar "trustedpaths"
	      (strcat (getvar "trustedpaths") ";" str ";")
      )
    )
  )
  (mapcar 'check
	  '("K:\\..."
	    "U:\\CHUCK\\LISP"
	    "U:\\CHUCK\\LISP\\..."
	   )
  )
  (princ "\nTrusted paths checked... Loaded as necessary.")

;;; Directories for Plotter configurations and pen settings
  (setq	SupPath	(strcase
		  (vlax-get-property TabNameObject 'PrinterConfigPath)
		)
  )
  (if (not
	(vl-string-search "ACAD2018 PLOTTING" SupPath)
      )
    (progn
      (princ "\nPrinter configuration path loading...")
      (setq
	SupPath	(strcat SupPath ";" "K:\\Plotting;")
      )
      ;; Update the path
      (vlax-put-property TabNameObject 'PrinterConfigPath SupPath)
    )					;end progn
  )					;end if

  (setq	SupPath
	 (strcase (vlax-get-property TabNameObject 'PrinterDescPath))
  )
  (if (not
	(vl-string-search "ACAD2018 PLOTTING" SupPath)
      )
    (progn
      (princ "\nPrinter description path loading...")
      (setq
	SupPath	(strcat SupPath ";" "K:\\Plotting;")
      )
      ;; Update the path
      (vlax-put-property TabNameObject 'PrinterDescPath SupPath)
    )					;end progn
  )					;end if

  (setq
    SupPath (strcase
	      (vlax-get-property TabNameObject 'PrinterStyleSheetPath)
	    )
  )
  (if (not
	(vl-string-search "ACAD2018 PLOTTING" SupPath)
      )
    (progn
      (princ "\nPlot style table path loading...")
      (setq
	SupPath	(strcat SupPath ";" "K:\\Plotting;")
      )
      ;; Update the path
      (vlax-put-property
	TabNameObject
	'PrinterStyleSheetPath
	SupPath
      )
    )					;end progn
  )					;end if

;;; Directory for Autosave Path
  (if (not
	(= (strcase (getvar "savefilepath")) "C:\\ACAD-AUTOSAVE")
      )
    (progn
      (setvar "savefilepath" "C:\\ACAD-AUTOSAVE")
      (princ "\nAutosave path checked... Changed as necessary.")
    )
  )
  (princ)
)					; end TrustedPath 

The hardest part of this task was getting the correct property names.  😉

  • Like 1

Share this post


Link to post
Share on other sites
BIGAL

Thanks CHULFENG I have the paths plus a few other items all sorted when you have to build around 20 autocad per year need shortcuts. 

 

(vlax-dump-object (vla-get-files (vla-get-preferences (vlax-get-Acad-object)))) will give list of properties.

 

A couple worth adding Acadtemp is my dump directory

 

(vla-put-TempFilePath *files* "C:\\AcadTemp\\")

(vla-put-PlotLogFilePath *files* "C:\\AcadTemp\\")

(vla-put-LogFilePath *files* "C:\\AcadTemp\\")

Edited by BIGAL
  • Like 1

Share this post


Link to post
Share on other sites
CHLUCFENG
19 minutes ago, BIGAL said:

(vlax-dump-object (vla-get-files (vla-get-preferences (vlax-get-Acad-object))))

 

Well, check that out! Shows me the properties, and their current path. Quite handy.

 

Thanks for the tip!

Share this post


Link to post
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
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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...