Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

no function definition: VLAX-GET-ACAD-OBJECT

2 REPLIES 2
Reply
Message 1 of 3
serussel
12945 Views, 2 Replies

no function definition: VLAX-GET-ACAD-OBJECT

I added the following programming to my Acad2013.lsp file to add Support File Search Paths automatically.

 

Now I get the following two errors:

 

no function definition: VLAX-GET-ACAD-OBJECT

 

; error: no function definition: ACET-REG-PRODKEY

 

ACAD2013.lsp:

 

; MODULE_ID ACAD2007_LSP_
;;;    ACAD2013.LSP Version 1.0 for AutoCAD 2013
;;;
;;;  Copyright 2012 Autodesk, Inc.  All rights reserved.
;;;
;;;  Use of this software is subject to the terms of the Autodesk license
;;;  agreement provided at the time of installation or download, or which
;;;  otherwise accompanies this software in either electronic or hard copy form. ;;;
;;;
;;;
;;;    Note:
;;;            This file is normally loaded only once per AutoCAD session.
;;;            If you wish to have LISP code loaded into every document,
;;;            you should add your code to acaddoc.lsp.
;;;
;;;    Globalization Note:  
;;;            We do not support autoloading applications by the native
;;;            language command call (e.g. with the leading underscore
;;;            mechanism.)

(if (not (=  (substr (ver) 1 11) "Visual LISP")) (load "acad2013doc.lsp"))

;; Silent load.
(princ)


;; This loads CGA custom macro for "Set to current layer" lisp file
(load "s:/acad2007/lisp/layer.lsp")

;; This loads CGA custom macro for "Set to current layer" lisp file
(load "s:/acad2007/lisp/cgalayr.lsp")

;; This loads CGA custom lisp files
(load "s:/acad2007/lisp/CGA_custom.lsp")

;; This loads CGA custom lisp files
(load "s:/acad2007/lisp/door.lsp")

;; This loads CGA custom macro for Dimension Block Insertion file
(load "s:/acad2007/lisp/cgablockInsert.lsp")

;; This loads CGA custom macro for Dimension Block Insertion file
(load "s:/acad2007/lisp/imperial-metricblockInsert.lsp")

;; This loads custom Civil Cannoscales
(load "s:/acad2007/lisp/CS.lsp")

;; This loads custom GHA Page Setups
(load "s:/acad2007/lisp/GHA Pagesetups.lsp")

;; This loads custom zoom > xp routine
(load "s:/acad2007/lisp/zoomxp.lsp")

;; This loads custom Electrical Plan Template
(load "s:/acad2007/lisp/electrical-plan.lsp")

;; This loads custom dimension routine
(load "s:/acad2007/lisp/dimension.lsp")

;; This loads custom mvsetup routine
(load "s:/acad2007/lisp/mvsetup.lsp")

;; This loads custom leader routine
(load "s:/acad2007/lisp/leader.lsp")

;; This loads custom Roof Framing Template routine
(load "s:/acad2007/lisp/Roof Frame.lsp")

;; This loads custom Upper Floor Framing Template routine
(load "s:/acad2007/lisp/Upper Frame.lsp")

;; This loads custom Main Floor Framing Template routine
(load "s:/acad2007/lisp/Main Frame.lsp")

;; This loads custom GHA Title Block routine
(load "s:/acad2007/lisp/Layout Setup.lsp")

;; This loads custom Change Caps routine
(load "s:/acad2007/lisp/Chgcase.lsp")

;; This loads custom GHA Title Block routine
(load "s:/acad2007/lisp/STL.lsp")

(prompt "\nacad2007doc.lsp Loaded...")


