Showing posts with label LISP. Show all posts
Showing posts with label LISP. Show all posts

Monday, September 15, 2014

Length of object label with free app for AutoCAD

LengthText.lsp is a free AutoLisp app for AutoCAD by JTB World to add length of objects as a text field label. Select the object and then where you want the text for the length to be. When the object is modified the text will also be updated automatically based on FIELDEVAL or the settings found in the OPTIONS dialog box. The current unit settings are being used to show the length.

LengthText.lsp

Download LengthText.lsp or the AreaText.lsp that this was based upon. If you have a need for any AutoCAD customization work feel free to contact us.

Monday, February 17, 2014

How to test if a DVB file is loaded using AutoLISP

This is a sample code snippet showing how you with AutoLISP (or rather Visual LISP) can test if a certain VBA DVB file is loaded in AutoCAD or not.

(vl-load-com)
(defun isDVBLoaded (dvb / oVBProjs c found)
  (setq oVBProjs (vlax-get (vla-get-vbe (vlax-get-acad-object)) "VBProjects"))
  (setq dvb (strcase dvb))
  (repeat (setq c (vla-get-count oVBProjs))
    (if (vl-string-search dvb (strcase (vla-get-FileName (vla-item oVBProjs c))))
      (setq found T)
    )
    (setq c (1- c))
  )
  found
)

Here’s how to call the function:
(isDVBLoaded "jtbworld.dvb")

Monday, January 27, 2014

AutoLISP progn error: too many arguments SOLVED

I was working on an existing AutoLISP program for AutoCAD while I found that during “Check Text in Editor” (or “Check Selection”) I got an error. It worked fine to just load and run the program but check did not. Trying to make an application (FAS or VLX) will also give this error.

; error: too many arguments: (PROGN 1 2 3 ... )

It was really confusing until I realized that progn only accepts 255 arguments. Often progn is used to together with if to allow more expressions to be evaluated and in a case like that it can easily happen that there are more than 255 arguments.

This is en example of how to reproduce this:

(progn
  1    2    3     4    5       6    7    8      9    10   11     12   13   14
  15   16   17     18   19   20    21   22      23   24   25     26   27   28
  29   30   31     32   33   34    35   36      37   38   39     40   41   42
  43   44   45     46   47   48    49   50      51   52   53     54   55   56
  57   58   59     60   61   62    63   64      65   66   67     68   69   70
  71   72   73     74   75   76    77   78      79   80   81     82   83   84
  85   86   87     88   89   90    91   92      93   94   95     96   97   98
  99   100  101     102  103  104    105  106  107  108  109     110  111  112
  113  114  115     116  117  118    119  120  121  122  123     124  125  126
  127  128  129     130  131  132    133  134  135  136  137     138  139  140
  141  142  143     144  145  146    147  148  149  150  151     152  153  154
  155  156  157     158  159  160    161  162  163  164  165     166  167  168
  169  170  171     172  173  174    175  176  177  178  179     180  181  182
  183  184  185     186  187  188    189  190  191  192  193     194  195  196
  197  198  199     200  201  202    203  204  205  206  207     208  209  210
  211  212  213     214  215  216    217  218  219  220  221     222  223  224
  225  226  227     228  229  230    231  232  233  234  235     236  237  238
  239  240  241     242  243  244    245  246  247  248  249     250  251  252
  253  254  255     256
)

The workaround I used was to add a few extra nested progn and problem solved.

Another way is to use cond like this:
(cond (T
1 2 3 all the way to 256 or higher will work fine
))

And of course create a new function with defun.

But what about using (repeat 1 …) as a workaround saving an extra pair of parentheses compared to cond? Unfortunately repeat has the same limitation of 255 expressions as progn.
; error: too many arguments: (REPEAT 1 1 2 ... )

What then is progn other than a way to bundle together a lot of expressions?
  
Progn evaluates each expression sequentially and returns the value of the last expression. In the progn example above the returned value would be 256.

Monday, January 13, 2014

SmartPurger 3.5 released

SmartPurger 3.5 from JTB World is now available both from our product page as well as on Autodesk Exchange Apps. A free trial is available of SmartPurger so you can give it a try.

SmartPurger not only purges multiple drawings but can also batch process most anything you like if you have any Script or AutoLISP files you want to run on a bunch of DWGs. If you don’t know how we can help to create it so you can automate your manual tasks. An AutoCAD based application is required to run SmartPurger but it can also work with other DWG compatible CAD applications.

These are the bug fixes for this release:

-Fixed a bug where accoreconsole did not save to specified DWG version
-Purge multileader styles bug fixed where it did not always purge these styles.
-Handle dialog box about VBA not installed
-Fixed bug where Educational Version - Terminated sometimes show up in status column even though the drawing is not educational

If you are interested in other useful AutoCAD helper functions take a look at JTB Sheet Set Creator, DigSigStamp,Batch Publish for AutoCAD, DimensionPatrol, TransTips or OffsetInXref.

If you need any custom app created, small or large, for AutoCAD or Revit you are welcome to contact us.

Tuesday, October 15, 2013

How to know what service pack is installed for AutoCAD

The easiest way to see if and what service pack is installed for AutoCAD or any vertical is to check the About dialog box. Either use the ABOUT command or select About from this dropdown at the top right of AutoCAD.

And in the About dialog box the Product Version will be seen showing in this case:
Product Version: I.108.0.0, AutoCAD 2014 SP1

To find out which service packs have been applied to your Autodesk software, you can also use the Windows control panel for uninstalling and changing programs.

  • For Windows XP, click the Windows Start menu Control Panel Add/Remove Programs Show Updates.
  • For Windows 7, click the Windows Start menu Control Panel Programs and Features View Installed Updates.
  • For Windows 8, right-click the Windows Start screen (or use the swipe up gesture from the bottom edge while on the Start screen). Click All Apps Windows System Control Panel Programs and Features Uninstall a Program View Installed Updates.
    Alternatively open File Explorer and on the Computer ribbon tab click on Uninstall or change a program followed by View installed updates.
  • For Windows 8.1, right-click on the Windows Start menu Control Panel Programs Programs and Features View installed updates.
    Alternatively open File Explorer and on the Computer ribbon tab click on Uninstall or change a program followed by View installed updates.

