AutoCAD: Secrets Every User Should Know

Selection Sets and Entity Manipulation

In Chapter 8, you saw a list of GET functions functions designed to get data or objects. Most of them are simple and allow you to prompt users so they know what kind of data you re trying to get. Now let s look at some functions that are more powerful and complex. First I ll show you how your AutoLISP program can get information about entities in your drawing. Once you understand how to get information from an entity, I ll show you how to use that information.

ASSOC, ENTGET, ENTSEL

The ASSOC, ENTGET, and ENTSEL functions show up all the time in AutoLISP programs. They can work together to get a ton of information from an entity in the drawing. You can find out what the entity is, what layer it s on, what linetype it uses, and so on. Enter the following line of code at the AutoCAD command line with an Enter, and then select a circle when prompted. This line will prove extremely useful in future programs:

(cdr (assoc 5 (entget (car (entsel)))))

The value returned will vary, but it s always a hexadecimal number that represents the entity s handle. AutoCAD assigns a handle to each entity as it s created. The handle is permanently associated with that entity.

Hexadecimal numbers are base 16 numbers, rather than base 10: hex (6) + decimal (10) are combined to form the word hexadecimal (16). Hexadecimals are used in computing because they can represent binary values with fewer...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Math Calculation Software
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.