(vla-put-supportpath
  (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
  (strcat ";S:\\Fonts"
          ";"
          (vla-get-supportpath files)
  )
)


(vla-put-supportpath
  (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
  (strcat ";S:\\Acad2007\\Hatch_Patterns"
          ";"
          (vla-get-supportpath files)
  )
)

(vla-put-supportpath
  (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
  (strcat ";S:\\Acad2007\\Simpson\\Menu"
          ";"
          (vla-get-supportpath files)
  )
)

(vla-put-supportpath
  (setq files (vla-get-files (vla-get-preferences (vlax-get-acad-object))))
  (strcat ";S:\\Acad2007\\Lisp"
          ";"
          (vla-get-supportpath files)
  )
)


(print "Printer setup started.")
(vl-load-com)
(vlax-for ps (vla-get-plotconfigurations
(vla-get-activedocument (vlax-get-acad-object))
)
(vla-delete ps)
)
(setq expert (getvar "expert"))
(setvar "expert" 2)
(command "._-PSETUPIN"
"S:/ACAD2007/Templates/Sheetsets/Architectural Imperial.dwt"
"*"
)
(setvar "expert" expert)

(print "Printer setup completed.")

 

 

 

 

2 REPLIES 2
Message 2 of 3
matt.worland
in reply to: serussel

Try adding (vl-load-com) to the beginning of the file.

If my reply was helpful, please give a "Thumbs Up" or "Accept as Solution"
Message 3 of 3
Lee_Mac
in reply to: serussel

Firstly, you should not modify the acad20##.lsp or acad20##doc.lsp files in any way - as stated in the documentation, these files are reserved for use by AutoCAD and contain AutoLISP functions required by the AutoCAD application. Furthermore, any modifications can be overwritten following an update of the application.

 

All customisations to be loaded on drawing startup should be placed in the acaddoc.lsp file - and this file should be created if not already present on the user's system.

 

To determine whether an acaddoc.lsp file already exists, open a blank new drawing in AutoCAD and type at the command-line:

 

(findfile "acaddoc.lsp")

 

If the above returns a valid filepath, navigate to the file in Windows Explorer and modify the contents of the existing file as required.

 

If the above returns nil, open Notepad (or an alternative plain text editor) to a new file and populate the file with your customisations. When finished, save the file as acaddoc.lsp to an AutoCAD Support File Search Path (these paths are listed under the 'Files' tab of the 'Options' dialog), ensuring that the 'Save as Type' option is set to 'All Files'.

 

When a drawing is opened (new or existing), AutoCAD will automatically search the working directory & all support file search paths (in the order listed in the 'Files' tab) for a file called 'acaddoc.lsp'; AutoCAD will then automatically load the first such file found into the current drawing session, hence evaluating all AutoLISP expressions contained in the file. More information about the potential dangers of such behaviour can be found in my post entitled: 'Dangers of the acaddoc.lsp'.

 

Now, regarding your code: as Matt has correctly indicated, the error you are receiving arises because the ActiveX component of Visual LISP has not been loaded using (vl-load-com) prior to invoking an ActiveX function - in this case (vlax-get-acad-object). Hence, you will need to ensure that (vl-load-com) appears in the file (and is evaluated) before calling an ActiveX function.

 

Looking at your expressions to add new Support File Search Paths (SFSP), I note that there is no check to test whether the added support path already exists in the list of SFSP and so, when the code is evaluated again (i.e. when the AutoCAD application is restarted since your code currently resides in the acad2013.lsp file), these support paths will again be appended to the list of SFSP.

 

To offer an alternative, consider my set of Support File Search Path functions; using my LM:sfsp+ function you can add a list of support paths in one expression, with the guarantee that if a path already exists in the list of SFSP, it will not be added twice, and paths which do not exist will also not be added.

 

Furthermore, the use of my function will be far more efficient in its operation, since it does not repeatedly call vlax-get-acad-object (which is a slow function to evaluate and repeated evaluation of this function should be avoided where possible) and then trudge through the Object Model hierarchy (application > preferences > files) for every support path.

 

To demonstrate the use of my function using your support paths:

 

(LM:sfsp+
   '(
        "S:\\Acad2007\\Lisp"
        "S:\\Acad2007\\Simpson\\Menu"
        "S:\\Acad2007\\Hatch_Patterns"
        "S:\\Fonts"
    )
)

 

I hope this helps.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost