Showing posts with label VBA. Show all posts
Showing posts with label VBA. Show all posts

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")

Wednesday, September 4, 2013

AutoCAD performance issues and VBA

Here is a reason why you may not want to use VBA if you have 64-bit version of AutoCAD 2008 - AutoCAD 2013.

Background

Initializing VBA System...

By just initializing the VBA system running for example VBAIDE, some commands in AutoCAD will take 10 times longer. It might be more or less depending on different factors. No DVB needs to even be loaded for this to happen.

Using ProcMon I found that without VBA initialized and loaded a QSAVE command resulted in less than 2100 registry and file events.

But with VBA initialized QSAVE caused almost 950,000 registry and file events. No wonder QSAVE took so long. Many file and registry events are done multiple times and seems to be related to the number of folders AutoCAD usually search files in.

Changing system variables like INDEXCTL, SAVEFIDELITY and PROXYGRAPHICS did not help even though they in other cases can speed up the time it takes to save drawings.

Why is this happening?

With VBA component initialized, AutoCAD has to check for any callbacks registered in VBA component even for standard AutoCAD commands. This verification is consumes time as the communication is across processes.

Autodesk ships the 32-bit VBA version in an out-of-process server with 64-bit AutoCAD (up until AutoCAD 2013 where VBA 6.3 is used). Therefore, a lot of marshaling is required going between the out-of-process VBA server and 64-bit AutoCAD. As a result, 64-bit VBA is slower than 32-bit VBA.

This problem should not exist in AutoCAD 2014 because VBA 7.1 is used and is available in a native 64-bit version, but for some reason it did for me. Eventually I figured out that reinstalling AutoCAD 2014 and VBA completely solved the issue.

Solution

