Monday, December 12, 2011

How to write AutoLISP that works on both Windows and Mac

If you want to write AutoLISP code that works for both AutoCAD on Windows and AutoCAD for Mac remember that there is no support for DCL or COM interfaces such as VLA or VLAX (Visual LISP).

There are 4 new AutoLISP functions in AutoCAD 2012 that can help as long as you don’t need backward compatibility:

  • dumpallproperties - Outputs all the properties and their current value for the specified entity.
  • getpropertyvalue - Returns the current value of the specified property for an entity.
  • ispropertyreadonly - Returns T or nil of the specified property for an entity is read-only or not.
  • setpropertyvalue - Sets the specified property to a new value for an entity.

The following example demonstrates how to get the current radius value of a circle.
Command: (command "_circle" "2,2" 2)
nil
Command: (getpropertyvalue (entlast) "radius")
2.0

The following example demonstrates how to change the radius of a circle.
Command: (command "_circle" "2,2" 2)
nil
Command: (setpropertyvalue (entlast) "radius" 3)

For more see Hyperpics and Accessing Information About Layers in a Drawing with GETPROPERTYVALUE.

No comments:

Post a Comment