Another way is to use _Vernum, an undocumented system variable that has been around for long and could be used to identify the product version and if a service pack is installed or not. Programmers and CAD managers have often used this in AutoLISP code.

_Vernum for AutoCAD 2014 without SP1 is I.18.0.0 (UNICODE)

_Vernum for AutoCAD 2014 after installation is I.108.0.0 (UNICODE)

But what if having AutoCAD Architecture 2014 installed side by side? If AutoCAD 2014 SP1 is installed and AutoCAD Architecture 2014 has no SP1 installed _Vernum will show I.108.0.0 (UNICODE).

Once up on a time the _Vernum for verticals were different but because the verticals since AutoCAD 2013 are installed in the same place as vanilla AutoCAD _Vernum can not be used to reliably identify if a service pack is installed or not. For a better way read further.

Other related tips to figure out info about the installed product and finally the solution.

Command: ACADVER
ACADVER = "19.1s (LMS Tech)" (read only)

Command: UILOCALE
UILOCALE = "en-US" (read only)
The above is a new system variable in AutoCAD 2014.

(getvar 'PRODUCT)
Result: "AutoCAD"

(vla-get-caption (vlax-get-acad-object))
Result: "Autodesk AutoCAD 2014 - NOT FOR RESALE - [Drawing1.dwg]"

(vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)) "ProductName")
Result: "AutoCAD 2014 - English"

(vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)) "ProductNameGlob")
Result: "AutoCAD 2014"

(vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)) "Release")
Result: "19.1.18.0"
The above will show the release number without the service pack added.

This will only work for AutoCAD 2013 or newer:

(setq reg (strcat "HKEY_LOCAL_MACHINE\\" (vlax-machine-product-key)))
(setq LocaleidLen (strlen (vl-registry-read reg "Localeid")))
(setq reg (strcat (substr reg 1 (- (strlen reg) LocaleidLen 1)) "\\Service Packs"))
(setq reg (strcat reg "\\" (car (vl-registry-descendents reg))))
(setq PatchTitle (vl-registry-read reg "PatchTitle"))
(setq Release (vl-registry-read reg "Release"))
Result example for AutoCAD:
PatchTitle="AutoCAD 2014 SP1" and Release="19.1.108.0"
Result example for AutoCAD Architecture:
PatchTitle="AutoCAD Architecture 2014 SP 1" and Release="7.5.106.0"

This last example shows the programmers way to get what service pack is installed for the current AutoCAD product.

Friday, May 17, 2013

AutoCAD 2013 Service Pack 2

AutoCAD 2013 SP2 is now available to download here. You don’t need to install earlier SP before installing SP2. If you have AutoCAD LT 2013 the download is here.

I and other beta testers have used SP2 for some time but if you don’t want to be the first to run into any unexpected problems you might want to wait a few weeks. (remember SP1 that quickly was replaced by SP1.1) Other than that there are a lot of fixes in SP2 making it worth installing.

This Service Pack can be applied to AutoCAD 2013 installed as a standalone application as well as AutoCAD 2013 installed from the following Autodesk Design Suites.

  • AutoCAD Design Suite 2013
  • Autodesk Building Design Suite 2013
  • Autodesk Factory Design Suite 2013
  • Autodesk Infrastructure Design Suite 2013
  • Autodesk Plant Design Suite 2013
  • Autodesk Product Design Suite 2013

The following operating systems are also now officially supported for 32-bit and 64-bit AutoCAD 2013 with Service Pack 2.

  • Windows 8 Standard edition
  • Windows 8 Enterprise edition
  • Windows 8 Professional edition

_VERNUM (product version) details:
AutoCAD 2013 SP2: G.204.0.0 (UNICODE)
AutoCAD 2013 SP1.1: G.114.0.0 (UNICODE)
AutoCAD 2013 SP1: G.112.0.0 (UNICODE)
AutoCAD 2013: G.55.0.0 (UNICODE)

As a result of detailed information from customers who used the Customer Error Reporting Utility, a number of problems were identified and fixed. Updates have been made in the following commands and features:

3D Navigation Tools

  • Occasional crash related to navigation tools.

Autodesk 360

  • Crash with long file path in the Autodesk 360 folder.
  • Occasional crash when opening AutoCAD with the InfoCenter off.

Block

  • Occasional crash when clicking a block table grip with only one row of values available.

Command Line

  • Crash when switching Input Method Editor (IME) after canceling a command when DYNMODE is set to 0 and the command window is docked.

DGN Support

  • Fatal error when scrolling the DGN linetype in the Properties Palette.

Dimensions

  • Occasional crash when grip-editing annotative dimensions.

External Reference (XREF)

  • An OLE Object in an xref was not correctly set before the xref was detached. This crash issue has been resolved by opening the xref before erasing it.

MLEADER

  • Occasional crash when using MATCHPROP with multileaders.

OLE

  • Occasional crash when closing the application with a drawing that contains an OLE object.

OPTIONS

  • Occasional crash when changing or switching profiles in Options.

Plot

  • Occasional crash when plotting with a wipeout in the drawing.

PDF Underlay

  • Crash when specifying other PDF file from Saved Path field in External Reference palette.

General

  • Occasional crash when opening AutoCAD drawings in Windows 8.
  • Occasional crash due to using Intersection object snaps on lightweight polylines.
  • Some corrupt drawings crash when opened or saved and are not fixed automatically.
  • Exiting the Text Editor while previewing text style causes a crash.

The following defects have been fixed:

3D Navigation Tools

  • Zoom speed varies with 3Dconnexion device in perspective view.

3D Modeling

  • Issue with the MASSPROP command with sliced 3D solids.

Block

  • Issue with the display of the Block Property Table cascading menu.

CUI (Customize User Interface)

  • Missing checkboxes in the Customize User Interface (CUI) dialog box when NET 4.5 is installed.

DGN Support

  • Issues with exporting files to DGN, even after exploding contents of file.
  • Import of a DGN arc as an Ellipse.

Dimensions

  • Radial dimensions for regions can become associated to wrong arc.
  • Dimension text background fill cannot be reset in Properties.
  • Jogged radial dimensions in paper space may reflect the wrong value of an extruded cylinder in model space.

Image

  • MONOCHROME BITMAP attached in DWG file is not shown correctly.

INQUIRY

  • MASSPROP reports an incorrect mass and centroid for a solid swept along a planar spline.

MLeader

  • Multileader scale is not always updated when multileader style is changed.

Model Documentation - Detail View

  • Changing the Hatch property of a Detail view derived from a Section view sometimes causes AutoCAD to hang.

Modify

  • Ellipse is sometimes distorted during stretching.

MTEXT

  • The font doesn't match the setting in -STYLE command in Windows 8.

Plot

  • There is a black stripe when plotting some drawings with a clipped image.
  • A printer cannot be added after adding multiple driver folders in the Options dialog box.
  • Drawings cannot be plotted with the oversized paper size and transparency on.

Selection

  • Grips for attributes of blocks are not automatically made hot upon sub-selection.
  • Selection preview is reset to off when IntelliMouse® zooming is ended.

Visual Lisp

  • DCL files whose code page matches the system but not the product are not recognized and loaded properly.

General

  • Saving some DWG files that contain 3D solids is slow.
  • A UCS other than the World UCS results in an incorrect location for the wipeout frame.
  • Prompts to save are not displayed when closing a hyperlink drawing that has been changed.
  • Performance is slow when saving the drawing created with Release 2010 and earlier.

Fixes in the previous AutoCAD 2013 Service Pack 1.1 are included.

See also more details in the posts AutoCAD 2013 SP1 & AutoCAD LT 2013 SP1 and AutoLISP and VBA Security Controls in AutoCAD 2013 SP1.

Friday, March 29, 2013

How to fix error: ActiveX Server returned an error: Error loading type library/DLL

I just got this error running some AutoLISP code in AutoCAD 2014 that I know there is no error in.

; error: ActiveX Server returned an error: Error loading type library/DLL

I tried to repair the AutoCAD installation but it did not help so I tried a reinstall instead and that solved the issue.

I think this problem happened because I also have AutoCAD 2013 installed and applied the service pack to it after AutoCAD 2014 was installed.

Friday, December 28, 2012

How to rotate or twist the view in AutoCAD

Here are some AutoLISP commands that can be useful if you want to rotate or twist the view. Change 90 to any other angle if you like. For counterclockwise change to –90. If you have a recent version of AutoCAD and just want 90 degrees relative rotation use the built in ViewCube functionality and the two arrows at the top right.

The DVIEW command can be used to also manually to twist the view using the twist option that twists or tilts the view around the line of sight. The twist angle is measured counterclockwise, with 0 degrees to the right.

