Thursday, March 24, 2016

How to load script in AutoCAD

In AutoCAD we can use custom programs that help us do many routine work.

You can load your own apps (script) in AutoCAD.
Script is an text document that written on programming language LISP or VBA, and has extension *.LSP, *.ARX, *.DVB and others.


To load the script into AutoCAD you need run command:

Command: APPLOAD

or use menu:

Tools | Load Application

APPLOAD

Select  file ExplodeProxy2013x64 and press load.

The Selected file will be loaded to the AutoCAD. In order to file is loaded automatically press button Contents, and add file.

After file was loaded, you can run command.  Usually, AutoCAD shows which commands contains script, or you must read script file and find there a command that run script. Open *.LSP file in notepad and search text

defun C:

For example  DLINA  is a main command that runs script:

(defun C:Dlina (/ Nab Sum i Curve Param)
       (vl-load-com)
       (if (setq Nab (ssget))
       (progn
                 (setq Sum 0 i 0 value 0)
                 (repeat (sslength Nab)
                 (setq Curve (vlax-ename->vla-object (ssname Nab i))
                 i (1+ i)
                Param (vl-catch-all-apply 'vlax-curve-getEndParam
                (list Curve))
        )
       (if (not (vl-catch-all-error-p Param))
       (setq Sum (+ Sum (vlax-curve-getDistAtParam Curve
       Param)))
     )
  )
 )
)
(princ (strcat "\nСумма длин выбранных элементов равна: " (rtos
Sum 2 2)))
(setq value (rtos Sum 2 2))
 (alert (strcat "Сумма = " value))
(prin1)
)


No comments:

Post a Comment