Make_LSP - Help
About Make_LSP
Make_Lsp.lsp is a AutoLisp cogenerator. This program
will write AutoLisp programs for you. Answer a series of questions and out pops a
program. (Unless you have an error.)
Errors
Most of the errors I've come across with this program have been in two
categories.
1. Path problem.
Make sure that all files are in your AutoCad search path. I
strongly suggest you put them in your working directory.
2. Confusion.
This program was designed to alter properties on autocad
entities with the ability to use a few autocad commands on the selection set before or
after altering the properties. You need to use the program as it was designed. Why
would you want to write a program that copies entities? AutoCAD has that command
already.
This program will not do anything unless you alter the properties
of at least one entity.
I'll step you through an example
program:
My first program: Let's write a program that changes all text in a
drawing to layer "TX".
Directions: Everything in black will be comments and
instructions. Everything in Blue will be what you see on your
screen as the program is running in AutoCad. Everything in Red
will be what you need to type in at the Command prompt. <enter>
means press the enter key.
A.
Load the make_lsp program by typing (load
"make_lsp")<enter>
B.
Run the make_lsp program by typing make_lsp
<enter>
C.
Step 1 - Name your program.
Press any key to continue to
step 1.
D.
Type in a name for your program. Let's use "Test1"
for this example. Type test1 <enter>
E.
The program will check to see if the file exist. If it exist
you will be prompted to overwrite. Select Y or N. If you choose not to overwrite,
you will loop back to select a name.
*************************************************************
* ....Please Wait.....Waiting For File
Verification.... *
*
*
*
*
*
*
* Program Name >
V:\lsp\TEST1.lsp
OK.
*
*
*
*************************************************************
F.
Step 2 - Selection Process
We are through with the naming process. Press
any key to continue to step 2.
G.
We now begin the process of selecting entities to work on.
You have three different ways to select entities.
******************************************
* Object Selection
Mode *
* ---------------------------------
*
* 1.
Global
*
* 2. Multiple
Selection
*
* 3. Single Object
Selection *
*
*
******************************************
1. Global
This will select everything in the drawing. This will also give you an oppurtunity
later to "double filter". Double Filter will filter out entites that do not
match certain criteria.
2. Multiple Selection.
Allows you to pick several entites to work on.
3. Single Object Selection
Allows you to pick one item to work on.
H.
In this example we want to work on all text entities. So we will select
option number one to do global object selection. Type 1
<enter>
I.
We now have all objects in the drawing inside our selection set. We
need to use some filtering to get only text entities. So we will select option number 1 to
filter. Type 1 <enter>
***********************************************************
* F i l t e
r S e l e c t i o
n
*
*
---------------------------------------------------- *
* 0. NO FILTER - WORK on ALL objects in
drawing. *
* 1. FILTER - WORK on ONLY FILTERED
objects. *
*
*
***********************************************************
J.
We need to select the type of entities we want to include in our selection
set. In this example we need all text entities. So we will select option zero to filter by
entity type. Type 0 <enter>
************************************************
*
*
* Filter Selection -
Details
*
* ------------------------------------------- *
*
*
* 0. Entity
type
*
* 2. Block
name
*
* 6. Line
type
*
* 7. Text
style
*
* 8. Layer
name
*
* 62.
Color
number
*
*
*
* X. To
Exit
*
*
*
************************************************
K.
We now have an oppurtunity to decide whether the program will prompt for
the entity type or whether we will hard code the entity type into the program. In this
example we always want to work on text entities so we will choose option 1 to make a
permanent filter name. Type 1 <enter>
************************************************************
*
*
* Method of Determining
Filter
Names
*
* ------------------------------------------------------
*
* 1. PERMANENT FILTER
NAME
*
* This will make the program filter the
entities *
* to the same settings every
time.
*
* Ex. If you wanted this program to work
on text *
* that was on layer
TEXT1 every time then you *
* could make layer name
- TEXT1 a permanent *
* setting and the
program would automatically *
* get just the text on
layer
TEXT1.
*
*
*
* 2. USER
RESPONSE
*
* Ask the user what filter to use every
time. *
* Ex. Instead of filtering out all text but
text *
* on layer name TEXT1
(in the example above) *
* the program would ask
what layer the text *
* was
on.
*
*
*
************************************************************
L.
Next we select the entity type to filter for. In this example we
want to filter for text entities. So we will select the text option. Type 9 <enter>
*****************************************************************
*
Filter
Details
*
*
---------------------------------------------------------- *
* 1. Arc 4.
Block 7. Circle 10.
Dimension *
* 2. Insert 5.
Line 8. Polyline 11.
Point *
* 3. Shape 6.
Solid 9. Text 12.
Trace *
*
*
*****************************************************************
M.
We are now back at the Filter Selection Screen. We can add
additional filters if we wanted to. For example if we wanted just text that was in
the "Simplex" style we could select option 7 and add that filter. In this
example we want all text no matter what color, layer, or style. So we
will select option X to exit. Type X <enter>
***************************************************
* Filter
Selection -
Details *
* ------------------------------------------- *
*
*
* 0. Entity
type
*
* 2. Block
name
*
* 6. Line
type
*
* 7. Text
style
*
* 8. Layer
name
*
* 62.
Color
number
*
*
*
* X. To
Exit
*
*
*
*
*
* Filters: ( 0
)
*
*
*
***************************************************
N.
Now we get to the power of Double Filtering. If we wanted to get all
text entities in the drawing that were rotated at 45 degrees or were of a certain height
or value, we could do that now with double filtering. In this example we want ALL
text so, we will select the NO option. Type N <enter>
********************************************************
* D o u b l
e F i l t e
r *
* --------------------------------------------------- *
* YES - Double
Filter.
*
* Allows
the use of a double-filtering *
*
system. (Ex. If you wanted to change *
* all the
text in your drawing that was *
* rotated
at 45 degrees to a different *
* layer or
a different rotation angle *
* this is
the function you would use.) *
* Valid
Double-Filters
are:
*
* Angle,
Height, Elevation, Thickness, *
* Radius,
& Text
Value.
*
*
*
* NO - Do not Double
Filter.
*
* Use
Standard Filtering
only.
*
*
*
********************************************************
O.
We are now through with the entity selection process. Press any key to continue to step 3.
P.
Step 3 - Alter Properties
If you choose to exit the program at this point, you will not write the
program. You will lose all information and
have to start over. There's no sense in writing a program that will not do anything.
Right?
If you choose to use an Auto-Cad Command at this point you will write
the program when you exit but, your program will not do anything.
You have to choose to Alter properties at this point. We will
loop back through here at a later time during this example and at that point the other
options will be valid. (If this were visual basic I would have greyed out options 0 and 2
until you altered some properties.)
So, select Alter Properties. Type 1
<enter>
****************************************************
* Alter Properties / Command
Selection *
* --------------------------------------------
*
*
*
* 0.
EXIT
*
*
*
* 1. ALTER PROPERTIES (Change
Command) *
*
*
* Ex. Change layer, Linetype,
Text style, *
*
Text value, Text height, ect. *
*
*
* 2. USE AUTO-CAD
COMMANDS
*
*
*
* Ex. Move, Rotate, Scale,
Array, Copy, *
*
Offset, Mirror,
ect.
*
*
*
****************************************************
Q.
Property Menu
There are a lot of properties that we can alter. In this example
we want to change all text to the layer "TX". So, we would select option
8 to change the layer. Type 8 <enter>
*******************************************************
*
Property
Menu
*
* ------------------------------------------------- *
* 0. EXIT
MENU 10. Start
point *
* 1. Text
Value 11. End
point *
* 4. Text Search/Replace 38. Polyline
width *
* 6. Line
type 39. 3d
Thickness *
* 7. Text
style 40. Radius,
Height *
* 8.
Layer
50. Rotation angle *
* 9.
Match
62.
Color
*
*
*
*******************************************************
R.
Property Input Selection.
We can choose whether the program prompts us each time for the layer name or whether we
hard code the layer name into the program. If we choose option one the program
will ask us the layer's name to change to every time it runs. In this example we
want to change to layer "TX". So, we would select a permanent value. Type 2 <enter>
***********************************************************
* Property
Input
Selection
*
*
---------------------------------------------------- *
*
*
* How do you want the property values to be
changed? *
*
*
* 1.
User to type in new value
each *
* time
the program
runs.
*
* 2.
Set a permanent value
now.
*
*
*
***********************************************************
S.
The program will now ask you
for the permanent layer name. Type in the
layer name "TX" and press enter. Type TX
<enter>
T.
We are now back at the Alter Properties / AutoCAD Command
menu. At this point we can choose alter properties to do even more changes to the text
we've selected or we can choose to use an AutoCad command on the selection set. In
this example we have accomplished all of our goals. We are going to change ALL text
in the drawing to layer "TX". We simply need to exit the menu by selecting
option zero. Type 0 <enter>
U.
The program will now write the autoLisp
code and ask you if you want to load
the program and try it out. Type Y <enter>
********************************************************************
* M A K E _
L S P . l s p C o m p l e t e
d *
*
------------------------------------------------------------- *
*
*
*
*
* This concludes the
Auto_lisp program
maker. *
*
*
* Load your
new program and try it
out.
*
*
*
*
*
* Load Program? Y/N
:
*
*
*
********************************************************************
V.
Type the name of your program and test it. Type Test1 <enter>
End of My First Program.
Note: This was a very simple program.
You can get quite complicated with all of the options available to you. I'll try to
find time to step you through a complicated program in the near future.
Back to AutoLisp
Home
All questions/complaints/suggestions should be sent to /
Last Updated January 4th, 2012
Copyright 2002-2012 /. All rights reserved. |