Friday, March 6, 2009

InitCommandVersion and ^R control sequence explained

The ^R control sequence forces AutoCAD to use the newest version of the command. When the ^R control sequence is not used, the oldest version of the command is used. For example, in AutoCAD 2009 or AutoCAD 2010, the following command macro ends after setting the radius value, which is not what would happen in AutoCAD 2008. The following command macro shows the FILLET command using the Multiple option and setting a radius of 0.1:

^C^C_fillet;u;r;0.1;

This command macro does not work correctly in AutoCAD 2009 or newer versions, as the FILLET command is being interpreted to use its legacy command behavior, prompting sequence, and options. The following shows the command prompt for the legacy FILLET command:

Current settings: Mode = TRIM, Radius = 0.1000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]:

To use the newest command behavior, add the ^R control sequence before the command in the command macro. The following shows the same command macro using the new ^R control sequence:

^C^C^R_fillet;u; r;0.1;

The command prompt and options for the above command macro look like the following:

Current settings: Mode = TRIM, Radius = 0.1000
Select first object or [uNdo/Polyline/Radius/Trim/mUltiple]:

Running the command macro with the ^R control sequence and the FILLET command makes it behave just like it did in AutoCAD 2008.

If you are using AutoLISP, you can control which version of a command is used by preceding the Command function with the InitCommandVersion function.  The syntax for the InitCommandVersion function is as follows:

(InitCommandVersion <version_number>)

where <version_number> controls which version of the command should be used for the preceding command being executed by the Command function.

The following example demonstrates how to use version 1 (or the oldest version) of the FILLET command:

(InitCommandVersion 1)
(command “fillet”)

AutoCAD commands that have been updated to support versioning:

-ARCHIVE, -COLOR, -ETRANSMIT, -GROUP, -IMAGE, -INSERT, -LAYER, -STYLE, -TABLE, -VIEW, 3DCONFIG, 3DMOVE, 3DROTATE, ABOUT, ARCHIVE, ARRAY, ATTDEF, ATTEDIT, ATTEXT, BCLOSE, BEDIT, BHATCH, BLOCK, BOUNDARY, BOX, BPARAMETER, BPOLY, BSAVEAS, BVSTATE, BWBLOCKAS, CHAMFER, CLASSICIMAGE, CLASSICXREF, COLOR, CONVERT, CONVERTCTB, CONVERTPSTYLES, COPY, COPYTOLAYER, CUILOAD, CUIUNLOAD, DDEDIT, DIM, DIMEDIT, DIMSTYLE, DTEXT, DWGCONVERT, DXFIN, DXFOUT, ETRANSMIT, EXECUTETOOL, EXPLODE, EXTRUDE, FILLET, GROUP, HATCH, HATCHEDIT, HELIX, HIDE, IMAGE, IMAGEADJUST, INSERT, LAYDEL, LAYER, LAYISO, LAYMCH, LAYMRG, LAYOUT, LINETYPE, LOFT, LWEIGHT, MASSPROP, MENULOAD, MENUUNLOAD, MLEADER, MLEDIT, MOVE, MTEXT, MVIEW, OPENDWFMARKUP, OSNAP, PAN, PLOTSTAMP, PSETUPIN, PSOUT, PURGE, QUICKCALC, RENAME, RENDER, REVOLVE, SCALE, SHADE, SHADEMODE, SOLIDEDIT, STRETCH, STYLE, TABLE, TABLEDIT, TABLESTYLE, TOOLBAR, UNITS, VBALOAD, VBARUN, VIEWPORTS, VPLAYER, VPORTS, WBLOCK, WSSAVE, XBIND, XREF

InitCommandVersion can also be used as a substitute for initdia when it does not work as expected (AutoCAD 2012).

For more read the Knowledge Base document: Command macro does not work the same as it did in AutoCAD 2008 and previous versions

No comments:

Post a Comment

Subscribe to the comments feed

Some of the latest blog posts

Subscribe to RSS headline updates from:
Powered by FeedBurner

Contact Us | About JTB World | Subscribe to this blog
JTB World's website | Website General Terms of Use | Privacy Policy
^ Top of page

© 2004- JTB World. All rights reserved.