Downgrading to AutoCAD 32-bit on Windows 32-bit is probably not desirable as a solution. A better solution or workaround is to upgrade to AutoCAD 2014 (but that could cause problems with 32bit VB6 controls that are not available for 64-bit) or better yet porting the VBA application to .NET DLL (using VB.NET or C#). JTB World can help with porting of VBA to .NET.

See also this post: AutoCAD 2014 supports VBA 64-bit

Monday, July 8, 2013

VBA InsertBlock Filer error and solution

Having VBA code like this can cause troubles.

Set objBlock = ThisDrawing.ModelSpace.InsertBlock(Point, "C:\demo.dwg", 1, 1, 1, 0)

With this error: Error description: “Filer error”   Error number: -2145386445

For some reason it is inconsequent because sometimes I found it working and sometimes it doesn’t. I first thought it had to do with the case of the file name did not match. I tried "C:\DEMO.DWG" and suddenly it worked but then again it didn’t. Not sure but it seems to work fine the first time AutoCAD is launched and after that it just don’t work longer.

I have only tested this in AutoCAD 2014 64-bit and Windows 8 so it might work differently with other setups but after I run into this I found that other have had similar problems in older AutoCAD versions too.

The workaround is to use a variable for the block name.

blockName="C:\demo.dwg"
Set objBlock = ThisDrawing.ModelSpace.InsertBlock(Point, blockName, 1, 1, 1, 0)

Tuesday, March 26, 2013

AutoCAD 2014 supports VBA 64-bit

Yes, VBA is still available for AutoCAD in the latest 2014 even though it was not supposed to. 64bit VBA (Visual Basic for Applications) is finally also available in 64-bit for AutoCAD. The performance problems, with previous releases of 64bit AutoCAD when using VBA, should be now be gone.

Note that 32bit VB6 controls will fail on 64bit.

The version of VBA that is available for AutoCAD 2014 is VBA 7.1.

Microsoft has introduced two new conditional compilation constants: “VBA7” and “Win64”.

#If VBA7 Then
    'Use new VBA7 functionality
#Else
    'Use old VBA functionality
#End If

The Win64 constant enables a separation between the 32 and 64 bit version of VBA and can be used to ensure that code is only executed when VBA runs in the correct mode.

For AutoCAD 2014 64-bit VBA is not supported on Windows XP Professional.

Find the VBA for AutoCAD downloads here at http://www.autodesk.com/vba-download.

For reference these resources can be helpful: Compatibility Between the 32-bit and 64-bit Versions of Office 2010 and 64-Bit Visual Basic for Applications Overview.

Previous post Learn how to migrate from VBA to .NET for AutoCAD, VBA 7 for AutoCAD 2012? and VBA Download for AutoCAD 2013.

Sometimes it can still make sense to migrate from VBA to .NET for AutoCAD and JTB World provides this service. Welcome to contact us with your needs.

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.

Monday, April 9, 2012

VBA Download for AutoCAD 2013

VBA (Microsoft Visual Basic for Applications) is still available in AutoCAD 2013 but it is not included with the installation media. Find the VBA for AutoCAD downloads here at http://www.autodesk.com/vba-download. There downloads are found also for AutoCAD 2010, AutoCAD 2011, AutoCAD 2012 in both 32-bit and 64-bit.

If you have existing VBA this can be good news but don’t get started to develop anything new in VBA for AutoCAD as we don’t know if this will be the last release with VBA or not. Consider to convert the code to .NET (C# or VB.NET) and if you like help with it please feel free to contact us.

Friday, March 25, 2011

AutoCAD 2012 VBA Enabler

Autodesk will continue to “unofficially” support VBA in its 2012 products, thus VBA (Visual Basic for Applications) is still available and as a separate installer.
http://www.autodesk.com/vba-download

The Express Tools command REVERT still requires VBA.

Trying to click on Installation Help, System Requirements or Readme does not work.

At least the actual installation works. If you have AutoCAD 2012 verticals like AutoCAD Architecture 2012, AutoCAD MEP 2012, AutoCAD Electrical 2012, AutoCAD Map 3D 2012, and AutoCAD Mechanical 2012, and AutoCAD Structural Detailing 2012 or AutoCAD Civil 3D 2012 the installer will install for all of them.

Software developers are strongly encouraged by Autodesk to base all future Microsoft Windows based development for AutoCAD based products on the Microsoft .NET Framework (VB .NET, C#, managed C++ etc).

If Autodesk’s future versions (AutoCAD 2013?) still will be able to run VBA or not only future can tell but don’t hold your breath.

JTB World offers fee based porting of LISP or VBA applications to .NET.

Friday, May 14, 2010

VBA 7 for AutoCAD 2012?

VBA is having 7 lives it seems.

Office 2010 is now available in a pure 64-bit version. How about VBA then? This document mentions that with the introduction of the new 64-bit version of Microsoft Office 2010, a new version of Microsoft Visual Basic for Applications (VBA), known as Microsoft Visual Basic for Applications 7.0 (VBA 7), is being released to work with both 32-bit and 64-bit applications.

VBA 7 is a new code base, replacing the earlier version of VBA. VBA 7 exists for both the 32-bit and 64-bit versions of Office 2010.

This is an old quote from Microsoft. “We understand that VBA is a critical capability for large numbers of our customers; accordingly, there is no plan to remove VBA from future versions of Excel.”

Autodesk is having plans to remove support for VBA in AutoCAD 2012 and have prepared for that by having VBA as an optional installer. Now that Microsoft officially keep supporting VBA will Autodesk follow along and make use of VBA 7?

See also Learn how to migrate from VBA to .NET for AutoCAD.

Tuesday, May 11, 2010

Autodesk possible cross-product scripting language/IDE

This post has best before date of May 30th, 2010.

Autodesk is researching candidates for a possible cross-product scripting language/IDE. What is your preferred language?

  • Javascript/ECMAScript
  • Python
  • Ruby
  • Lua
  • VBA/VBScript

If you want to make your voice heard on this question and others take the survey for the product you work with.

AutoCAD®
AutoCAD® Civil 3D®
AutoCAD® Map 3D®
Revit®
Autodesk Inventor®
Autodesk Navisworks®

Via Through the Interface: API wishlist surveys for Autodesk products

Tuesday, December 22, 2009

Run-time error '429': ActiveX component can't create object solution for VBA 64-bit

Code like this will result in error in AutoCAD Architecture 2010 64-bit:
Set SchedApp = New AecScheduleApplication

Or this in AutoCAD 2010 64-bit:
Set SSM = New AcSmSheetSetMgr

One method that seems to work is to move the code from within a sub to the declaration like this:
Private SchedApp As New AecScheduleApplication

Another method is to replace it using GetInterfaceObject like this:
Set SchedApp = ThisDrawing.Application.GetInterfaceObject("AecX.AecScheduleApplication.6.0")

The reason is that VBA runs as an out-of-process client in 64-bit applications.

Unfortunately this also means that Sheet Set Manager API cannot be used in 64-bit applications because it is a COM server that cannot be called from another process as opposed to an ActiveX server.

Another 64-bit related problem is in AutoCAD Architecture 2009/2010 and AutoCAD MEP 2009/2010. In Tools>References the AutoCAD tlb shows up but not for the verticals. The same problem is also in .NET if you look at the COM tab when adding references.

The solution for this is a fix in the registry that look like this:

[HKEY_CLASSES_ROOT\TypeLib\{E8BCE300-BF69-431B-9153-1FF0DEF8F613}\6.0\0\win32]
@="C:\\Program Files\\Common Files\\Autodesk Shared\\AecXBase60.tlb"

It needs to be done for each tlb you want to use. There is a win64 key but the win32 key is missing so it needs to be added.

Here is also a Microsoft KB describing similar problems with Office.

Monday, October 19, 2009

Learn how to convert VBA code into VB.NET for AutoCAD

Visit Through the Interface for details on the free webcast.

The session will be taking place at 8am Pacific/10am Eastern/4pm in the UK/5pm in Central Europe, on October 20, 2009. If you cannot make it the webcast will be recorded.

If you need help to convert or migrate old VBA code to VB.NET or C#, JTB World can help with this service. You’re welcome to contact us.

Thursday, September 24, 2009

Hide or isolate objects in AutoCAD freeware

I mentioned a few days ago that I wanted to release a freeware and here it is.

You can hide, isolate or unisolate selected objects with it.

It is free and without support and released as it is. It is a VBA program that you need to load with VBALOAD and then the form can be showed with VBARUN running IsolateHideObjects.dvb!Start.Isolate.
It can be called by AutoLISP like this:
(vl-vbarun "c:/temp/IsolateHideObjects.dvb!Start.Isolate")

Download here.
(notice the warning in the comments about the risk of saving a drawing without using UnIsolate so make sure to know about potential side effects)

For any questions please keep them as comment in this blog post.

Tuesday, July 28, 2009

AutoCAD .NET Developer's Guide

This is really great news! I have reviewed a lot of the guide and can testify that it will be useful for many.
This guide provides information on how to use the AutoCAD .NET API with Microsoft Visual Studio and the programming languages VB.NET and C#. Information specific to developing applications using Microsoft Visual Studio can be found under the topics “Getting Started with Microsoft Visual Studio” and “Develop Applications with Microsoft Visual Studio.”
Programmers developing with the .NET Framework using a development environment other than Microsoft Visual Studio can skip these two chapters. However, all of the example code in this guide is presented in VB.NET and C#.
You can access the AutoCAD .NET Developer’s Guide online:
http://www.autodesk.com/autocad-net-developers-guide


Introduction

Getting Started with Microsoft Visual Studio

Basics of the AutoCAD .NET API

Control the AutoCAD Environment

Create and Edit AutoCAD Entities

Dimensions and Tolerances

Work in Three-Dimensional Space

Define Layouts and Plot

Use Events

Develop Applications with VB.NET and C#

VBA/VB to VB.NET and C# Comparison

VBA to VB.NET and C# Comparison

AutoCAD .NET Developer's Guide

Here is also some great screencasts from Microsoft.

Wednesday, May 27, 2009

ProSteel 3D customization using COM with AutoLISP and VBA

I have done coding using the ProSteel API and it is pretty extensive and flexible. I made improvements to the logic used to add position numbers on the steel structure objects as well as creating a two way sync of object properties between AutoCAD and a database. I also created other customizations to automate the workflow further both for working with the 3D model as well as the 2D generation. Another thing I did was to manipulate the ProSteel model so it worked better to use the information in Navisworks.

Either ps3d_com.arx (PSComWrapper Type Library) or ProStructuresLoader.arx are used and it works fine to develop with either AutoLISP or VBA. (VB.NET or C# should be possible to use)

Unfortunately there are not many resources about usage of the ProSteel COM interface other than the included documentation but the other day I run into this site that has some examples posted.

ProSteel was created by Kiwi Software GmbH and later acquired by Bentley and is an add-on running on the AutoCAD platform.

If you need any customization done for ProSteel (or AutoPLANT Structural) feel free to contact me.

Previous blog post talking about ProSteel 3D.

Wednesday, April 29, 2009

Learn how to migrate from VBA to .NET for AutoCAD

VBA is going away from AutoCAD in a coming release but ActiveX that is the API will remain so you can use the same API you are familiar with within .NET using COM Interop. So if you’re familiar with the ActiveX Object Model you get get up and running in .NET quicker.

In the four examples in this Autodesk Developer Network Network DevTV Visual Basic Express is used and you learn how to prepare code to use late binding and then export from VBA via VB6 format and end up with VB.NET code. There is even a great free macro that makes the VB6 project without requiring VB6.

AutoCAD VBA to .NET Migration Basics
view
download (140 Mb)
supporting files (1.72 Mb)

  • Example 1 is showing manual migration using VB6
  • Example 2 is showing the migration using the migration macro
  • Example 3 is dealing with user forms and problems with late binding and why it is good to change Object to something more specific using early binding
  • Example 4 is for referencing other type libraries than the AutoCAD ones. The example shows object referencing Excel and Word

Via Through the Interface

See also the posts More details on VBA in AutoCAD 2010 products, AutoCAD 2010 VBA and VSTA future and No VBA installed with AutoCAD 2010

Sunday, April 5, 2009

AutoCAD and DWG viruses made in VBA or AutoLISP

According to this Knowledge Base document: AutoCAD and Viruses “The two main types of viruses that can affect AutoCAD are VBA macros embedded in drawing files and AutoLISP that runs automatically when a drawing is opened.” The document also describes some ways to protect against potential viruses or malicious code.

It would also be possible that a virus comes through other means like ARX or DLL files possibly in combination with EXE, BAT, CMD or VBS files that could register the files to make them load automatically.

Personally I have never run in run into any AutoCAD related virus or malware. Probably because they are not that common.

ACAD.Star was probably the first VBA virus for AutoCAD and was discovered in 2000 by Kaspersky more than a year after the AutoCAD 2000 version was released.

Another way to get infected is if you download a cracked AutoCAD version that is injected with a virus or worm.

AL/Bursted-Fam is a family of AutoCAD LISP (AutoLISP) virus. If an infected file is received as ACAD.LSP and an AutoCAD Drawing is loaded from the same folder the virus becomes resident within AutoCAD. AL/Bursted-Fam edits the existing global ACAD.LSP or creates one to load  itself at AutoCAD startup from another LSP file in the same folder. When an AutoCAD drawing (DWG file) is editted an ACAD.LSP will be created in the same folder as the drawing. – Sophos. Another one is AL/Billy-A

One good thing with AutoCAD 2010 is that VBA is not even installed as default and eventually VBA will not be available for AutoCAD at all. :)

Tuesday, March 31, 2009

Autodesk Network License Manager 11.5.0 system requirements

Autodesk Network License Manager 11.5.0 (that comes with 2010-based products like AutoCAD 2010) is supported on the following operating systems:

  • Windows Vista 32-bit SP1
  • Windows Vista 64-bit SP1
  • Windows XP 32-bit SP3
  • Windows XP 64-bit SP2
  • Windows 2003 R2 Server Edition
  • Windows 2003 Server Edition
  • Windows 2000 Server Edition

Some other new documents are:

Knowledge Base document: Supported operating systems for the Autodesk Network License Manager shipped with 2010 products

The path for the Plot Styles folder has been moved from a sibling level of the Plotters folder to a subdirectory in the Plotters folder. - Knowledge Base document: Location of Plot Styles folder

Knowledge Base document: VBA support in AutoCAD 2010


Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner