SolidWorks

Sheet Metal Guy INDUSTRY DIRECTORY: The most comprehensive resource for businesses in the metal forming, fabricating, and welding industries.

 

 
Home


 

 

 

 

 

 


 

Click here for Customizing SolidWorks For Greater Productivity

The GPS Center

Top Selling SolidWorks Book
SolidWorks for the Sheet Metal Guy - Course 1: Part Creation
"The book was easy to follow. I have bought other books to learn how to use SolidWorks. This book took me to a new level."
- Charles Hugo

 

Nate's Simple AutoLisp - Lesson 001
(

Warning/Disclaimer: I'm neither a teacher nor am I versed in the theory behind AutoLisp programming. But I invite you to come along for a ride. This stuff is not only fun, but it can be useful ! Each lesson should take 5-10 minutes.

So, here we go...

Lesson 001 - Picking stuff

We'll start out simple, nothing fancy. We'll just type and run AutoLisp expressions right at your AutoCAD "Command:" line prompt.

1. Open up an AutoCAD drawing. Draw a LINE entity anywhere.
2. At the Command: prompt type this... (entsel) [Enter]

nate_lesson_001a.jpg

3. As soon as you hit the [Enter] key, AutoCAD evaluates what you've typed on the command line. The word "entsel" inside of the open and close parenthesis is a predefined AutoLisp function for picking stuff, one thing at a time. It defaults to a "Select object:" prompt. Now pick on the LINE entity in your drawing.

You will see something like this displayed on your command line:

nate_lesson001b.jpg

It is a "list" of two pieces of data. Only the first element is of interest to us now. It's a numeric code that gives the entity name identifier of the LINE entity you selected.

Okay, let's dig a bit deeper.

We need to isolate this entity name from the two-element list returned by (entsel).

4. Type this at the command line prompt: (car (entsel)) [Enter]
5. Pick on a line entity. Now you'll see the entity name code all by itself. The "(car ... )" AutoLisp function returns the first element of a multi-element list.

nate_lesson001c.jpg

Now, the cool part. We're going to "open" up and display the guts of a picked entity.

6. Type this at the command line prompt: (entget (car (entsel))) [Enter]
7. Pick on a line entity. Now you'll see a bunch of data displayed in your command window. It will look something like this:

nate_lesson001d.jpg

At first it just looks like gibberish. But there is some interesting stuff in here. Let's poke around.

This is the basic data about our picked LINE entity. It is a "list" of stuff. Each element of this list starts with a group code number followed by the value for that group code.

Group code 0 give the entity type. Look at the data and pick it out. You'll see (0 . "LINE"). So, we picked on a LINE entity.

For a LINE entity, group code 10 gives the line's staring X,Y,Z coordinate. Look for the (10 ....) entry in the data dump. The data following the 10 is the starting X,Y,Z coordinate. Group code 11 gives the ending X,Y,Z coordinate.

Group code 8 gives the layer name that the entity is inserted on.

Okay, that's all for now. Time's up. Hope to see you for the next lesson!

Nate's Simple AutoLisp - Lesson 002
Nate's Simple AutoLisp - Lesson 003
 

 
 

Controlling the Machine

 

Nate HoltNate Holt
Coinciding with the acquisition of VIA Development, Nate joined Autodesk in March of 2003 after a decade stint as an entrepreneur following a two-decade stint as a controls engineer and software applications developer at Owens-Corning. Nate is now the lead product architect for AutoCAD Electrical. He loves this stuff.

 
 

 

 

Nate's Simple AutoLisp - Lesson 002

Nate's Simple AutoLisp - Lesson 003

Controlling the Machine

Signup for our free AutoCAD Tips and Tricks

AllAboutAutoCAD.com
AllAboutAutoCAD.com

AllAboutInventor.com

AllAboutInventor.com

AllAboutSolidEdge.com
AllAboutSolidEdge.com
About SolidWorks
AboutSolidWorks.com
SheetMetalGuy.com
SheetMetalGuy.com

Home | About | Contact Us | Privacy Policy | Return Policy | Site Terms
All About Community | All About AutoCAD | All About Inventor | All About Solid Edge | About SolidWorks | Sheet Metal Guy
Copyright 2008 Sheet Metal Guy | info@SheetMetalGuy.com