The AutoCAD system variable VIEWTWIST stores the view rotation angle for the current viewport measured relative to the WCS and is also named as “Roll angle” (Displays the rotation angle of the view within your viewing plane, which is a plane parallel to your monitor's screen.) in the View Manager. This is being used for rotating the view relative the current rotation.

; By Jimmy Bergmark, www.jtbworld.com
; Rotate 90 degrees relative the current twist rotation
(defun c:r90 ()
  (command "._dview" "" "_twist" (+ (* 180.0 (/ (getvar "viewtwist") pi)) 90 ) "")
  (princ)
)

; Rotate -90 degrees relative the current twist rotation
(defun c:r-90 ()
  (command "._dview" "" "_twist" (+ (* 180.0 (/ (getvar "viewtwist") pi)) -90 ) "")
  (princ)
)

; Rotate to 90 degrees fixed twist rotation
(defun c:r90f ()
  (command "._dview" "" "_twist" 90 "")
  (princ)
)

; Rotate to 0 degrees fixed twist rotation
(defun c:r0f ()
  (command "._dview" "" "_twist" 0 "")
  (princ)
)

Before

and after rotating the view 90 degrees.

Friday, September 21, 2012

AutoCAD product keys in Visual LISP explained

The product key functions have some news in Visual LISP for AutoCAD 2013. These are extended functions provided by VLISP. You must issue vl-load-com before you can use the functions.

VLAX-MACHINE-PRODUCT-KEY - Returns the AutoCAD product key from the Machine hive in the Windows Registry.  (ie. "Software\\Autodesk\\AutoCAD\\R19.0\\ACAD-B001:409") VLAX-MACHINE-PRODUCT-KEY replaces VLAX-PRODUCT-KEY in releases AutoCAD 2013 and later.

VLAX-USER-PRODUCT-KEY - Returns the AutoCAD product key from the User hive in the Windows Registry.  (ie. "Software\\Autodesk\\AutoCAD\\R19.0\\ACAD-B001:409")

In AutoCAD these 2 strings will always be identical. The strings will only be different in Core Engine host applications other than AutoCAD.

VLAX-PRODUCT-KEY - Returns the AutoCAD Windows registry path. Old function, still available.

The Core Engine host AcCoreConsole.exe that ships with AutoCAD can be configured to run ’isolated’ in which case the vlax-user-product-key will return a different string than vlax-machine-product-key. Normally, it shares the HKLM/HKCU keys with AutoCAD. However, you can configure it with the /isolate switch to use a different HKCU root key. The /isolate switch can be used to prevent the changes to the system variables from affecting regular AutoCAD. This is useful when you want to set sysvars or other registry based configuration setting for AcCoreConsole.exe but you don’t want these settings to change for your AutoCAD instance.

When using the /isolate switch you also need to include an existing or new userid.

Example: AcCoreConsole.exe /isolate batch

When that is done you will notice how vlax-user-product-key will return a different value compared with the other functions:

Command: (vl-load-com)

Command: (princ (vlax-product-key))
Software\Autodesk\AutoCAD\R19.0\ACAD-B004:409
"Software\\Autodesk\\AutoCAD\\R19.0\\ACAD-B004:409"

Command: (princ (vlax-user-product-key))
Software\Autodesk\AutoCAD\R19.0\CoreUser\batch
"Software\\Autodesk\\AutoCAD\\R19.0\\CoreUser\\batch"

Command: (princ (vlax-machine-product-key))
Software\Autodesk\AutoCAD\R19.0\ACAD-B004:409
"Software\\Autodesk\\AutoCAD\\R19.0\\ACAD-B004:409"

Here AutoCAD registry product keys are explained further. The registry product keys are not the same thing as the Autodesk Product Keys that are used to differentiate products that are both sold independently and as part of a product suite.

Wednesday, September 12, 2012

Visual LISP and ActiveX/VBA Comparison

The following table compares AutoLISP/Visual LISP functions in AutoCAD with the similar ActiveX, VBA, and Visual Basic 6 functions and operators. The ActiveX Automation equivalents are indicated by “AutoCAD.Application.” and the Visual Basic 6 equivalents are listed as a function or operator. This chart can be useful when you jump between working in different languages as well as if you know one of them and want to learn the other.

AutoLISP function ActiveX, VBA, or Visual Basic 6 equivalent
+ (addition) + (addition operator)
- (subtraction) - (subtraction operator)
* (multiplication) * (multiplication operator)
/ (division) / (division operator)
= (equal to) = (equal to comparison operator)
/= (not equal to) <> (not equal to comparison operator)
< (less than) < (less than comparison operator)
<= (less than or equal to) <= (less than or equal to comparison operator)
> (greater than) > (greater than comparison operator)
>= (greater than or equal to) >= (greater than or equal to comparison operator)
~ (bitwise not) Not operator
1+ (increment) Use + (addition operator)
1- (decrement) Use - (subtraction operator)
abs Abs function
acad_colordlg Not provided
acad_helpdlg Search for HELP in the online Help index
acad_strlsort Search for SORT in the online Help index
action_tile Use the Dialog Editor
add_list Use the Dialog Editor
ads AutoCAD.Application.ListADS method
alert MsgBox function
and And operator
angle AutoCAD.Application.ActiveDocument.Utility.
AngleFromXAxis method
angtof AutoCAD.Application.ActiveDocument.Utility.
AngleToReal method
angtos AutoCAD.Application.ActiveDocument.Utility.
AngleToString method
append Use array manipulation functions
apply Not provided
arx AutoCAD.Application.ListARX method
arxload AutoCAD.Application.LoadARX method
arxunload AutoCAD.Application.UnloadARX method
ascii Asc function
assoc Not provided
atan Atn function
atof CDbl Function
atoi CInt Function
atom Search for IS in the online Help index
atoms-family Not provided
autoarxload Not provided
autoload Not provided
Boole Use logical operators
boundp Search for IS in the online Help index
car/cdr Use array manipulation functions
chr Chr function
client_data_tile Use the Dialog Editor
close AutoCAD.Application.Documents.Close method
command AutoCAD.ActiveDocument.SendCommand method
cond Select Case statement
cons Use array manipulation functions or AutoCAD.Application.collection.Add<entityname> method
cos Cos function
cvunit Use the conversion functions
defun The keywords Function and End Function
dictadd AutoCAD.Application.ActiveDocument.Dictionaries.
Add method
dictnext AutoCAD.Application.ActiveDocument.Dictionaries.
Item method
dictremove AutoCAD.Application.ActiveDocument.Dictionaries.
Dictionary.Delete method
dictrename AutoCAD.Application.ActiveDocument.Dictionaries.
Dictionary.Rename method
dictsearch AutoCAD.Application.ActiveDocument.Dictionaries.
Dictionary.GetName and GetObject methods
dimx_tile and dimy_tile Use the Dialog Editor
distance AutoCAD.Application.Utility.
GetDistance for interactive method.
distof Not provided
done_dialog Use the Dialog Editor
end_image Use the Dialog Editor
end_list Use the Dialog Editor
entdel AutoCAD.Application.ActiveDocument.
collection_object.Delete method
entget AutoCAD.Application.ActiveDocument.
collection_object.property properties
entlast AutoCAD.Application.ActiveDocument.Modelspace.
Item(count-1)
entmake AutoCAD.Application.ActiveDocument.Modelspace.
Add<entityname> method
entmakex AutoCAD.Application.ActiveDocument.Modelspace.
Add<entityname> method
entmod Use any of the read-write properties for the object
entnext AutoCAD.Application.ActiveDocument.collection.
Item method
entsel AutoCAD.Application.ActiveDocument.SelectionSets object/methods/properties
entupd AutoCAD.Application.ActiveDocument.Modelspace.
object.Update method
eq Not provided
equal Eqv operator
*error* Error object/method/properties
eval Not provided
exit AutoCAD.Application.Quit method
exp Exp function
expand Not provided
expt ^ (exponentiation operator)
fill_image Use the Dialog Editor
findfile Dir function
fix Fix, Int, Cint functions
float CDbl Function
foreach For Each...Next statement
gc AutoCAD.Application.ActiveDocument.PurgeAll
gcd Not provided
get_attr Use the Dialog Editor
get_tile Use the Dialog Editor
getangle AutoCAD.Application.ActiveDocument.Utility.
GetAngle method
getcfg AutoCAD.Application.Preferences.property property
getcname Not provided
getcorner AutoCAD.Application.ActiveDocument.Utility.
GetCorner method
getdist AutoCAD.Application.ActiveDocument.Utility.
GetDistance method
getenv AutoCAD.Application.Preferences.property property
getfiled Use the file dialog
getint AutoCAD.Application.ActiveDocument.Utility.
GetInteger method
getkword AutoCAD.Application.ActiveDocument.Utility.
GetKeyword method
getorient AutoCAD.Application.ActiveDocument.Utility.
GetOrientation method
getpoint AutoCAD.Application.ActiveDocument.Utility.
GetPoint method
getreal AutoCAD.Application.ActiveDocument.Utility.
GetReal method
getstring AutoCAD.Application.ActiveDocument.Utility.
GetString method
getvar AutoCAD.Application.GetVariable method
graphscr AppActivate AutoCAD.Application.Caption
grclear Obsolete function
grdraw Not provided
grread Not provided
grtext AutoCAD.Application.ActiveDocument.Utility.Prompt
grvecs Not provided
handent AutoCAD.Application.ActiveDocument.ModelSpace.
object.Handle property
help Search for HELP in the online Help index
if If… Then… Else statement
initget AutoCAD.Application.ActiveDocument.Utility.
InitializeUserInput
inters AutoCAD.Application.ActiveDocument.Modelspace.
object.IntersectWith
itoa Str function
lambda Not provided
last arrayname(UBound(arrayname))
length UBound function
list ReDim statement
listp IsArray function
load_dialog Use the Dialog Editor
load AutoLISP is not supported through Automation
log Log function
logand And function
logior Or function
lsh Imp function
mapcar Not provided
max Max function
mem Not provided
member Use collection
menucmd AutoCAD.Application.MenuBar object
menugroup AutoCAD.Application.MenuGroup object
min Min function
minusp Use < 0 syntax
mode_tile Use the Dialog Editor
namedobjdict AutoCAD.Application.ActiveDocument.Dictionaries collection
nentsel AutoCAD.Application.ActiveDocument.SelectionSets.
SelectionSet.SelectAtPoint method
nentselp AutoCAD.Application.ActiveDocument.SelectionSets.
SelectionSet.SelectAtPoint method
new_dialog Use the Dialog Editor
not Use the logical operators
nth Use object(n) syntax
null IsNull function
numberp TypeName function
open Open function
or Use the logical operators
osnap Not provided (You can use the SetVariable method to control the OSMODE system variable.)
polar AutoCAD.Application.ActiveDocument.Utility.
PolarPoint method
prin1 AutoCAD.Application.ActiveDocument.Utility.Prompt
princ AutoCAD.Application.ActiveDocument.Utility.Prompt
print AutoCAD.Application.ActiveDocument.Utility.Prompt
progn Not provided
prompt AutoCAD.Application.ActiveDocument.Utility.Prompt
quit AutoCAD.Application.Quit method
quote Not provided
read Not provided
read-char Input function
read-line Line Input function
redraw AutoCAD.Application.ActiveDocument.Modelspace.
object.Update method
regapp AutoCAD.Application.ActiveDocument.
RegisteredApplications.Add method
rem Mod function
repeat For… Each, While,
reverse Not provided
rtos AutoCAD.Application.ActiveDocument.Utility.
RealToString method
set Set function
set_tile Use the Dialog Editor
setcfg AutoCAD.Application.Preferences.property property
setfunhelp Not provided
setq Set function
setvar AutoCAD.Application.SetVariable method
sin Sin function
setview AutoCAD.Application.ActiveDocument.Viewports.
Viewport.SetView method
slide_image Use the Dialog Editor
snvalid Not provided
sqrt Sqr function
ssadd AutoCAD.Application.ActiveDocument.SelectionSets.
Add method
ssdel AutoCAD.Application.ActiveDocument.SelectionSets.
SelectionSet.Delete method
ssget AutoCAD.Application.ActiveDocument.SelectionSets.
SelectionSet.SelectOnScreen method
ssgetfirst Not provided
sslength AutoCAD.Application.ActiveDocument.SelectionSets.
SelectionSet.Count method
ssmemb Compare ID of object with the SelectionSet members
ssname AutoCAD.Application.ActiveDocument.SelectionSets.
SelectionSet.Name property
ssnamex Not provided
sssetfirst AutoCAD.Application.ActiveDocument.
PickfirstSelectionSet
startapp Shell function
start_dialog Use the Dialog Editor
start_image Use the Dialog Editor
start_list Use the Dialog Editor
strcase StrConv function
strcat & operator
strlen Len function
subst Not provided
substr Mid function
tablet Not provided
tblnext AutoCAD.Application.ActiveDocument.
collection_object.Item method
tblobjname AutoCAD.Application.ActiveDocument.
collection_object.Name method
tblsearch AutoCAD.Application.ActiveDocument.
collection_object.Name method
term_dialog Use the Dialog Editor
terpri Not provided
textbox AutoCAD.Application.ActiveDocument.space.object.
GetBoundingBox method
textpage Not provided
textscr Not provided
trace Not provided
trans AutoCAD.Application.ActiveDocument.Utility.
TranslateCoordinates method
type TypeName function
unload_dialog Use the Dialog Editor
untrace Not provided
vector_image Use the Dialog Editor
ver AutoCAD.Application.Version property
vports AutoCAD.Application.ActiveDocument.
Viewports collection
wcmatch Like operator
while While… Wend
write-char Print function
write-line Print function
xdroom Not provided
xdsize Not provided
zerop Use = 0 syntax

Source: AutoCAD 2013 Active X Developer’s Guide on AutoCAD Developer Center. To utilize the documentation with the VBA IDE or Visual LISP IDE, download and extract the contents of the ZIP file to the following location: C:\Program Files\Common Files\Autodesk Shared

Wednesday, September 5, 2012

AutoCAD ActiveX API History

There have been a number of changes to the AutoCAD ActiveX API since its first introduction with AutoCAD R14. Typically this API is used by AutoLISP/Visual LISP and AutoCAD VBA.

A full history of the additions, changes, and removals made to the ActiveX API is now available in the AutoCAD 2013 ActiveX Developer’s Guide (acad_aag.chm) that is found at AutoCAD Developer Center. To utilize the documentation with the VBA IDE or Visual LISP IDE, download and extract the contents of the ZIP file to the following location: C:\Program Files\Common Files\Autodesk Shared

Via AutoCAD DevBlog

Tuesday, August 21, 2012

AutoLISP and VBA Security Controls in AutoCAD 2013 SP1

AutoCAD 2013 was just updated with AutoCAD 2013 Service Pack 1 and here are more details from Autodesk Knowledge Base TS20327810:

Due to the appearance of malicious applications that use AutoLISP® and VBA, Autodesk is providing controls for several new security measures with Service Pack 1 for AutoCAD® 2013. Equivalent service packs for AutoCAD-based vertical applications will also be released.

These new controls affect the following products when Service Pack 1 is installed:

  • AutoCAD 2013
  • AutoCAD® 2013 for Mac®
  • AutoCAD 2013-based vertical applications

AutoCAD LT® does not run AutoLISP or VBA applications and does not require these security measures.

What the New Controls Do

The new controls provide the following security measures:

  • Minimize the possibility of loading and running unauthorized or malicious AutoLISP and VBA applications by controlling the folder location from which AutoLISP and VBA applications are automatically loaded (AUTOLOADPATH system variable).
  • Limit the impact of malicious AutoLISP and VBA applications by disabling autoloading of default AutoLISP and VBA applications (AUTOLOAD system variable).
  • Facilitate the cleanup process by completely disabling AutoLISP at startup (/nolisp startup switch).

Control AutoLoading by Specifying a Folder Location

The AUTOLOADPATH system variable controls the folders from which AutoCAD automatically loads the following AutoLISP and VBA files:

  • acad.lsp
  • acad.fas
  • acad.vlx
  • acaddoc.lsp
  • acaddoc.fas
  • acaddoc.vlx
  • acad.dvb

The default value of AUTOLOADPATH is the empty string ("") or period (.). When set to either of these values, autoloading follows legacy behavior. It automatically loads the listed files without restrictions in the following order:

  1. The AutoCAD startup folder
  2. The folder of the current drawing
  3. The folders in the AutoCAD Support Files search path

This default setting is not recommended, because malicious applications can anticipate the folders listed above.

To minimize the possibility of loading a malicious application, always set the AUTOLOADPATH system variable to the unique folder where your authorized applications are located.

To specify multiple folders, use a semicolon as the separator. The value of AUTOLOADPATH is saved in each named profile.

Note: To enable the autoloading changes to acad.dvb, uninstall the original AutoCAD 2013 VBA Enabler, and download and install the latest AutoCAD 2013 VBA module that was updated for the changes made in Service Pack 1 for AutoCAD 2013.

Control Autoloading of AutoLISP and VBA Applications

To control whether AutoLISP applications and acad.dvb is automatically loaded at startup, use the AUTOLOAD system variable:

  • Setting AUTOLOAD to 0 prevents the previously listed AutoLISP files and acad.dvb from being automatically loaded, which is useful for debugging.
  • Setting AUTOLOAD to 1 restores the autoloading behavior, which now depends on the value of the AUTOLOADPATH system variable.

Disable Loading All AutoLISP Applications

To prevent loading any AutoLISP applications, use the /nolisp startup switch to disable AutoLISP in the current AutoCAD session, including all LSP, FAS, and VLX files.

If your system has already been impacted by a malicious application, this option helps you debug and clean up your installation and any impacted files.

The read-only LISPENABLED system variable reports whether AutoLISP is enabled in the current AutoCAD session. If LISPENABLED is 0, AutoLISP has been disabled by the /nolisp startup switch.

Note: Disabling AutoLISP also prevents the Express Tools and some AutoCAD command tools from functioning and should only be used in emergency situations.

For more information on how to use startup switches refer to the solution, Startup switches for AutoCAD.

Changes to acad2013.lsp and acad2013doc.lsp Autoloading Behavior

The acad2013.lsp and acad2013doc.lsp files will now be loaded only from their default installation folders:

<installation folder>\Support
<installation folder>\Support\<language>

Changes to the Options Dialog Box

The “Load acad.lsp with every drawing” checkbox on the System tab of the Options dialog box (ACADLSPASDOC system variable) is disabled when AUTOLOAD or LISPENABLED has a value of 0.

For more information about these controls see the readme forAutoCAD 2013 Service Pack 1.

Recommended Setup and Repair Workflow

For the best protection from malicious AutoLISP and VBA applications set AUTOLOADPATH to a unique folder location and set AUTOLOAD to 1.

If your installation has already been impacted by a malicious application that runs on startup, following these general steps:

  1. Start your AutoCAD-based product with the /nolisp switch.
  2. Find and remove all malicious code.
  3. Repair any affected files.
  4. Set AUTOLOADPATH to a unique folder location and set AUTOLOAD to 1.

After taking these steps, you can remove the /nolisp startup switch from the shortcut properties of the program’s desktop icon, and resume the normal operation of your AutoCAD-based application.

See also ACAD/Medre.A Malware AutoCAD AutoLISP Malware!

UPDATE: AutoCAD 2013 Service Pack 1.1

AutoCAD 2013 SP1 & AutoCAD LT 2013 SP1

AutoCAD 2013 Service Pack 1 is now available as well as AutoCAD LT 2013 SP1.

UPDATE: AutoCAD 2013 Service Pack 1.1

As a result of recent ACAD/Medre.A Malware AutoCAD AutoLISP Malware! and other appearances of malicious applications Autodesk has introduced options to control the operation of AutoLISP and VBA applications in AutoCAD. Worth noting is that if you use VBA consider to download and install the latest AutoCAD 2013 VBA module that was updated for the changes made in Service Pack 1 for AutoCAD 2013. See reasons why further down.

_VERNUM is now “G.112.0.0 (UNICODE)” (without SP1 it is “G.55.0.0 (UNICODE)”)

Here is what Autodesk has to say about it and where you can download it for AutoCAD as well as download it for AutoCAD LT:

You can apply this update to AutoCAD 2013 running on all supported operating systems and languages. Consult the readme file for installation instructions and more details on the primary issues resolved by this update. Be sure to install the correct update (32-bit or 64-bit) for your software and operating system.
This Service Pack can be applied to AutoCAD 2013 installed as a standalone application as well as AutoCAD 2013 installed from the following Autodesk Design Suites.

  • AutoCAD Design Suite 2013
  • Autodesk Building Design Suite 2013
  • Autodesk Factory Design Suite 2013
  • Autodesk Infrastructure Design Suite 2013
  • Autodesk Plant Design Suite 2013
  • Autodesk Product Design Suite 2013

NOTE: You can also use Autodesk Exchange to install the Live Update Maintenance Patches, which will automatically show the correct Service Pack for your product.

For Windows 7 users: When you apply this Service Pack while running AutoCAD or AutoCAD LT, do not click the "Automatically close applications and attempt to restart them after setup is complete" option. Instead, close AutoCAD or AutoCAD LT manually, and click the "Do not close applications. (A Reboot may be required.)" option in the dialog box. It is recommended that you reboot your system after installing the Service Pack.

Problems Reported with the Customer Error Reporting Utility

As a result of detailed information from customers who used the Customer Error Reporting Utility, a number of problems were identified and fixed. Updates have been made in the following commands and features:

3D Navigation Tools

  • Unexpected exit while panning.
  • Occasional crash related to navigating in 3D drawing.

3D Modeling

  • Occasional crash while selecting a face during a Presspull operation.
  • Crash when opening multiple 3D drawings containing a large number of 3D objects.

Autodesk 360

  • Crash in Japanese AutoCAD when logging into Autodesk 360 from the Options dialog box.
  • Occasional crash when opening a drawing that contains xrefs, when logged in to Autodesk 360.

CUI (Customize User Interface)

  • Occasional crash while loading a custom CUI file.
  • Unhandled exception occurs while clicking the Customize button from Quick Properties palette on a computer running .NET 4.5.

Design Center

  • Occasional crash while working with DesignCenter.

DGN Support

  • Fatal error when attaching or importing certain DGN files.

Dimensions

  • Crash after undoing the creation of a non-associative continued or non-associative baseline dimension.

Hatch

  • Occasional crash while zooming during Hatchedit.

InfoCenter

  • Crash when clicking any option from the Stay Connected button in the title bar when no drawings are open.

Inquiry

  • Crash while calculating area of a polyline that contains at least one segment that has been reduced to zero length.

Plot

  • Occasional crash while plotting to PDF.
  • Crash while plotting to a PDF file and the PDF driver is not present.

Point Cloud

  • Crash if the PCG file used to create a point cloud object does not exist.

Express Tools

  • Occasional crash during a MOCORO (Move/Copy/Rotate) command.

Startup

  • Crash due to corrupt graphics cache files on startup.
  • Crash occurs while canceling a LISP routine that runs at program startup.

General

  • Crash on undo/redo after adding 256 or more objects to a group.
  • Crash while switching IME language for double-byte characters, when Dynmode is turned off.
  • Crash on viewing thumbnail in AutoCAD 2012 when installed side-by-side with AutoCAD 2013.
  • Occasional crash when exploding splines created by third-party applications.
  • Crash when AutoCAD exits on computers running .NET 4.5.

General Service Pack Updates

The following defects have been fixed:

3D Navigation Tools

  • The Keep Scene Upright option in the 3DConnexion Settings dialog box cannot not be changed.

3D Modeling

  • Issue with the centroid computation for 3D solids.

Action Recorder

  • Action macros recorded in previous releases are not working correctly in AutoCAD 2013.

Autodesk 360

  • Pressing F1 does not display Help for the ONLINESYNCSETTINGS dialog box.
  • Drawing files with names containing language-specific characters do not get saved to Autodesk 360.
  • User is not automatically logged in when launching Autodesk 360 from the AutoCAD ribbon.
  • Sometimes the Share Drawing dialog box opens behind the main application window.

Customization Sync

  • Customization Sync progress animation runs continuously.
  • Customization Sync does not sync new custom commands in tool palettes.

DGN Support

  • Export to DGN does not use the Global Origin specified in the seed file.
  • The DGNIMPORTUNITCONVERSION system variable is missing in AutoCAD LT.

Display Drivers

  • Integrated chipsets are unable to return available video memory correctly.
  • When using COPYCLIP and PASTECLIP on a 64-bit operating system, you might see the object color change from the original color.

Dimensions

  • Existing drawings lose Qleader settings when edited in AutoCAD 2013.
  • Dimensions created using the Perpendicular object snap will shift when the drawing geometry is moved, copied, or otherwise modified.

External Reference (XREF)

  • External reference drawings (XREFs) show as unresolved in AutoCAD 2013.

Hatch

  • The Hatch Preview option is not available from the context menu when creating a hatch.

Field

  • An object's angular property uses linear format instead of angular format in the Field dialog box.

MLeader

  • Multileaders incorrectly display a dot at the content block's insertion point.
  • If the Extend Leaders to Text option is turned on, the text in multileaders moves if the drawing is opened or edited in AutoCAD 2013.

Modify

  • The SCALE command gets cancelled while dragging when small scale factor is acquired with object snap turned on.

PDF Export

  • Plotting to a PDF file with a plot style causes wipeouts to appear black.

Performance

  • Slow performance while running a large script.
  • Slow performance while creating Layers quickly.

Plot

  • Using Plot Preview turns the Command window back on.

Properties Palette

  • When an object is selected, the tooltip is missing in the Properties Palette for the following languages: Traditional Chinese, Czech, Russian, and Hungarian.

Ribbon

  • The Visibility drop-down control on the Block Editor Ribbon is not working properly when property preview is enabled.

Selection

  • Pressing Shift with a window selection fails to remove multiple Drawing Views from the selection set on a layout.

Sheet Set Manager

  • A high network utilization will result with the SMB V2 (Server Message Block) protocol while working with the Sheet Set Manager.

Visual Lisp

  • Menucmd does not display the drop-down menu when the Command window is docked.

General

  • Error on launching AutoCAD after the QuickCalc palette is anchored.
  • INSBASE value is incorrect for a drawing created using -WBLOCK.

New /nolisp Startup Switch and Related System Variables

This Service Pack introduces options to control the operation of AutoLISP and VBA applications in AutoCAD. The new controls provide the following security measures:

  • Minimize the possibility of loading and running unauthorized or malicious AutoLISP and VBA applications by controlling the folder location from which AutoLISP and VBA applications are automatically loaded (AUTOLOADPATH system variable).
  • Limit the impact of malicious AutoLISP and VBA applications by disabling autoloading of default AutoLISP and VBA applications (AUTOLOAD system variable).
  • Facilitate the cleanup process by completely disabling AutoLISP at startup (/nolisp startup switch).

For more information see this document. AutoLISP and VBA Security Controls in AutoCAD 2013 SP1

Note: To enable the autoloading changes to acad.dvb, uninstall the AutoCAD 2013 VBA Enabler, and download and install the latest AutoCAD 2013 VBA module that was updated for the changes made in Service Pack 1 for AutoCAD 2013.

New /nolisp Startup Switch

Start AutoCAD with this switch to disable AutoLISP execution in the current AutoCAD session, including all LSP, FAS, and VLX files. This switch is useful for preventing malicious AutoLISP code from automatically loading and executing.

Disabling AutoLISP has the following effects:

  • Attempting to load any LISP file will fail.
  • Attempting to copy and paste AutoLISP code into the Command window will fail silently.

Note: Disabling AutoLISP will prevent the Express Tools and some AutoCAD command tools from functioning and should only be used in emergency situations.

LISPENABLED (System Variable)

Indicates whether AutoLISP is enabled for the current AutoCAD session.

(Read-only)
Type: Integer
Saved in: Not saved
Initial value: 1

0 - AutoLISP is disabled
1 - AutoLISP is enabled

Disabling AutoLISP has the following effects:

  • Attempting to load any LISP file will fail.
  • Attempting to copy and paste AutoLISP code into the Command window will fail silently.
This system variable is controlled by the /nolisp startup switch.

AUTOLOAD (System Variable)

Controls whether AutoCAD autoloads acad.lsp/fas/vlx, acaddoc.lsp/fas/vlx, acad.dvb files.

Type: Integer
Saved in: Named Profile/Registry
Initial value: 1

Values:
0 - None of the following 7 AutoLISP/VBA files will be automatically loaded

  • acad.lsp
  • acad.fas
  • acad.vlx
  • acaddoc.lsp
  • acaddoc.fas
  • acaddoc.vlx
  • acad.dvb
1 - autoloads the 7 files depending on the value of the AUTOLOADPATH system variable.

AUTOLOADPATH (System Variable)

Controls the folder from where AutoCAD loads acad.lsp/fas/vlx, acaddoc.lsp/fas/vlx, acad.dvb files.

Type: String
Saved in: Named Profile/Registry
Initial value: ""

Valid strings include the following:
"<folder path or paths separated by semicolons>" = Automatically loads the acad.lsp/fas/vlx, acaddoc.lsp/fas/vlx, acad.dvb files only in the specified folders and no other locations, including the current drawing folder. To minimize the possibility of loading a malicious application, always set the AUTOLOADPATH system variable to the unique folder where your authorized applications are located.
"" (empty string) or "." (period) - No path restriction. Automatically loads the acad.lsp/fas/vlx, acaddoc.lsp/fas/vlx, acad.dvb files found in the AutoCAD startup folder, the drawing folder, and the AutoCAD search path, in that order. This duplicates AutoCAD 2012 behavior and is not recommended.

Changes to acad2013.lsp and acad2013doc.lsp Autoloading Behavior

The acad2013.lsp and acad2013doc.lsp files will now be loaded only from their default installation folders:
<install folder>\Support
<install folder>\Support\<language>

Changes to the Options Dialog Box

The "Load acad.lsp with every drawing" checkbox on the System tab of the Options dialog box (ACADLSPASDOC system variable) is disabled when AUTOLOAD or LISPENABLED has a value of 0.

Recommended Setup and Repair Workflow

For the best protection from malicious AutoLISP and VBA applications set AUTOLOADPATH to a unique folder location and set AUTOLOAD to 1.

If your installation has already been impacted by a malicious application that runs on startup, following these general steps:

1. Start your AutoCAD-based product with the /nolisp startup switch.
2. Find and remove all malicious code.
3. Repair any affected files.
4. Set AUTOLOADPATH to a unique folder location and set AUTOLOAD to 1.

After taking these steps, you can remove the /nolisp startup switch from the shortcut properties of the program's desktop icon, and resume the normal operation of your AutoCAD-based application.

Tuesday, June 19, 2012

Export layouts to separate drawings freeware for AutoCAD

Want to export layouts to separate drawings? This can be done with LayoutsToDwgs.lsp that recently was updated to handle Map prompt with WBLOCK “Include AutoCAD Map information in the export? [Yes/No] <Y>:”.

Export Paper Space tabs to individual drawings made easy and works for most AutoCAD versions and verticals.

Monday, June 18, 2012

How to automatically remove Autodesk 360 icon in AutoCAD 2013 file dialog boxes

AutoCAD 2013 came with the new Autodesk 360 icon showing up in the places list in file dialog boxes like the open or save as drawing dialog boxes. If you as a CAD Manager wants to remove it automatically from a lot of machines it can be done. To manually remove it is easy, just right click on any of the icons in the places list and you can remove, add or restore. If you have a network drive or folder location it is even possible to add it too.

I’ve updated the RemIcons.lsp AutoLISP code so that any of the icons Autodesk 360, Buzzsaw, RedSpark, Point A and FTP can be removed or added. There is also a VBScript sample included. The icons History, Documents, Favorites and Desktop can also be removed but I’ve not included that in the code. A tip is to look in the registry (where R19.0, ACAD-B004:409 and <<Unnamed Profile>> needs to be changed depending on AutoCAD version, vertical and profile): HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R19.0\ACAD-B004:409\Profiles\<<Unnamed Profile>>\Dialogs\AllAnavDialogs

Monday, April 23, 2012

No source available in Visual Studio debugging AutoCAD .NET code

AutoCAD 2011 through AutoCAD 2013 is being in progress migrating to fiberless operation. See Wikipedia for more about Fibers.

This affects ARX application using acedCommand (replaced with acedCommandS and acedCommandC), acedCmd (replaced with acedCmdS and acedCmdC) as well as ARX or .NET application using AcApDocManager functions to create, close or activate documents. If P/Invoke has been used to access acedCommand in .NET API, it will not work.  Finally LISP *error* handlers using the (command) function. In most cases you simply have to replace (command) from within an *error* handler with calls to the new (command-s) function. Worth knowing is that (command-s) is significantly faster than (command). A limitation with (command-s) is that “pause” tokens cannot be used and the expression must represent complete commands..

AutoCAD 2011 introduced two variables FIBERWORLD and NEXTFIBERWORLD to help programmers to test and migrate code.
FIBERWORLD = 1 if Fibers are being used.
Change NEXTFIBERWORLD to 0 to disable fibers and 1 to enable fibers. Close and relaunch AutoCAD, or close all the current documents in AutoCAD and then open/new one.

If breakpoints in custom forms being opened using ShowModalDialog or ShowDialog cannot be hit when debugging .NET addins in Visual Studio 2010 the workaround is to set AutoCAD to run in fiberless operation (FIBERWORLD = 0). When you try to debug you may see this message in Visual Studio: No Source Available. No symbols are loaded for any call stack frame. The source code cannot be displayed.

The problem that you may have with FIBERWORLD = 0 is that the Ribbon is not working, you may get strange crashes and have other issues. If you cannot type any commands you may need to disable and enable the command line using the application menu and search for command. If you need to work on a specific drawing it can help to load it automatically from within the Visual Studio debugger as the open command may break the command functionality.

When ready remember to set back AutoCAD to run in fiber mode again.

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner